MainHomePanelCtrl.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using XGame.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. /// <summary>
  12. /// UI逻辑处理类
  13. /// </summary>
  14. /// <typeparam name=""></typeparam>
  15. public partial class MainHomePanelCtrl : UIController<MainHomePanelVM>
  16. {
  17. protected override void OnEnable(object intent)
  18. {
  19. AddUIListenres();
  20. RefreshPlayerInfo();
  21. }
  22. protected override void OnDisable()
  23. {
  24. RemoveUIListenres();
  25. }
  26. #region UI事件
  27. private void AddUIListenres()
  28. {
  29. VM.SysMenuBtn.onClick.Add(OnClickSysMenuBtn);
  30. VM.FriendBtn.onClick.Add(OnClickFriendBtn);
  31. VM.MailBtn.onClick.Add(OnClickMailBtn);
  32. VM.NoticeBtn.onClick.Add(OnClickNoticeBtn);
  33. VM.SettingBtn.onClick.Add(OnClickSettingBtn);
  34. VM.ExchangeBtn.onClick.Add(OnClickExchangeBtn);
  35. VM.BagBtn.onClick.Add(OnClickBagBtn);
  36. VM.MapRewardBtn.onClick.Add(OnClickMapRewardBtn);
  37. }
  38. private void RemoveUIListenres()
  39. {
  40. VM.SysMenuBtn.onClick.Remove(OnClickSysMenuBtn);
  41. VM.FriendBtn.onClick.Remove(OnClickFriendBtn);
  42. VM.MailBtn.onClick.Remove(OnClickMailBtn);
  43. VM.NoticeBtn.onClick.Remove(OnClickNoticeBtn);
  44. VM.SettingBtn.onClick.Remove(OnClickSettingBtn);
  45. VM.ExchangeBtn.onClick.Remove(OnClickExchangeBtn);
  46. VM.BagBtn.onClick.Remove(OnClickBagBtn);
  47. VM.MapRewardBtn.onClick.Remove(OnClickMapRewardBtn);
  48. }
  49. private void OnClickSysMenuBtn(EventContext context)
  50. {
  51. VM.SysMenuActive = !VM.SysMenuActive;
  52. }
  53. private void OnClickFriendBtn(EventContext context)
  54. {
  55. Context.ShowTips("OnClickFriendBtn");
  56. VM.SysMenuActive = false;
  57. }
  58. private void OnClickMailBtn(EventContext context)
  59. {
  60. Context.ShowTips("OnClickMailBtn");
  61. VM.SysMenuActive = false;
  62. }
  63. private void OnClickNoticeBtn(EventContext context)
  64. {
  65. Context.ShowTips("OnClickNoticeBtn");
  66. VM.SysMenuActive = false;
  67. // 临时测试GM消息按钮
  68. Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel);
  69. }
  70. private void OnClickSettingBtn(EventContext context)
  71. {
  72. Context.ShowTips("OnClickSettingBtn");
  73. VM.SysMenuActive = false;
  74. }
  75. private void OnClickExchangeBtn(EventContext context)
  76. {
  77. Context.ShowTips("OnClickExchangeBtn");
  78. VM.SysMenuActive = false;
  79. // 临时测试GM消息入口按钮
  80. Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel);
  81. }
  82. private void OnClickBagBtn(EventContext context)
  83. {
  84. Context.UI.OpenAsync(UIKeys.BagBackpackPanel);
  85. VM.SysMenuActive = false;
  86. }
  87. private void OnClickMapRewardBtn(EventContext context)
  88. {
  89. Context.ShowTips("OnClickMapRewardBtn");
  90. }
  91. #endregion
  92. void RefreshPlayerInfo()
  93. {
  94. //TODO
  95. var player = PlayerData.Instance;
  96. VM.PlayerHead.icon = "itemicon_99"; // player.HeadIcon;
  97. VM.PlayerNameTxt.text = player.Name;
  98. VM.PlayerLvTxt.text = player.Level.ToString();
  99. VM.PlayerPowerIcon.icon = AddressableDefine.itemicon_power;
  100. VM.PlayerPowerTxt.text = player.Power.FormatNumber();
  101. }
  102. }
  103. }