CreateSearchRoomDlg.cs 7.3 KB

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