123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /// #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
- {
- /// <summary>
- /// 今日不再提醒key
- /// </summary>
- public enum EDayTipsKey : uint
- {
- SellEquip = 1, // 出售比穿戴装备高战力
- }
- public class ConfirmationBoxParam
- {
- public string cnt;
- public EDayTipsKey tipsKey;
- public Action onPromiseCallback; // 确定按钮回调函数
- public Action onCancelCallback;
- }
- /// <summary>
- /// UI逻辑处理类
- /// </summary>
- /// <typeparam name=""></typeparam>
- public partial class CommonConfirmationBoxCtrl : UIController<CommonConfirmationBoxVM>
- {
- 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;
- }
- }
- }
|