ClothingListView.cs 6.8 KB

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