ItemInformationPanelCtrl.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data.Items;
  8. using XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class ItemInformationPanelCtrl : UIController<ItemInformationPanelVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. if (intent != null)
  22. {
  23. ShowUI(intent as IItemBase);
  24. }
  25. }
  26. protected override void OnDisable()
  27. {
  28. RemoveUIListenres();
  29. }
  30. #region UI事件
  31. private void AddUIListenres()
  32. {
  33. VM.SureBtn.onClick.Add(OnClickSureBtn);
  34. }
  35. private void RemoveUIListenres()
  36. {
  37. VM.SureBtn.onClick.Remove(OnClickSureBtn);
  38. }
  39. private void OnClickSureBtn(EventContext context)
  40. {
  41. Context.ClosePanel();
  42. }
  43. #endregion
  44. private void ShowUI(IItemBase data)
  45. {
  46. var table = ItemTableRepo.Get(data.TableId);
  47. VM.NameLabel.text = table.Name;
  48. VM.DescLabel.text = table.Desc;
  49. if (data is ItemBase itemBase)
  50. {
  51. VM.NumLabel.visible = true;
  52. VM.NumLabel.text = itemBase.Count.ToString();
  53. }
  54. else
  55. {
  56. VM.NumLabel.visible = false;
  57. }
  58. VM.QualityIcon.icon = AddressableDefine.ItemFrame(table.Quality);
  59. VM.ItemIcon.icon = table.Icon;
  60. }
  61. }
  62. }