StoreGiftBagView.cs 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class StoreGiftBagView : BaseWindow
  9. {
  10. private UI_StoreGiftBagUI _ui;
  11. private ValueBarController _valueBarController;
  12. private List<ShopCfg> _shopCfgs;
  13. private int menu2;
  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. }
  25. _ui = null;
  26. base.Dispose();
  27. }
  28. protected override void OnInit()
  29. {
  30. base.OnInit();
  31. packageName = UI_StoreGiftBagUI.PACKAGE_NAME;
  32. _ui = UI_StoreGiftBagUI.Create();
  33. this.viewCom = _ui.target;
  34. isfullScreen = true;
  35. this.clickBlankToClose = false;
  36. this.bringToFontOnClick = false;
  37. _ui.m_storeGiftBagList.m_list.itemRenderer = ListItemRenderer;
  38. _valueBarController = new ValueBarController(_ui.m_valueBar);
  39. }
  40. protected override void AddEventListener()
  41. {
  42. base.AddEventListener();
  43. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  44. }
  45. protected override void OnShown()
  46. {
  47. base.OnShown();
  48. menu2 = (int)this.viewData;
  49. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_GIFT_BAG, menu2);
  50. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  51. _valueBarController.OnShown();
  52. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  53. _ui.m_storeGiftBagList.m_list.scrollPane.ScrollTop();
  54. UpdateView();
  55. }
  56. protected override void OnHide()
  57. {
  58. base.OnHide();
  59. ShopViewManager.Instance.ClearItemEff();
  60. _valueBarController.OnHide();
  61. }
  62. protected override void RemoveEventListener()
  63. {
  64. base.RemoveEventListener();
  65. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  66. }
  67. private void UpdateView()
  68. {
  69. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  70. ShopViewManager.Instance.ClearItemEff();
  71. _ui.m_storeGiftBagList.m_list.numItems = _shopCfgs.Count;
  72. }
  73. private void ListItemRenderer(int index, GObject obj)
  74. {
  75. ShopCfg shopCfg = _shopCfgs[index];
  76. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  77. RedDotController.Instance.SetComRedDot(obj.asCom, menu2 == ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY && shopCfg.Price == 0 && ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.maxBuyNum, "", 5, 76);
  78. }
  79. }
  80. }