StoreGiftBagView.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using UI.Store;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using cfg.GfgCfg;
  7. using ET;
  8. namespace GFGGame
  9. {
  10. public class StoreGiftBagView : BaseWindow
  11. {
  12. private UI_StoreGiftBagUI _ui;
  13. private ValueBarController _valueBarController;
  14. private List<ShopCfg> _shopCfgs;
  15. private int menu2;
  16. public override void Dispose()
  17. {
  18. if (_valueBarController != null)
  19. {
  20. _valueBarController.Dispose();
  21. _valueBarController = null;
  22. }
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. }
  27. _ui = null;
  28. base.Dispose();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_StoreGiftBagUI.PACKAGE_NAME;
  34. _ui = UI_StoreGiftBagUI.Create();
  35. this.viewCom = _ui.target;
  36. isfullScreen = true;
  37. this.clickBlankToClose = false;
  38. this.bringToFontOnClick = false;
  39. _ui.m_storeGiftBagList.m_list.itemRenderer = ListItemRenderer;
  40. _valueBarController = new ValueBarController(_ui.m_valueBar);
  41. }
  42. protected override void AddEventListener()
  43. {
  44. base.AddEventListener();
  45. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  46. }
  47. protected override void OnShown()
  48. {
  49. base.OnShown();
  50. menu2 = (int)this.viewData;
  51. _shopCfgs = CommonDataManager.Tables.TblShopCfg.DataList
  52. .Where(a => a.Menu1 == ConstStoreTabId.STORE_GIFT_BAG && a.Menu2 == menu2).ToList();
  53. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  54. _valueBarController.OnShown();
  55. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  56. _ui.m_storeGiftBagList.m_list.scrollPane.ScrollTop();
  57. UpdateView();
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. ShopViewManager.Instance.ClearItemEff();
  63. _valueBarController.OnHide();
  64. }
  65. protected override void RemoveEventListener()
  66. {
  67. base.RemoveEventListener();
  68. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  69. }
  70. private void UpdateView()
  71. {
  72. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  73. ShopViewManager.Instance.ClearItemEff();
  74. _ui.m_storeGiftBagList.m_list.numItems = _shopCfgs.Count;
  75. }
  76. private void ListItemRenderer(int index, GObject obj)
  77. {
  78. ShopCfg shopCfg = _shopCfgs[index];
  79. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  80. RedDotController.Instance.SetComRedDot(obj.asCom,
  81. menu2 == ConstStoreSubId.STORE_GIFT_BAG_ACTIVITY && shopCfg.Price == 0 &&
  82. ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.Id) < shopCfg.MaxBuyNum, "", 5, 76);
  83. }
  84. }
  85. }