/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data; using XGame.Framework.UI; namespace FL.FGUI { /// /// UI逻辑处理类 /// /// public partial class MainHomePanelCtrl : UIController { protected override void OnEnable(object intent) { AddUIListenres(); RefreshPlayerInfo(); } protected override void OnDisable() { RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { VM.SysMenuBtn.onClick.Add(OnClickSysMenuBtn); VM.FriendBtn.onClick.Add(OnClickFriendBtn); VM.MailBtn.onClick.Add(OnClickMailBtn); VM.NoticeBtn.onClick.Add(OnClickNoticeBtn); VM.SettingBtn.onClick.Add(OnClickSettingBtn); VM.ExchangeBtn.onClick.Add(OnClickExchangeBtn); VM.BagBtn.onClick.Add(OnClickBagBtn); VM.MapRewardBtn.onClick.Add(OnClickMapRewardBtn); } private void RemoveUIListenres() { VM.SysMenuBtn.onClick.Remove(OnClickSysMenuBtn); VM.FriendBtn.onClick.Remove(OnClickFriendBtn); VM.MailBtn.onClick.Remove(OnClickMailBtn); VM.NoticeBtn.onClick.Remove(OnClickNoticeBtn); VM.SettingBtn.onClick.Remove(OnClickSettingBtn); VM.ExchangeBtn.onClick.Remove(OnClickExchangeBtn); VM.BagBtn.onClick.Remove(OnClickBagBtn); VM.MapRewardBtn.onClick.Remove(OnClickMapRewardBtn); } private void OnClickSysMenuBtn(EventContext context) { VM.SysMenuActive = !VM.SysMenuActive; } private void OnClickFriendBtn(EventContext context) { Context.ShowTips("OnClickFriendBtn"); VM.SysMenuActive = false; } private void OnClickMailBtn(EventContext context) { Context.ShowTips("OnClickMailBtn"); VM.SysMenuActive = false; } private void OnClickNoticeBtn(EventContext context) { Context.ShowTips("OnClickNoticeBtn"); VM.SysMenuActive = false; // 临时测试GM消息按钮 Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel); } private void OnClickSettingBtn(EventContext context) { Context.ShowTips("OnClickSettingBtn"); VM.SysMenuActive = false; } private void OnClickExchangeBtn(EventContext context) { Context.ShowTips("OnClickExchangeBtn"); VM.SysMenuActive = false; // 临时测试GM消息入口按钮 Context.UI.OpenAsync(UIKeys.GmToolSendMsgPanel); } private void OnClickBagBtn(EventContext context) { Context.UI.OpenAsync(UIKeys.BagBackpackPanel); VM.SysMenuActive = false; } private void OnClickMapRewardBtn(EventContext context) { Context.ShowTips("OnClickMapRewardBtn"); } #endregion void RefreshPlayerInfo() { //TODO var player = PlayerData.Instance; VM.PlayerHead.icon = "itemicon_99"; // player.HeadIcon; VM.PlayerNameTxt.text = player.Name; VM.PlayerLvTxt.text = player.Level.ToString(); VM.PlayerPowerIcon.icon = AddressableDefine.itemicon_power; VM.PlayerPowerTxt.text = player.Power.FormatNumber(); } } }