CreateSearchRoomDlg.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using LitJson;
  2. using Newtonsoft.Json;
  3. using SC.XR.Unity;
  4. using ShadowStudio.Mgr;
  5. using ShadowStudio.Model;
  6. using Studio.WebSocket.Message;
  7. using System;
  8. using System.Collections;
  9. using System.Collections.Generic;
  10. using UnityEngine;
  11. using UnityEngine.UI;
  12. using XRTool.Util;
  13. using XRTool.WorldUI;
  14. namespace ShadowStudio.UI
  15. {
  16. [RequireComponent(typeof(WorldDlg))]
  17. public class CreateSearchRoomDlg : UnitySingleton<CreateSearchRoomDlg>
  18. {
  19. private Button clearBtn;
  20. private Button createRoomBtn;
  21. private Button deleteBtn;
  22. private Button aboutmeBtn;
  23. private SCInputField searchRoomInputFiled;
  24. public WorldDlg dlg;
  25. private XRImage3D image3D;
  26. private void Start()
  27. {
  28. dlg = GetComponent<WorldDlg>();
  29. dlg.showDlg();
  30. clearBtn = dlg.GetBreadthChild<Button>("ClearBtn");
  31. clearBtn.onClick.AddListener(OnClickClear);
  32. createRoomBtn = dlg.GetBreadthChild<Button>("CreateRoomBtn");
  33. createRoomBtn.onClick.AddListener(OnClickCreateRoom);
  34. deleteBtn = dlg.GetBreadthChild<Button>("DeleteBtn");
  35. deleteBtn.onClick.AddListener(OnClickDelete);
  36. aboutmeBtn = dlg.GetBreadthChild<Button>("AboutmeBtn");
  37. aboutmeBtn.onClick.AddListener(OnClickAboutmeBtn);
  38. searchRoomInputFiled = dlg.GetBreadthChild<SCInputField>("SearchRoomInputFiled");
  39. searchRoomInputFiled.onEndEdit.AddListener(InputSearchRoomEnd);
  40. searchRoomInputFiled.onValueChanged.AddListener(SearchRoomChanged);
  41. if (UserInfoMgr.Instance.userConfig.Login_type == "3")
  42. {
  43. createRoomBtn.gameObject.SetActive(false);
  44. deleteBtn.gameObject.SetActive(false);
  45. }
  46. WSHandler.User.OnSearchRoom += searchRoom;
  47. searchRoomInputFiled.text = "";
  48. clearBtn.gameObject.SetActive(false);
  49. image3D = transform.Find("UIRoot/AboutmeBtn/IconXRImage3D").GetComponent<XRImage3D>();
  50. for (int i = 0; i < CommonMethod.UserAvatarsList.Count; i++)
  51. {
  52. if (UserInfoMgr.Instance.userConfig.Avatar == CommonMethod.UserAvatarsList[i].Url)
  53. {
  54. string path = "Avatar/" + CommonMethod.UserAvatarsList[i].Id + "Avatar";
  55. if (image3D)
  56. {
  57. image3D.simple = Resources.Load(path) as Texture2D;
  58. }
  59. }
  60. }
  61. SettingSystem();
  62. }
  63. public void SettingSystem()
  64. {
  65. if (PlayerPrefs.HasKey(UserInfo.Account + "_SystemSetting"))
  66. {
  67. string SystemData = PlayerPrefs.GetString(UserInfo.Account + "_SystemSetting");
  68. SystemDatas data = JsonConvert.DeserializeObject<SystemDatas>(SystemData);
  69. CustomInfo.isSendVideo = data.Camera == 1 ? true : false;
  70. CustomInfo.isSendAudio = data.Mic == 1 ? true : false;
  71. UserInfo.systemDatas = data;
  72. }
  73. else
  74. {
  75. CustomInfo.isSendVideo = true;
  76. CustomInfo.isSendAudio = true;
  77. }
  78. }
  79. private void SearchRoomChanged(string searchroom)
  80. {
  81. if (searchroom != "")
  82. {
  83. if (!searchroom.Contains(" "))
  84. {
  85. WSHandler.User.SearchRoom(searchRoomInputFiled.text);
  86. }
  87. clearBtn.gameObject.SetActive(true);
  88. }
  89. else
  90. {
  91. clearBtn.gameObject.SetActive(false);
  92. OnClear();
  93. }
  94. }
  95. private void InputSearchRoomEnd(string searchroom)
  96. {
  97. }
  98. private void OnEnable()
  99. {
  100. if(dlg!=null)
  101. dlg.showDlg();
  102. }
  103. private void OnClickDelete()
  104. {
  105. //被zby替换的代码
  106. //((RoomListDlg.Instance.roomlist) as RoomList).ShowDeleteBtn();
  107. EventTool.DisplayDeleteMethod();
  108. }
  109. private void OnClickClear()
  110. {
  111. searchRoomInputFiled.text = "";
  112. }
  113. private void OnClear()
  114. {
  115. //被zby替换的代码
  116. //RoomListDlg.Instance.ClearConfig();
  117. //for (int i = 0; i < HomeViewMgr.Instance.SelfRoomConfigList.Count; i++)
  118. //{
  119. // RoomListDlg.Instance.AddConfig(HomeViewMgr.Instance.SelfRoomConfigList[i]);
  120. //}
  121. //int ct = HomeViewMgr.Instance.SelfRoomConfigList.Count;
  122. //for (int i = ct - 1; i < 6 - ct; i++)
  123. //{
  124. // RoomConfig roomConfig0 = new RoomConfig("", "1", "教育", "", "", "", "", "", "", "");
  125. // RoomListDlg.Instance.AddConfig(roomConfig0);
  126. // HomeViewMgr.Instance.SelfRoomConfigList.Add(roomConfig0);
  127. //}
  128. //RoomListModel.Instance.UpdateList(RoomListDlg.Instance.roomlist);
  129. //RoomListDlg.Instance.roomlist.showItemEffect();
  130. ConfigModel.Instance.Clear();
  131. for (int i = 0; i < HomeMgr.Instance.SelfRoomConfigList.Count; i++)
  132. {
  133. ConfigModel.Instance.InitElement(HomeMgr.Instance.SelfRoomConfigList[i]);
  134. }
  135. while (ConfigModel.Instance.Count < 5)
  136. {
  137. RoomConfig itemConfig = new RoomConfig("", "1", "教育", "", "", "", "", "", "", "");
  138. ConfigModel.Instance.InitElement(itemConfig);
  139. HomeMgr.Instance.SelfRoomConfigList.Add(itemConfig);
  140. }
  141. MenuListDlg.Instance.LoadData();
  142. MenuListDlg.Instance.UpdateData();
  143. MenuListDlg.Instance.Show();
  144. }
  145. private void searchRoom(SearchRoomResponseMessage message)
  146. {
  147. //被zby替换的代码
  148. //RoomListDlg.Instance.ClearConfig();
  149. ConfigModel.Instance.Clear();
  150. for (int i = 0, roomCount = message.data.Count; i < roomCount; i++)
  151. {
  152. RoomNetData roomNetData = message.data[i];
  153. RoomConfig itemConfig = new RoomConfig(roomNetData,"0");
  154. ConfigModel.Instance.InitElement(itemConfig);
  155. }
  156. //被zby替换的代码
  157. //RoomListModel.Instance.UpdateList(RoomListDlg.Instance.roomlist);
  158. //RoomListDlg.Instance.roomlist.showItemEffect();
  159. MenuListDlg.Instance.LoadData();//先加载数据
  160. MenuListDlg.Instance.UpdateData();//再刷新数据显示
  161. MenuListDlg.Instance.Show();//再显示动效
  162. }
  163. private void OnClickCreateRoom()
  164. {
  165. //被zby替换的代码
  166. //HomeViewMgr.Instance.roomList.hide();
  167. HomeMgr.Instance._menuListDlg.Hide();
  168. dlg.hideDlg();
  169. Invoke("GotoView", 1.3f);
  170. }
  171. private void OnClickAboutmeBtn()
  172. {
  173. //被zby替换的代码
  174. //HomeViewMgr.Instance.roomList.hide();
  175. HomeMgr.Instance._menuListDlg.Hide();
  176. dlg.hideDlg();
  177. Invoke("GotoAboutme", 1.3f);
  178. }
  179. private void GotoView()
  180. {
  181. //被zby替换的代码
  182. //HomeViewMgr.Instance.ShowView(HomeViewMgr.CREATROOMDLG);
  183. //HomeViewMgr.Instance.roomListDlg.SetActive(false);
  184. HomeMgr.Instance.ShowView(HomeMgr.CREATROOMDLG);
  185. if (CreateRoomDlg.Instance)
  186. {
  187. CreateRoomDlg.Instance.Init();
  188. }
  189. HomeMgr.Instance.roomListDlg.SetActive(false);
  190. }
  191. private void GotoAboutme()
  192. {
  193. //被zby替换的代码
  194. //HomeViewMgr.Instance.ShowView(HomeViewMgr.AboutMeDlg);
  195. //HomeViewMgr.Instance.roomListDlg.SetActive(false);
  196. HomeMgr.Instance.ShowView(HomeMgr.AboutMeDlg);
  197. HomeMgr.Instance.roomListDlg.SetActive(false);
  198. }
  199. protected override void OnDestroy()
  200. {
  201. base.OnDestroy();
  202. WSHandler.User.OnSearchRoom -= searchRoom;
  203. }
  204. }
  205. }