Commit 978a4a43 authored by perfectdicky's avatar perfectdicky

check update version

parent d3976df6
......@@ -26,9 +26,10 @@ public class Menu : WindowServantSP
UIHelper.registEvent(gameObject, "online_", onClickOnline);
UIHelper.registEvent(gameObject, "replay_", onClickReplay);
UIHelper.registEvent(gameObject, "single_", onClickPizzle);
//UIHelper.registEvent(gameObject, "ai_", Program.gugugu);
UIHelper.registEvent(gameObject, "ai_", onClickAI);
UIHelper.registEvent(gameObject, "exit_", onClickExit);
//MDPRO2 update
UIHelper.getByName<UILabel>(gameObject, "version_").text = "1.7.4";
Program.I().StartCoroutine(checkUpdate());
}
......@@ -41,21 +42,19 @@ public class Menu : WindowServantSP
private IEnumerator checkUpdate()
{
yield return new WaitForSeconds(1);
var verFile = File.ReadAllLines("config/ver.txt", Encoding.UTF8);
if (verFile.Length == 0) // 放一个空的 ver.txt 以关闭自动更新功能
yield break;
if (verFile.Length != 2 || !Uri.IsWellFormedUriString(verFile[1], UriKind.Absolute))
{
Program.PrintToChat(InterString.Get("YGOPro2 自动更新:[ff5555]未设置更新服务器,无法检查更新。[-]@n请从官网重新下载安装完整版以获得更新。"));
yield break;
}
var ver = verFile[0];
var url = verFile[1];
var www = UnityWebRequest.Get(url);
// var verFile = File.ReadAllLines("config/ver.txt", Encoding.UTF8);
// if (verFile.Length != 2 || !Uri.IsWellFormedUriString(verFile[1], UriKind.Absolute))
// {
// Program.PrintToChat(InterString.Get("MDPro2 自动更新:[ff5555]未设置更新服务器,无法检查更新。[-]"));
// yield break;
// }
// var ver = verFile[0];
// var url = verFile[1];
var ver= UIHelper.getByName<UILabel>(gameObject, "version_").text;
var www = UnityWebRequest.Get("https://code.mycard.moe/sherry_chaos/MDPro2_Version/-/raw/master/ver.txt");
www.SetRequestHeader("Cache-Control", "max-age=0, no-cache, no-store");
www.SetRequestHeader("Pragma", "no-cache");
yield return www.Send();
yield return www.SendWebRequest();
try
{
var result = www.downloadHandler.text;
......@@ -63,17 +62,18 @@ public class Menu : WindowServantSP
var mats = lines[0].Split(":.:");
if (ver != mats[0])
{
upurl = mats[1];
for (var i = 1; i < lines.Length; i++) uptxt += lines[i] + "\n";
Program.PrintToChat(InterString.Get("MDPro2 不是最新版本 更新!更新!更新![-]"));
// upurl = mats[1];
// for (var i = 1; i < lines.Length; i++) uptxt += lines[i] + "\n";
}
else
{
Program.PrintToChat(InterString.Get("YGOPro2 自动更新:[55ff55]当前已是最新版本。[-]"));
Program.PrintToChat(InterString.Get("MDPro2 自动更新:[55ff55]当前已是最新版本。[-]"));
}
}
catch (Exception e)
{
Program.PrintToChat(InterString.Get("YGOPro2 自动更新:[ff5555]检查更新失败![-]"));
Program.PrintToChat(InterString.Get("MDPro2 自动更新:[ff5555]检查更新失败![-]"));
}
}
......
......@@ -8,11 +8,6 @@ using YGOSharp;
public class Program : MonoBehaviour
{
public static void gugugu()
{
PrintToChat(InterString.Get("非常抱歉,因为技术原因,此功能暂时无法使用。请关注官方网站获取更多消息。"));
}
#region Resources
[Header("场景")]
......
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