ClothingListView.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.ClothingFoster;
  5. namespace GFGGame
  6. {
  7. public class ClothingListView : BaseWindow
  8. {
  9. private UI_ClothingListUI _ui;
  10. // private ValueBarController _valueBarController;
  11. private int _menuType = ConstSuitGuideTypeId.TYPE_1;
  12. private int[] _menuTypeDataArray;
  13. private List<int> _suitIds;
  14. public override void Dispose()
  15. {
  16. // if (_valueBarController != null)
  17. // {
  18. // _valueBarController.Dispose();
  19. // _valueBarController = null;
  20. // }
  21. if (_ui != null)
  22. {
  23. _ui.Dispose();
  24. _ui = null;
  25. }
  26. base.Dispose();
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. packageName = UI_ClothingListUI.PACKAGE_NAME;
  32. _ui = UI_ClothingListUI.Create();
  33. this.viewCom = _ui.target;
  34. isfullScreen = true;
  35. isReturnView = true;
  36. // _valueBarController = new ValueBarController(_ui.m_valueBar);
  37. _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
  38. _ui.m_comBoxSort.items = new string[] { "默认排序", "稀有度高", "稀有度低", "收集度高", "收集度低" };
  39. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  40. _ui.m_comBoxSort.onChanged.Add(OnComboBoxSortChanged);
  41. _ui.m_btnHaveGot.onChanged.Add(OnClickBtnHaveGot);
  42. _ui.m_btnNotGet.onChanged.Add(OnClickBtnNotGet);
  43. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("xc_bjbj");
  44. }
  45. protected override void AddEventListener()
  46. {
  47. base.AddEventListener();
  48. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  49. }
  50. protected override void OnShown()
  51. {
  52. base.OnShown();
  53. // _valueBarController.OnShown();
  54. _ui.m_btnHaveGot.selected = true;
  55. _ui.m_btnNotGet.selected = true;
  56. SuitFosterProxy.SendGetSuitInfos().Coroutine();
  57. UpdateListSuit();
  58. Timers.inst.AddUpdate(CheckGuide);
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. // _valueBarController.OnHide();
  64. Timers.inst.Remove(CheckGuide);
  65. }
  66. protected override void RemoveEventListener()
  67. {
  68. base.RemoveEventListener();
  69. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  70. }
  71. private void OnClickBtnBack()
  72. {
  73. // this.Hide();
  74. ViewManager.GoBackFrom(typeof(ClothingListView).FullName);
  75. }
  76. private void OnClickListTypeItem()
  77. {
  78. UpdateListSuit();
  79. }
  80. private void OnComboBoxSortChanged()
  81. {
  82. UpdateListSuit();
  83. }
  84. private void OnClickBtnSwitch()
  85. {
  86. _menuType = 3 - _menuType;
  87. }
  88. private void OnClickBtnHaveGot()
  89. {
  90. if (!_ui.m_btnHaveGot.selected)
  91. {
  92. _ui.m_btnNotGet.selected = true;
  93. }
  94. UpdateListSuit();
  95. }
  96. private void OnClickBtnNotGet()
  97. {
  98. if (!_ui.m_btnNotGet.selected)
  99. {
  100. _ui.m_btnHaveGot.selected = true;
  101. }
  102. UpdateListSuit();
  103. }
  104. private void UpdateListSuit()
  105. {
  106. _ui.m_listSuit.RemoveChildrenToPool();
  107. _suitIds = SuitUtil.GetClothingFosterSuitIdList(_ui.m_btnNotGet.selected, _ui.m_btnHaveGot.selected, _ui.m_comBoxSort.selectedIndex);
  108. _ui.m_listSuit.numItems = _suitIds.Count;
  109. _ui.m_listSuit.scrollPane.ScrollTop();
  110. }
  111. private void ListSuitItemRenderer(int index, GObject item)
  112. {
  113. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(item);
  114. int suitId = _suitIds[index];
  115. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  116. listItem.m_txtName.text = suitCfg.name;
  117. listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  118. RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
  119. listItem.target.data = suitId;
  120. UpdateSuitStatusView(listItem);
  121. UI_ListSuitItem.ProxyEnd();
  122. }
  123. private void UpdateSuitStatus(EventContext eventContext)
  124. {
  125. int num = _ui.m_listSuit.numChildren;
  126. for (int i = 0; i < num; i++)
  127. {
  128. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  129. UpdateSuitStatusView(listItem);
  130. UI_ListSuitItem.ProxyEnd();
  131. }
  132. }
  133. private void UpdateSuitStatusView(UI_ListSuitItem listItem)
  134. {
  135. int suitId = (int)listItem.target.data;
  136. int count = 0;
  137. int totalCount = 0;
  138. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  139. listItem.m_progBar.max = totalCount;
  140. listItem.m_progBar.value = count;
  141. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  142. listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveSuit;
  143. listItem.m_bg.onClick.Clear();
  144. listItem.m_bg.onClick.Add(() =>
  145. {
  146. if (haveSuit)
  147. {
  148. ViewManager.Show<ClothingView>(new object[] { suitId, _suitIds });
  149. }
  150. else
  151. {
  152. ViewManager.Show<SuitPartsDetailView>(suitId);
  153. }
  154. });
  155. RedDotController.Instance.SetComRedDot(listItem.target, RedDotDataManager.Instance.GetClothingFosterRed(suitId) || RedDotDataManager.Instance.GetClothingRenewRed(suitId), "", 8, -3);
  156. }
  157. private void CheckGuide(object param)
  158. {
  159. if (GuideDataManager.IsGuideFinish(ConstGuideId.SUIT_LIST_VIEW) <= 0)
  160. {
  161. UpdateToCheckGuide(null);
  162. }
  163. else
  164. {
  165. Timers.inst.Remove(CheckGuide);
  166. }
  167. }
  168. protected override void UpdateToCheckGuide(object param)
  169. {
  170. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  171. int index = 0;
  172. for (int i = 0; i < _suitIds.Count; i++)
  173. {
  174. int suitId = _suitIds[i];
  175. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  176. if (haveSuit == true)
  177. {
  178. index = i;
  179. break;
  180. }
  181. }
  182. GuideController.TryGuide(_ui.m_listSuit, ConstGuideId.SUIT_LIST_VIEW, 3, "选择套装。", index);
  183. }
  184. }
  185. }