/// #pkgName FGUI包名 /// #panelName UIPanel名字 /// #UIName = $"{#pkgName}{#panelName}" UIKey名字 /// 该脚本由模板创建 /// created by cb 2024 using FairyGUI; using FL.Data; using System; using XGame.Framework.UI; namespace FL.FGUI { /// /// 今日不再提醒key /// public enum EDayTipsKey : uint { SellEquip = 1, // 出售比穿戴装备高战力 } public class ConfirmationBoxParam { public string cnt; public EDayTipsKey tipsKey; public Action onPromiseCallback; // 确定按钮回调函数 public Action onCancelCallback; } /// /// UI逻辑处理类 /// /// public partial class CommonConfirmationBoxCtrl : UIController { private ConfirmationBoxParam _data; protected override void OnEnable(object intent) { AddUIListenres(); _data = intent as ConfirmationBoxParam; ShowUI(); } protected override void OnDisable() { _data = null; RemoveUIListenres(); } #region UI事件 private void AddUIListenres() { VM.CancelBtn.onClick.Add(OnClickCancelBtn); VM.SureBtn.onClick.Add(OnClickSureBtn); VM.ToggleBtn.onClick.Add(OnClickToggleBtn); } private void RemoveUIListenres() { VM.CancelBtn.onClick.Remove(OnClickCancelBtn); VM.SureBtn.onClick.Remove(OnClickSureBtn); VM.ToggleBtn.onClick.Remove(OnClickToggleBtn); } private void OnClickCancelBtn(EventContext context) { if (_data?.onCancelCallback != null) { _data.onCancelCallback(); } Context.ClosePanel(); } private void OnClickSureBtn(EventContext context) { if (_data?.onPromiseCallback != null) { _data.onPromiseCallback(); } Context.ClosePanel(); } private void OnClickToggleBtn(EventContext context) { // 测试出售高战力装备不再提示 if (_data?.tipsKey > 0 && _data.tipsKey == EDayTipsKey.SellEquip) { DragonEggData.Instance.CheckDayTipsKey = VM.ToggleBtn.selected; } } #endregion private void ShowUI() { if (_data?.cnt != null) { VM.CntLabel.text = _data.cnt; } VM.ShowToggleUI.selectedIndex = _data?.tipsKey > 0 ? 1 : 0; } } }