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 XGame.Database;
  8. using XGame.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. public class ItemInfoParam
  12. {
  13. public ItemTable itemInfo;
  14. public string numDesc;
  15. }
  16. /// <summary>
  17. /// UI逻辑处理类
  18. /// </summary>
  19. /// <typeparam name=""></typeparam>
  20. public partial class ItemInformationPanelCtrl : UIController<ItemInformationPanelVM>
  21. {
  22. protected override void OnEnable(object intent)
  23. {
  24. AddUIListenres();
  25. var data = intent as ItemInfoParam;
  26. if (data != null)
  27. {
  28. ShowUI(data);
  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. }