SuitPartsDetailView.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using UI.FieldGuide;
  2. using FairyGUI;
  3. namespace GFGGame
  4. {
  5. public class SuitPartsDetailView : BaseWindow
  6. {
  7. private UI_SuitPartsDetailUI _ui;
  8. private int[] _items;
  9. public override void Dispose()
  10. {
  11. base.Dispose();
  12. _items = null;
  13. }
  14. protected override void OnInit()
  15. {
  16. base.OnInit();
  17. _ui = UI_SuitPartsDetailUI.Create();
  18. this.viewCom = _ui.target;
  19. this.modal = true;
  20. this.viewCom.Center();
  21. _ui.m_listParts.itemRenderer = ListPartsItemRenderer;
  22. _ui.m_listParts.onClickItem.Add(OnClickListPartsItem);
  23. }
  24. protected override void OnShown()
  25. {
  26. base.OnShown();
  27. int suitId = (int)this.viewData;
  28. _items = SuitCfgManager.Instance.GetSuitItems(suitId);
  29. _ui.m_listParts.numItems = _items.Length;
  30. _ui.m_listParts.ResizeToFit();
  31. _ui.target.Center();
  32. }
  33. protected override void OnHide()
  34. {
  35. base.OnHide();
  36. }
  37. private void ListPartsItemRenderer(int index, GObject item)
  38. {
  39. UI_ListSuitPartsItem listItem = UI_ListSuitPartsItem.Proxy(item);
  40. int itemId = _items[index];
  41. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemId);
  42. listItem.m_txtName.text = ItemUtil.GetItemName(itemId);
  43. listItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  44. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  45. listItem.m_imgLock.visible = listItem.m_imgLockBg.visible = !haveItem;
  46. listItem.target.data = itemId;
  47. // listItem.target.onClick.Clear();
  48. // listItem.target.onClick.Add(() =>
  49. // {
  50. // if (haveItem)
  51. // {
  52. // GoodsItemTipsController.ShowItemTips(itemId);
  53. // }
  54. // });
  55. }
  56. private void OnClickListPartsItem(EventContext context)
  57. {
  58. GComponent item = context.data as GComponent;
  59. int itemId = (int)item.data;
  60. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  61. if (haveItem)
  62. {
  63. GoodsItemTipsController.ShowItemTips(itemId);
  64. }
  65. else
  66. {
  67. this.Hide();
  68. ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { itemId, new object[] { ViewName.SUIT_GUIDE_VIEW, this.viewData } });
  69. }
  70. }
  71. }
  72. }