MainHomePanelCtrl.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. MailService.Instance.RequestMailInto();
  63. }
  64. private void OnClickNoticeBtn(EventContext context)
  65. {
  66. Context.ShowTips("OnClickNoticeBtn");
  67. VM.SysMenuActive = false;
  68. // 临时测试GM消息按钮
  69. Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel);
  70. }
  71. private void OnClickSettingBtn(EventContext context)
  72. {
  73. Context.ShowTips("OnClickSettingBtn");
  74. VM.SysMenuActive = false;
  75. }
  76. private void OnClickExchangeBtn(EventContext context)
  77. {
  78. Context.ShowTips("OnClickExchangeBtn");
  79. VM.SysMenuActive = false;
  80. // 临时测试GM消息入口按钮
  81. Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel);
  82. }
  83. private void OnClickBagBtn(EventContext context)
  84. {
  85. Context.UI.OpenAsync(UIKeys.BagBackpackPanel);
  86. VM.SysMenuActive = false;
  87. }
  88. private void OnClickMapRewardBtn(EventContext context)
  89. {
  90. Context.ShowTips("OnClickMapRewardBtn");
  91. }
  92. #endregion
  93. void RefreshPlayerInfo()
  94. {
  95. //TODO
  96. var player = PlayerData.Instance;
  97. VM.PlayerHead.icon = "itemicon_99"; // player.HeadIcon;
  98. VM.PlayerNameTxt.text = player.Name;
  99. VM.PlayerLvTxt.text = player.Level.ToString();
  100. VM.PlayerPowerIcon.icon = AddressableDefine.itemicon_power;
  101. VM.PlayerPowerTxt.text = player.Power.FormatNumber();
  102. }
  103. }
  104. }