123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using LitJson;
- using Newtonsoft.Json;
- using SC.XR.Unity;
- using ShadowStudio.Mgr;
- using ShadowStudio.Model;
- using Studio.WebSocket.Message;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- namespace ShadowStudio.UI
- {
- [RequireComponent(typeof(WorldDlg))]
- public class CreateSearchRoomDlg : UnitySingleton<CreateSearchRoomDlg>
- {
- private Button clearBtn;
- private Button createRoomBtn;
- private Button deleteBtn;
- private Button aboutmeBtn;
- private SCInputField searchRoomInputFiled;
- public WorldDlg dlg;
- private XRImage3D image3D;
- private void Start()
- {
- dlg = GetComponent<WorldDlg>();
- dlg.showDlg();
- clearBtn = dlg.GetBreadthChild<Button>("ClearBtn");
- clearBtn.onClick.AddListener(OnClickClear);
- createRoomBtn = dlg.GetBreadthChild<Button>("CreateRoomBtn");
- createRoomBtn.onClick.AddListener(OnClickCreateRoom);
- deleteBtn = dlg.GetBreadthChild<Button>("DeleteBtn");
- deleteBtn.onClick.AddListener(OnClickDelete);
- aboutmeBtn = dlg.GetBreadthChild<Button>("AboutmeBtn");
- aboutmeBtn.onClick.AddListener(OnClickAboutmeBtn);
- searchRoomInputFiled = dlg.GetBreadthChild<SCInputField>("SearchRoomInputFiled");
- searchRoomInputFiled.onEndEdit.AddListener(InputSearchRoomEnd);
- searchRoomInputFiled.onValueChanged.AddListener(SearchRoomChanged);
- if (UserInfoMgr.Instance.userConfig.Login_type == "3")
- {
- createRoomBtn.gameObject.SetActive(false);
- deleteBtn.gameObject.SetActive(false);
- }
- WSHandler.User.OnSearchRoom += searchRoom;
- searchRoomInputFiled.text = "";
- clearBtn.gameObject.SetActive(false);
- image3D = transform.Find("UIRoot/AboutmeBtn/IconXRImage3D").GetComponent<XRImage3D>();
- for (int i = 0; i < CommonMethod.UserAvatarsList.Count; i++)
- {
- if (UserInfoMgr.Instance.userConfig.Avatar == CommonMethod.UserAvatarsList[i].Url)
- {
- string path = "Avatar/" + CommonMethod.UserAvatarsList[i].Id + "Avatar";
- if (image3D)
- {
- image3D.simple = Resources.Load(path) as Texture2D;
- }
- }
- }
- SettingSystem();
- }
- public void SettingSystem()
- {
- if (PlayerPrefs.HasKey(UserInfo.Account + "_SystemSetting"))
- {
- string SystemData = PlayerPrefs.GetString(UserInfo.Account + "_SystemSetting");
- SystemDatas data = JsonConvert.DeserializeObject<SystemDatas>(SystemData);
- CustomInfo.isSendVideo = data.Camera == 1 ? true : false;
- CustomInfo.isSendAudio = data.Mic == 1 ? true : false;
- UserInfo.systemDatas = data;
- }
- else
- {
- CustomInfo.isSendVideo = true;
- CustomInfo.isSendAudio = true;
- }
- }
- private void SearchRoomChanged(string searchroom)
- {
- if (searchroom != "")
- {
- if (!searchroom.Contains(" "))
- {
- WSHandler.User.SearchRoom(searchRoomInputFiled.text);
- }
- clearBtn.gameObject.SetActive(true);
- }
- else
- {
- clearBtn.gameObject.SetActive(false);
- OnClear();
- }
- }
- private void InputSearchRoomEnd(string searchroom)
- {
-
- }
- private void OnEnable()
- {
- if(dlg!=null)
- dlg.showDlg();
- }
- private void OnClickDelete()
- {
- //被zby替换的代码
- //((RoomListDlg.Instance.roomlist) as RoomList).ShowDeleteBtn();
- EventTool.DisplayDeleteMethod();
- }
- private void OnClickClear()
- {
- searchRoomInputFiled.text = "";
- }
- private void OnClear()
- {
- //被zby替换的代码
- //RoomListDlg.Instance.ClearConfig();
- //for (int i = 0; i < HomeViewMgr.Instance.SelfRoomConfigList.Count; i++)
- //{
- // RoomListDlg.Instance.AddConfig(HomeViewMgr.Instance.SelfRoomConfigList[i]);
- //}
- //int ct = HomeViewMgr.Instance.SelfRoomConfigList.Count;
- //for (int i = ct - 1; i < 6 - ct; i++)
- //{
- // RoomConfig roomConfig0 = new RoomConfig("", "1", "教育", "", "", "", "", "", "", "");
- // RoomListDlg.Instance.AddConfig(roomConfig0);
- // HomeViewMgr.Instance.SelfRoomConfigList.Add(roomConfig0);
- //}
- //RoomListModel.Instance.UpdateList(RoomListDlg.Instance.roomlist);
- //RoomListDlg.Instance.roomlist.showItemEffect();
- ConfigModel.Instance.Clear();
- for (int i = 0; i < HomeMgr.Instance.SelfRoomConfigList.Count; i++)
- {
- ConfigModel.Instance.InitElement(HomeMgr.Instance.SelfRoomConfigList[i]);
- }
- while (ConfigModel.Instance.Count < 5)
- {
- RoomConfig itemConfig = new RoomConfig("", "1", "教育", "", "", "", "", "", "", "");
- ConfigModel.Instance.InitElement(itemConfig);
- HomeMgr.Instance.SelfRoomConfigList.Add(itemConfig);
- }
- MenuListDlg.Instance.LoadData();
- MenuListDlg.Instance.UpdateData();
- MenuListDlg.Instance.Show();
- }
- private void searchRoom(SearchRoomResponseMessage message)
- {
- //被zby替换的代码
- //RoomListDlg.Instance.ClearConfig();
- ConfigModel.Instance.Clear();
- for (int i = 0, roomCount = message.data.Count; i < roomCount; i++)
- {
- RoomNetData roomNetData = message.data[i];
- RoomConfig itemConfig = new RoomConfig(roomNetData,"0");
- ConfigModel.Instance.InitElement(itemConfig);
- }
- //被zby替换的代码
- //RoomListModel.Instance.UpdateList(RoomListDlg.Instance.roomlist);
- //RoomListDlg.Instance.roomlist.showItemEffect();
- MenuListDlg.Instance.LoadData();//先加载数据
- MenuListDlg.Instance.UpdateData();//再刷新数据显示
- MenuListDlg.Instance.Show();//再显示动效
- }
- private void OnClickCreateRoom()
- {
- //被zby替换的代码
- //HomeViewMgr.Instance.roomList.hide();
- HomeMgr.Instance._menuListDlg.Hide();
- dlg.hideDlg();
- Invoke("GotoView", 1.3f);
- }
- private void OnClickAboutmeBtn()
- {
- //被zby替换的代码
- //HomeViewMgr.Instance.roomList.hide();
- HomeMgr.Instance._menuListDlg.Hide();
- dlg.hideDlg();
- Invoke("GotoAboutme", 1.3f);
- }
- private void GotoView()
- {
- //被zby替换的代码
- //HomeViewMgr.Instance.ShowView(HomeViewMgr.CREATROOMDLG);
- //HomeViewMgr.Instance.roomListDlg.SetActive(false);
- HomeMgr.Instance.ShowView(HomeMgr.CREATROOMDLG);
- if (CreateRoomDlg.Instance)
- {
- CreateRoomDlg.Instance.Init();
- }
- HomeMgr.Instance.roomListDlg.SetActive(false);
- }
- private void GotoAboutme()
- {
- //被zby替换的代码
- //HomeViewMgr.Instance.ShowView(HomeViewMgr.AboutMeDlg);
- //HomeViewMgr.Instance.roomListDlg.SetActive(false);
- HomeMgr.Instance.ShowView(HomeMgr.AboutMeDlg);
- HomeMgr.Instance.roomListDlg.SetActive(false);
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- WSHandler.User.OnSearchRoom -= searchRoom;
- }
- }
- }
|