BagSourceOfPropsPanelCtrl.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using Codice.CM.Common;
  7. using FairyGUI;
  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 BagSourceOfPropsPanelCtrl : UIController<BagSourceOfPropsPanelVM>
  17. {
  18. private ItemTable _itemInfo;
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. if (intent != null)
  23. {
  24. ShowUI((ItemInfoParam)intent);
  25. }
  26. }
  27. protected override void OnDisable()
  28. {
  29. RemoveUIListenres();
  30. }
  31. #region UI事件
  32. private void AddUIListenres()
  33. {
  34. VM.UseBtn.onClick.Add(OnClickUseBtn);
  35. }
  36. private void RemoveUIListenres()
  37. {
  38. VM.UseBtn.onClick.Remove(OnClickUseBtn);
  39. }
  40. private void OnClickUseBtn(EventContext context)
  41. {
  42. Context.UI.OpenAsync(UIKeys.BagUsePanel,_itemInfo);
  43. Context.ClosePanel();
  44. }
  45. #endregion
  46. private void ShowUI(ItemInfoParam data)
  47. {
  48. if (data.itemInfo != null)
  49. {
  50. _itemInfo = data.itemInfo;
  51. VM.NameLabel.text = _itemInfo.Name;
  52. VM.DescLabel.text = _itemInfo.Desc;
  53. bool bShowNum = data.numDesc != null;
  54. VM.CountLabel.visible = bShowNum;
  55. if (bShowNum) VM.CountLabel.text = data.numDesc;
  56. VM.QualityIcon.icon = AddressableDefine.ItemFrame(_itemInfo.Quality);
  57. VM.ItemIcon.icon = _itemInfo.Icon;
  58. VM.UseBtn.visible = _itemInfo.Type == (int)EItemType.Gift || _itemInfo.Type == (int)EItemType.RedEnvelope;
  59. bool bHideJumpUI = _itemInfo.Jump?.Length == 0;
  60. VM.JumpUICtrl.selectedIndex = bHideJumpUI ? 1 : 0;
  61. if (!bHideJumpUI)
  62. {
  63. ShowJumpUI(_itemInfo.Jump);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 显示来源跳转UI
  69. /// </summary>
  70. private void ShowJumpUI(int[] jumpIds)
  71. {
  72. VM.JumpList.BindDatas(jumpIds);
  73. }
  74. }
  75. }