SuitPartsDetailView.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using UI.CommonGame;
  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_SuitPartsDetailUI.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.ScrollToView(0);
  32. // _ui.m_listParts.ResizeToFit();
  33. _ui.target.Center();
  34. }
  35. protected override void OnHide()
  36. {
  37. base.OnHide();
  38. }
  39. private void ListPartsItemRenderer(int index, GObject obj)
  40. {
  41. int itemId = _items[index];
  42. ItemData reward = ItemUtil.createItemData(itemId, 1);
  43. if (obj.data == null)
  44. {
  45. obj.data = new ItemView(obj as GComponent);
  46. }
  47. (obj.data as ItemView).SetData(reward);
  48. (obj.data as ItemView).TxtHasCountVisble = false;
  49. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  50. (obj.data as ItemView).ImgNotGotVisible = !haveItem;
  51. }
  52. private void OnClickListPartsItem(EventContext context)
  53. {
  54. GComponent item = context.data as GComponent;
  55. int itemId = (int)item.data;
  56. bool haveItem = DressUpMenuItemDataManager.CheckHasItem(itemId);
  57. if (haveItem)
  58. {
  59. GoodsItemTipsController.ShowItemTips(itemId);
  60. }
  61. else
  62. {
  63. this.Hide();
  64. ViewManager.Show(ViewName.APPROACH_OF_ITEM_VIEW, new object[] { itemId, new object[] { ViewName.SUIT_GUIDE_VIEW, this.viewData } });
  65. }
  66. }
  67. }
  68. }