using FGUI.Game_04;

namespace ChillConnect
{
    public class GameMenuUI : BaseUI
    {
        private GameMenuUICtrl ctrl;
        private GameMenuModel model;
        private com_game_menu ui;

        private string content;

        private bool isTerm;

        public GameMenuUI(GameMenuUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.GameMenuUI;
            this.ctrl = ctrl;
        }

        protected override void SetUIInfo(UIInfo uiInfo)
        {
            uiInfo.packageName = "Game_04";
            uiInfo.assetName = "com_game_menu";
            uiInfo.layerType = UILayerType.Popup;
            uiInfo.isNeedOpenAnim = true;
            uiInfo.isNeedCloseAnim = true;
            uiInfo.isNeedUIMask = true;
        }

        #region 生命周期

        protected override void OnInit()
        {
        }

        protected override void OnClose()
        {
        }

        protected override void OnBind()
        {
            ui = baseUI as com_game_menu;
        }

        protected override void OnOpenBefore(object args)
        {
            if (args != null)
            {
                isTerm = (bool)args;
            }


            InitView();
        }

        protected override void OnOpen(object args)
        {
        }

        #endregion



        private void InitView()
        {
            ui.btn_close.SetClick(() =>
            {
                CtrlCloseUI();
            });
            ui.btn_exit.SetClick(() =>
            {
                CtrlCloseUI();

                GameDispatcher.Instance.Dispatch(GameMsg.ExitGame);
            });

            ui.btn_resume.SetClick(() =>
            {
                CtrlCloseUI();
            });
        }
    }
}