Esempio n. 1
0
    /// <summary>
    /// Before Init Modules, coroutine
    /// </summary>
    /// <returns></returns>
    public override IEnumerator OnBeforeInit()
    {
        if (AppConfig.IsDownloadRes)
        {
            var loader = AssetBundleLoader.Load($"uiatlas/{UIModule.Instance.CommonAtlases[0]}", (isOk, ab) =>
            {
                if (isOk && ab)
                {
                    var atlas = ab.LoadAsset <SpriteAtlas>("atlas_common");
                    ABManager.SpriteAtlases["atlas_common"] = atlas;
                }
            });
            while (!loader.IsCompleted)
            {
                yield return(null);
            }
            yield return(StartCoroutine(DownloadManager.Instance.CheckDownload()));

            if (DownloadManager.Instance.ErrorType != UpdateErrorType.None)
            {
                UIMsgBoxInfo info = new UIMsgBoxInfo().GetDefalut(I18N.Get("download_error", DownloadManager.Instance.ErrorType), null, I18N.Get("common_ignore"), I18N.Get("common_exit"));
                info.OkCallback     = () => { DownloadManager.Instance.DownloadFinish = true; };
                info.CancelCallback = KTool.ExitGame;
                var panel = UIModule.Instance.GetOrCreateUI <KUIMsgBox>();
                panel.info = info;
                panel.DisPlay(true);
            }
        }
        else
        {
            DownloadManager.Instance.DownloadFinish = true;
        }
    }
Esempio n. 2
0
    private void RefreshUI(UIMsgBoxInfo info)
    {
        ColorQuadMask.SetActive(info.AlphaMask);
        labelTitle.SetText(info.Title);
        labelMsgContent.SetText(info.Message);
        if (!string.IsNullOrEmpty(info.strOk))
        {
            btnOk.SetActive(true);
            btnOkText.SetText(info.strOk);
        }
        else
        {
            btnOk.SetActive(false);
        }

        if (!string.IsNullOrEmpty(info.strCancel))
        {
            btnCancel.SetActive(true);
            btnCancelText.SetText(info.strCancel);
        }
        else
        {
            btnCancel.SetActive(false);
        }
    }
Esempio n. 3
0
 public override void OnClose()
 {
     base.OnClose();
     KSGame.Instance.StopCoroutine(WaitForTimeout());
     labelCountDown.SetActive(false);
     info.OkCallback     = null;
     info.CancelCallback = null;
     info = null;
 }
Esempio n. 4
0
    public UIMsgBoxInfo GetDefalut(string msg, string strTitle = null, string strOk = null, string strCancel = null)
    {
        var info = new UIMsgBoxInfo();

        info.Title = strTitle == null?I18N.Get("common_title_tips") : strTitle;

        info.Message = msg;
        info.strOk   = strOk == null?I18N.Get("common_ok") : strOk;

        info.strCancel = strCancel == null?I18N.Get("common_cancel") : strCancel;

        return(info);
    }
Esempio n. 5
0
    public IEnumerator CheckDownload()
    {
        ClearData();
        var loadingPanel = UIModule.Instance.GetOrCreateUI <LoadingPanel>();

        loadingPanel.SetProgress(I18N.Get("download_check"));
        loadingPanel.DisPlay(true);
        string url = AppConfig.resUrl + AppConfig.VersionTxtName;

        Log.LogToFile($"读取远程version.txt:{url}");
        var loader = KWWWLoader.Load(url);

        while (!loader.IsCompleted)
        {
            yield return(null);
        }

        if (!loader.IsError)
        {
            ParseText(loader.Www.text, remoteVersion);
            remoteVersion.TryGetValue("filelist.txt", out filelistVersion);
        }
        else
        {
            ErrorType = UpdateErrorType.RemoteVersionError;
            yield break;
        }

        url = KResourceModule.GetResourceFullPath(AppConfig.VersionTxtName, false);
        Log.LogToFile($"读取本地version.txt:{url}");
        loader = KWWWLoader.Load(url);
        while (!loader.IsCompleted)
        {
            yield return(null);
        }

        if (!loader.IsError)
        {
            ParseText(loader.Www.text, localVersion);
        }
        else
        {
            ErrorType = UpdateErrorType.LocalVersionError;
            yield break;
        }

        loader.Dispose();
        loader = null;
        CompareVersion("lua.zip");
        CompareVersion("setting.zip");
        bool filelistSame = CompareVersion("filelist.txt", false);

        if (filelistSame == false)
        {
            //对比ab列表
            string remote_filelist = null;
            url    = AppConfig.resUrl + AppConfig.FilelistPath;
            loader = KWWWLoader.Load(url);
            while (!loader.IsCompleted)
            {
                yield return(null);
            }

            if (!loader.IsError)
            {
                remote_filelist = loader.Www.text;
            }
            else
            {
                ErrorType = UpdateErrorType.FilelistnError;
            }
            url    = KResourceModule.GetResourceFullPath(AppConfig.FilelistPath, false);
            loader = KWWWLoader.Load(url);
            while (!loader.IsCompleted)
            {
                yield return(null);
            }

            //开始对比两个filelist
            if (!loader.IsError)
            {
                GetDownloadFromFilelist(loader.Www.text, remote_filelist);
            }
            else
            {
                ErrorType = UpdateErrorType.LocalFilelistnError;
            }
        }

        if (downloadFiles.Count > 0)
        {
            var          panel = UIModule.Instance.GetOrCreateUI <KUIMsgBox>();
            UIMsgBoxInfo info  = new UIMsgBoxInfo().GetDefalut(I18N.Get("download_msg", KTool.FormatFileSize(downloadTotalSize)), strCancel: I18N.Get("common_skip"));
            info.OkCallback     = () => { Game.Instance.StartCoroutine(StartUpdate()); };
            info.CancelCallback = IngoreDownload;
            panel.info          = info;
            panel.DisPlay(true);
        }
        else
        {
            Log.LogToFile($"本次启动无资源更新,跳过下载");
            ClearData();
            DownloadFinish = true;
        }
    }