SuitPartsDetailView.cs 2.4 KB

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