Commit db813c4d authored by hex's avatar hex

fix superpre cards download

parent e4c4c727
Pipeline #39963 failed
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
public class YGO1superShower : MonoBehaviour { public class YGO1superShower : MonoBehaviour
{
public UITexture card; public UITexture card;
public UITexture closeup; public UITexture closeup;
// Use this for initialization // Use this for initialization
void Start () { void Start()
{
}
}
// Update is called once per frame
void Update () { // Update is called once per frame
void Update()
} {
}
} }
...@@ -193,7 +193,7 @@ public class Menu : WindowServantSP ...@@ -193,7 +193,7 @@ public class Menu : WindowServantSP
// 2. 使用 DownloadFileWithHeadCheck 下载文件 // 2. 使用 DownloadFileWithHeadCheck 下载文件
bool downloadCompleted = false; bool downloadCompleted = false;
bool fileExistedBefore = File.Exists(ypkFilePath); bool newVersionDownloaded = false;
int lastReportedProgress = 0; // 用于控制进度报告的频率 int lastReportedProgress = 0; // 用于控制进度报告的频率
yield return Program.I().StartCoroutine(UnityFileDownloader.DownloadFileWithHeadCheck( yield return Program.I().StartCoroutine(UnityFileDownloader.DownloadFileWithHeadCheck(
...@@ -205,6 +205,11 @@ public class Menu : WindowServantSP ...@@ -205,6 +205,11 @@ public class Menu : WindowServantSP
}, },
(progress) => (progress) =>
{ {
if (!newVersionDownloaded)
{
newVersionDownloaded = true;
Program.PrintToChat("发现新版本,开始下载...");
}
int currentProgress = Mathf.FloorToInt(progress * 100); int currentProgress = Mathf.FloorToInt(progress * 100);
if (currentProgress >= lastReportedProgress + 10) if (currentProgress >= lastReportedProgress + 10)
{ {
...@@ -218,14 +223,13 @@ public class Menu : WindowServantSP ...@@ -218,14 +223,13 @@ public class Menu : WindowServantSP
if (!downloadCompleted) if (!downloadCompleted)
{ {
Program.PrintToChat("超先行卡更新失败,请检查网络连接或稍后再试。"); Program.PrintToChat("超先行卡更新失败,请检查网络连接或稍后再试。");
isDownloadingSuperPre = false;
yield break; // 提前退出协程 yield break; // 提前退出协程
} }
bool fileExistsAfter = File.Exists(ypkFilePath); if (newVersionDownloaded)
if (!fileExistedBefore && fileExistsAfter)
{ {
Program.PrintToChat("发现新版本,下载完成,开始解压。"); Program.PrintToChat("下载完成,开始解压。");
yield return null; yield return null;
try try
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment