/// #pkgName FGUI包名
/// #panelName UIPanel名字
/// #UIName = $"{#pkgName}{#panelName}" UIKey名字
/// 该脚本由模板创建
/// created by cb 2024

using FairyGUI;
using XGame.Framework.UI.View;

namespace FL.FGUI
{
    /// <summary>
    /// UI逻辑处理类
    /// </summary>
    /// <typeparam name=""></typeparam>
    public partial class MainHomePanelCtrl : UIControllerBase<MainHomePanelVM>
    {
        public override void OnEnable(object intent)
        {
            AddUIListenres();
            VM.BoxSpine.url = "box_skeletondata";
            VM.BoxSpine.animationName = "box_idle";
            VM.BoxSpine.loop = true;
        }
        public override void OnDisable()
        {
            RemoveUIListenres();
        }
        #region UI事件
        private void AddUIListenres()
        {
            VM.GoldBtn.onClick.Add(OnClickGoldBtn);
            VM.DiamondBtn.onClick.Add(OnClickDiamondBtn);
            VM.SCBtn.onClick.Add(OnClickSCBtn);
            VM.XSLBtn.onClick.Add(OnClickXSLBtn);
            VM.HDBtn.onClick.Add(OnClickHDBtn);
            VM.GoldBox.onClick.Add(OnClickGoldBox);
            VM.MailBtn.onClick.Add(OnClickMailBtn);
            VM.FriendsBtn.onClick.Add(OnClickFriendsBtn);
            VM.RankBtn.onClick.Add(OnClickRankBtn);
            VM.BoxBtn.onClick.Add(OnClickBoxBtn);
            VM.RoleBtn.onClick.Add(OnClickRoleBtn);
            VM.FubenBtn.onClick.Add(OnClickFubenBtn);
            VM.ShopBtn.onClick.Add(OnClickShopBtn);
            VM.HomeBtn.onClick.Add(OnClickHomeBtn);
            VM.GonghuiBtn.onClick.Add(OnClickGonghuiBtn);
            VM.JianlingBtn.onClick.Add(OnClickJianlingBtn);
            VM.TaskBtn.onClick.Add(OnClickTaskBtn);
            VM.JinJieBtn.onClick.Add(OnClickJinJieBtn);
            VM.AutoBtn.onClick.Add(OnClickAutoBtn);
            VM.HuanHuaBtn.onClick.Add(OnClickHuanHuaBtn);

        }
        private void RemoveUIListenres()
        {
            VM.GoldBtn.onClick.Remove(OnClickGoldBtn);
            VM.DiamondBtn.onClick.Remove(OnClickDiamondBtn);
            VM.SCBtn.onClick.Remove(OnClickSCBtn);
            VM.XSLBtn.onClick.Remove(OnClickXSLBtn);
            VM.HDBtn.onClick.Remove(OnClickHDBtn);
            VM.GoldBox.onClick.Remove(OnClickGoldBox);
            VM.MailBtn.onClick.Remove(OnClickMailBtn);
            VM.FriendsBtn.onClick.Remove(OnClickFriendsBtn);
            VM.RankBtn.onClick.Remove(OnClickRankBtn);
            VM.BoxBtn.onClick.Remove(OnClickBoxBtn);
            VM.RoleBtn.onClick.Remove(OnClickRoleBtn);
            VM.FubenBtn.onClick.Remove(OnClickFubenBtn);
            VM.ShopBtn.onClick.Remove(OnClickShopBtn);
            VM.HomeBtn.onClick.Remove(OnClickHomeBtn);
            VM.GonghuiBtn.onClick.Remove(OnClickGonghuiBtn);
            VM.JianlingBtn.onClick.Remove(OnClickJianlingBtn);
            VM.TaskBtn.onClick.Remove(OnClickTaskBtn);
            VM.JinJieBtn.onClick.Remove(OnClickJinJieBtn);
            VM.AutoBtn.onClick.Remove(OnClickAutoBtn);
            VM.HuanHuaBtn.onClick.Remove(OnClickHuanHuaBtn);

        }
        private void OnClickGoldBtn(EventContext context)
        {
        }
        private void OnClickDiamondBtn(EventContext context)
        {
        }
        private void OnClickSCBtn(EventContext context)
        {
        }
        private void OnClickXSLBtn(EventContext context)
        {
        }
        private void OnClickHDBtn(EventContext context)
        {
        }
        private void OnClickGoldBox(EventContext context)
        {
        }
        private void OnClickMailBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickMailBtn");
        }
        private void OnClickFriendsBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickFriendsBtn");
        }
        private void OnClickRankBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickRankBtn");
        }
        private void OnClickBoxBtn(EventContext context)
        {
            if (VM.BoxSpine.Play("box_open", false))
            {
                var timer = Context.Time.AddDelayTimer(334, () =>
                {
                    VM.BoxSpine.Play("box_idle", true);
                });
            }
        }
        private void OnClickRoleBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickRoleBtn");
        }
        private void OnClickFubenBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickFubenBtn");
        }
        private void OnClickShopBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickShopBtn");
        }
        private void OnClickHomeBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickHomeBtn");
        }
        private void OnClickGonghuiBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickGonghuiBtn");
        }
        private void OnClickJianlingBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickJianlingBtn");
        }
        private void OnClickTaskBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickTaskBtn");
        }
        private void OnClickJinJieBtn(EventContext context)
        {
            XGame.Log.Debug($"OnClickJinJieBtn");
        }
        private void OnClickAutoBtn(EventContext context)
        {
        }
        private void OnClickHuanHuaBtn(EventContext context)
        {
        }

        #endregion
    }
}