Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Add version update checker
Browse files Browse the repository at this point in the history
  • Loading branch information
silent-destroyer committed Aug 13, 2023
1 parent 0b9ba4e commit 0ae808f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Patches/TitleVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using UnityEngine.UI;
using System.Net;
using UnityEngine.InputSystem.Utilities;
using System.IO;
using Newtonsoft.Json;

namespace TunicArchipelago {
public class TitleVersion {
Expand All @@ -16,26 +18,28 @@ public class TitleVersion {
public static GameObject TitleLogo;
public static void Initialize() {
if (!Loaded) {
/* bool UpdateAvailable = false;
bool UpdateAvailable = false;
string UpdateVersion = PluginInfo.VERSION;
try {
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/silent-destroyer/tunic-randomizer/releases");
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://api.github.com/silent-destroyer/tunic-randomizer-archipelago/releases");
Request.UserAgent = "request";
HttpWebResponse response = (HttpWebResponse)Request.GetResponse();
StreamReader Reader = new StreamReader(response.GetResponseStream());
string JsonResponse = Reader.ReadToEnd();
dynamic Releases = JSONParser.FromJson<dynamic>(JsonResponse);
UpdateAvailable = Releases[0]["tag_name"] != PluginInfo.VERSION;
UpdateVersion = Releases[0]["tag_name"];
dynamic Releases = JsonConvert.DeserializeObject<dynamic>(JsonResponse);
TunicArchipelago.Logger.LogInfo(Releases[0]["tag_name"]);
UpdateAvailable = Releases[0]["tag_name"].ToString() != PluginInfo.VERSION;
UpdateVersion = Releases[0]["tag_name"].ToString();
} catch (Exception e) {
}*/
TunicArchipelago.Logger.LogInfo(e.Message);
}
TMP_FontAsset FontAsset = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().Where(Font => Font.name == "Latin Rounded").ToList()[0];
Material FontMaterial = Resources.FindObjectsOfTypeAll<Material>().Where(Material => Material.name == "Latin Rounded - Quantity Outline").ToList()[0];
GameObject TitleVersion = new GameObject("randomizer version");
TitleVersion.AddComponent<TextMeshProUGUI>().text = $"Randomizer + Archipelago Mod Ver. {PluginInfo.VERSION}";
/* if (UpdateAvailable) {
if (UpdateAvailable) {
TitleVersion.GetComponent<TextMeshProUGUI>().text += $" (Update Available: v{UpdateVersion}!)";
}*/
}
TitleVersion.GetComponent<TextMeshProUGUI>().color = new Color(1.0f, 0.64f, 0.0f);
TitleVersion.GetComponent<TextMeshProUGUI>().fontMaterial = FontMaterial;
TitleVersion.GetComponent<TextMeshProUGUI>().font = FontAsset;
Expand Down

0 comments on commit 0ae808f

Please sign in to comment.