using UnityEngine;

namespace ScrewsMaster
{
    public static class App
    {
        private static SApplication _sCurrSApplication = null;

        public static void InitApplication(SApplication sApplication)
        {
            _sCurrSApplication = sApplication;
            _sCurrSApplication.Init();
            _sCurrSApplication.Enable();
        }

        private static float LoadingProgressDelayTime = 0f;

        public static void DisplayLoadingUI()
        {
            if (PlayerPrefs.GetInt("is_gift") == 1)
            {
                AppDispatcher.Instance.Dispatch(AppMsg.UI_DisplayLoadingUI);
            }
            else
            {
                UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LoginAUI_Open);
            }
        }

        public static void HideLoadingUI(bool isDelay = false)
        {
            if (!isDelay)
            {
                AppDispatcher.Instance.Dispatch(AppMsg.UI_HideLoadingUI);
                return;
            }

            TimerHelper.mEasy.AddTimer(0.5f, () => { AppDispatcher.Instance.Dispatch(AppMsg.UI_HideLoadingUI); });
        }
    }
}