SuitListView.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System.Collections.Generic;
  2. using FairyGUI;
  3. using UI.ClothingFoster;
  4. namespace GFGGame
  5. {
  6. public class SuitListView : BaseWindow
  7. {
  8. private UI_SuitListUI _ui;
  9. private ValueBarController _valueBarController;
  10. private int _menuType = ConstSuitGuideTypeId.TYPE_1;
  11. private int[] _menuTypeDataArray;
  12. private List<int> _suitIds;
  13. public override void Dispose()
  14. {
  15. base.Dispose();
  16. }
  17. protected override void OnInit()
  18. {
  19. base.OnInit();
  20. packageName = UI_SuitListUI.PACKAGE_NAME;
  21. _ui = UI_SuitListUI.Create();
  22. this.viewCom = _ui.target;
  23. this.viewCom.Center();
  24. isfullScreen = true;
  25. // this.modal = true;
  26. // viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  27. _valueBarController = new ValueBarController(_ui.m_valueBar);
  28. _ui.m_listSuit.itemRenderer = ListSuitItemRenderer;
  29. _ui.m_comBoxSort.items = new string[] { "默认排序", "稀有度高", "稀有度低", "收集度高", "收集度低" };
  30. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  31. _ui.m_comBoxSort.onChanged.Add(OnComboBoxSortChanged);
  32. _ui.m_btnHaveGot.onChanged.Add(OnClickBtnHaveGot);
  33. _ui.m_btnNotGet.onChanged.Add(OnClickBtnNotGet);
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. _valueBarController.OnShown();
  39. _ui.m_btnHaveGot.selected = true;
  40. _ui.m_btnNotGet.selected = true;
  41. UpdateListSuit();
  42. EventAgent.AddEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  43. }
  44. protected override void OnHide()
  45. {
  46. base.OnHide();
  47. _valueBarController.OnHide();
  48. EventAgent.RemoveEventListener(ConstMessage.ITEM_CHANGED, UpdateSuitStatus);
  49. }
  50. private void OnClickBtnBack()
  51. {
  52. // this.Hide();
  53. ViewManager.GoBackFrom(typeof(SuitListView).FullName);
  54. }
  55. private void OnClickListTypeItem()
  56. {
  57. UpdateListSuit();
  58. }
  59. private void OnComboBoxSortChanged()
  60. {
  61. UpdateListSuit();
  62. }
  63. private void OnClickBtnSwitch()
  64. {
  65. _menuType = 3 - _menuType;
  66. }
  67. private void OnClickBtnHaveGot()
  68. {
  69. if (!_ui.m_btnHaveGot.selected)
  70. {
  71. _ui.m_btnNotGet.selected = true;
  72. }
  73. UpdateListSuit();
  74. }
  75. private void OnClickBtnNotGet()
  76. {
  77. if (!_ui.m_btnNotGet.selected)
  78. {
  79. _ui.m_btnHaveGot.selected = true;
  80. }
  81. UpdateListSuit();
  82. }
  83. private void UpdateListSuit()
  84. {
  85. _ui.m_listSuit.RemoveChildrenToPool();
  86. _suitIds = SuitUtil.GetClothingFosterSuitIdList(_ui.m_btnNotGet.selected, _ui.m_btnHaveGot.selected, _ui.m_comBoxSort.selectedIndex);
  87. _ui.m_listSuit.numItems = _suitIds.Count;
  88. _ui.m_listSuit.scrollPane.ScrollTop();
  89. }
  90. private void ListSuitItemRenderer(int index, GObject item)
  91. {
  92. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(item);
  93. int suitId = _suitIds[index];
  94. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitId);
  95. listItem.m_txtName.text = suitCfg.name;
  96. listItem.m_loaderPic.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  97. RarityIconController.UpdateRarityIcon(listItem.m_rarity, suitId, false, true);
  98. listItem.target.data = suitId;
  99. UpdateSuitStatusView(listItem);
  100. }
  101. private void UpdateSuitStatus(EventContext eventContext)
  102. {
  103. int num = _ui.m_listSuit.numChildren;
  104. for (int i = 0; i < num; i++)
  105. {
  106. UI_ListSuitItem listItem = UI_ListSuitItem.Proxy(_ui.m_listSuit.GetChildAt(i));
  107. UpdateSuitStatusView(listItem);
  108. }
  109. }
  110. private void UpdateSuitStatusView(UI_ListSuitItem listItem)
  111. {
  112. int suitId = (int)listItem.target.data;
  113. int count = 0;
  114. int totalCount = 0;
  115. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitId, out count, out totalCount);
  116. listItem.m_progBar.max = totalCount;
  117. listItem.m_progBar.value = count;
  118. bool haveSuit = DressUpMenuSuitDataManager.CheckHaveSuit(suitId);
  119. listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveSuit;
  120. listItem.m_bg.onClick.Clear();
  121. listItem.m_bg.onClick.Add(() =>
  122. {
  123. if (haveSuit)
  124. {
  125. ViewManager.Show<SuitView>(new object[] { suitId, _suitIds }, new object[] { typeof(SuitListView).Name, this.viewData });
  126. }
  127. else
  128. {
  129. ViewManager.Show(ViewName.SUIT_PARTS_DETAIL_VIEW, suitId, new object[] { ViewName.SUIT_PARTS_DETAIL_VIEW, this.viewData });
  130. }
  131. });
  132. }
  133. }
  134. }