StoreGiftBagView.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. _ui.m_list.itemRenderer = ListItemRenderer;
  37. _valueBarController = new ValueBarController(_ui.m_valueBar);
  38. }
  39. protected override void AddEventListener()
  40. {
  41. base.AddEventListener();
  42. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. menu2 = (int)this.viewData;
  48. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_GIFT_BAG, menu2);
  49. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  50. _valueBarController.OnShown();
  51. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  52. UpdateView();
  53. }
  54. protected override void OnHide()
  55. {
  56. base.OnHide();
  57. _valueBarController.OnHide();
  58. }
  59. protected override void RemoveEventListener()
  60. {
  61. base.RemoveEventListener();
  62. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  63. }
  64. private void UpdateView()
  65. {
  66. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  67. _ui.m_list.numItems = _shopCfgs.Count;
  68. }
  69. private void ListItemRenderer(int index, GObject obj)
  70. {
  71. ShopCfg shopCfg = _shopCfgs[index];
  72. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  73. RedDotController.Instance.SetComRedDot(obj.asCom, menu2 == ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY && shopCfg.price == 0 && ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.maxBuyNum, "", 0, 70);
  74. }
  75. }
  76. }