SuitPartsDetailView.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. packageName = UI_SuitGuideUI.PACKAGE_NAME;
  18. _ui = UI_SuitPartsDetailUI.Create();
  19. this.viewCom = _ui.target;
  20. this.modal = true;
  21. this.viewCom.Center();
  22. _ui.m_listParts.itemRenderer = ListPartsItemRenderer;
  23. // _ui.m_listParts.onClickItem.Add(OnClickListPartsItem);
  24. }
  25. protected override void OnShown()
  26. {
  27. base.OnShown();
  28. int suitId = (int)this.viewData;
  29. _items = SuitCfgManager.Instance.GetSuitItems(suitId);
  30. _ui.m_listParts.numItems = _items.Length;
  31. _ui.m_listParts.ResizeToFit();
  32. _ui.target.Center();
  33. }
  34. protected override void OnHide()
  35. {
  36. base.OnHide();
  37. }
  38. private void ListPartsItemRenderer(int index, GObject obj)
  39. {
  40. int itemId = _items[index];
  41. ItemData reward = ItemUtil.createItemData(itemId, 1);
  42. if (obj.data == null)
  43. {
  44. obj.data = new ItemView(obj as GComponent);
  45. }
  46. (obj.data as ItemView).SetData(reward);
  47. (obj.data as ItemView).TxtHasCountVisble = false;
  48. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  49. (obj.data as ItemView).ImgNotGotVisible = !haveItem;
  50. }
  51. private void OnClickListPartsItem(EventContext context)
  52. {
  53. GComponent item = context.data as GComponent;
  54. int itemId = (int)item.data;
  55. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  56. if (haveItem)
  57. {
  58. GoodsItemTipsController.ShowItemTips(itemId);
  59. }
  60. else
  61. {
  62. this.Hide();
  63. ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { itemId, new object[] { ViewName.SUIT_GUIDE_VIEW, this.viewData } });
  64. }
  65. }
  66. }
  67. }