namespace ScrewsMaster
{
    public class ProfileUICtrl : BaseUICtrl
    {
        private ProfileUI ui;
        private ProfileModel model;

        private uint openUIMsg = UICtrlMsg.ProfileUI_Open;
        private uint closeUIMsg = UICtrlMsg.ProfileUI_Close;

        protected override void OnInit()
        {
        }

        protected override void OnDispose()
        {
        }

        public override void OpenUI(object args = null)
        {
            if (ui == null)
            {
                ui = new ProfileUI(this);
                ui.Open(args);
            }
        }

        public override void CloseUI(object args = null)
        {
            if (ui is { isClose: false })
            {
                ui.Close();
            }

            ui = null;
        }

        public override uint GetOpenUIMsg(string uiName)
        {
            return openUIMsg;
        }

        public override uint GetCloseUIMsg(string uiName)
        {
            return closeUIMsg;
        }

        protected override void AddListener()
        {
            uiCtrlDispatcher.AddListener(openUIMsg, OpenUI);
            uiCtrlDispatcher.AddListener(closeUIMsg, CloseUI);
        }

        protected override void RemoveListener()
        {
            uiCtrlDispatcher.RemoveListener(openUIMsg, OpenUI);
            uiCtrlDispatcher.RemoveListener(closeUIMsg, CloseUI);
        }
    }
}