
using FGUI.A000_common;
using UnityEngine;
using FairyGUI;

namespace ScrewsMaster
{
    public class RankUI : BaseUI
    {
        private RankUICtrl ctrl;
        private RankModel model;
        private FGUI.G019_Rank.RankPanel ui;

        public RankUI(RankUICtrl ctrl) : base(ctrl)
        {
            uiName = UIConst.RankUI;
            this.ctrl = ctrl;
        }

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

        #region 生命周期
        protected override void OnInit()
        {
            //model = ModuleManager.Instance.GetModel(ModelConst.RankModel) as RankModel;
        }

        protected override void OnClose()
        {
        }

        protected override void OnBind()
        {
            ui = baseUI as FGUI.G019_Rank.RankPanel;
        }

        protected override void OnOpenBefore(object args)
        {
            InitView();
        }

        protected override void OnOpen(object args)
        {
        }

        protected override void OnHide()
        {
        }

        protected override void OnDisplay(object args)
        {
        }
        #endregion

        #region 消息
        protected override void AddListener()
        {
            
        }
        protected override void RemoveListener()
        {
            
        }
        #endregion

        //初始化页面逻辑
        private void InitView()
        {
            ui.CloseBtn.SetClick(()=>
            {
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.RankUI_Close);
            });

            ui.PlayName.text = PreferencesMgr.Instance.PlayerName;
            ui.PlayLevel.text = GameHelper.GetLevel().ToString();
            GameHelper.SetSelfAvatar((ui.PlayIcon.GetChild("loader_avatar") as GComponent).GetChild("loader_avatar") as GLoader);
        }
        
        
    }
}