From d471e8d9e5dc133f1b8407b2111d859183445944 Mon Sep 17 00:00:00 2001 From: koyu Date: Fri, 12 Jan 2024 22:51:23 +0100 Subject: [PATCH] Check for updates on launch --- PlaySync/Main.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/PlaySync/Main.cs b/PlaySync/Main.cs index 1d8060c..e68751e 100644 --- a/PlaySync/Main.cs +++ b/PlaySync/Main.cs @@ -24,7 +24,7 @@ public partial class Main : Form bool pluggedin = false; bool syncing = false; bool cansync = false; - string version = "0"; + string version = "1"; string oldtext = ""; string deviceinfo = ""; string[] games; @@ -38,7 +38,7 @@ public static bool isDebug #if DEBUG return true; #else - return false; + return false; #endif } } @@ -74,14 +74,36 @@ public Main() toolStripMenuItem2.Checked = false; } string[] args = Environment.GetCommandLineArgs(); + bool autostart = false; foreach (string arg in args) { if (arg == "--autostart") { + autostart = true; this.ShowInTaskbar = false; this.WindowState = FormWindowState.Minimized; } } + if (!autostart) + { + try + { + string pubv = new WebClient().DownloadString("https://updates.koyu.space/playsync/latest"); + if (pubv.Split('\n')[0] != version) + { + DialogResult result = MessageBox.Show("New update available. Download now?", "New update available", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + { + launchUrl("https://updates.koyu.space/playsync/playsync.zip"); + } + } + else + { + MessageBox.Show("PlaySync is up to date!", "Up to date", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + catch { } + } } private void readGames(string readfolder)