ItemInformationPanelCtrl.cs 1.7 KB

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