StoreExchangeView.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 StoreExchangeView : BaseWindow
  9. {
  10. private UI_StoreExchangeUI _ui;
  11. private ValueBarController _valueBarController;
  12. private List<ShopCfg> _shopCfgs;
  13. public override void Dispose()
  14. {
  15. if (_valueBarController != null)
  16. {
  17. _valueBarController.Dispose();
  18. _valueBarController = null;
  19. }
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. }
  24. _ui = null;
  25. base.Dispose();
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. packageName = UI_StoreExchangeUI.PACKAGE_NAME;
  31. _ui = UI_StoreExchangeUI.Create();
  32. this.viewCom = _ui.target;
  33. isfullScreen = true;
  34. this.clickBlankToClose = false;
  35. _ui.m_list.itemRenderer = ListItemRenderer;
  36. _valueBarController = new ValueBarController(_ui.m_valueBar);
  37. }
  38. protected override void AddEventListener()
  39. {
  40. base.AddEventListener();
  41. EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. int menu2 = (int)this.viewData;
  47. _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_EXCHANGE, menu2);
  48. _shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
  49. _valueBarController.OnShown();
  50. _valueBarController.UpdateList(ShopDataManager.Instance.GetShopCostIds(_shopCfgs));
  51. UpdateView();
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. _valueBarController.OnHide();
  57. }
  58. protected override void RemoveEventListener()
  59. {
  60. base.RemoveEventListener();
  61. EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView);
  62. }
  63. private void UpdateView()
  64. {
  65. _shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
  66. _ui.m_list.numItems = _shopCfgs.Count;
  67. }
  68. private void ListItemRenderer(int index, GObject obj)
  69. {
  70. ShopCfg shopCfg = _shopCfgs[index];
  71. ShopViewManager.Instance.UptadeItem(obj, shopCfg);
  72. }
  73. }
  74. }