From 53da00fa893ee7d6b727ed973d9f615b2c048ddf Mon Sep 17 00:00:00 2001 From: mskomek <32844718+mskomek@users.noreply.github.com> Date: Thu, 16 Jul 2026 14:01:42 +0300 Subject: [PATCH] GUI: add cross-platform release updater (#243) --- src/SharpEmu.CLI/Program.cs | 5 + src/SharpEmu.GUI/GuiSettings.cs | 2 + src/SharpEmu.GUI/Languages/en.json | 17 +- src/SharpEmu.GUI/Languages/tr.json | 17 +- src/SharpEmu.GUI/MainWindow.axaml | 20 +++ src/SharpEmu.GUI/MainWindow.axaml.cs | 86 ++++++++- src/SharpEmu.GUI/Updater.cs | 253 +++++++++++++++++++++++++++ 7 files changed, 397 insertions(+), 3 deletions(-) create mode 100644 src/SharpEmu.GUI/Updater.cs diff --git a/src/SharpEmu.CLI/Program.cs b/src/SharpEmu.CLI/Program.cs index c0dd2bb9..8343f619 100644 --- a/src/SharpEmu.CLI/Program.cs +++ b/src/SharpEmu.CLI/Program.cs @@ -63,6 +63,11 @@ internal static partial class Program private static int Run(string[] args) { + if (Updater.TryApply(args, out var updateExitCode)) + { + return updateExitCode; + } + args = NormalizeInternalArguments(args, out var isMitigatedChild); if (args.Length == 0 && !isMitigatedChild) { diff --git a/src/SharpEmu.GUI/GuiSettings.cs b/src/SharpEmu.GUI/GuiSettings.cs index d07a4949..441eb74f 100644 --- a/src/SharpEmu.GUI/GuiSettings.cs +++ b/src/SharpEmu.GUI/GuiSettings.cs @@ -48,6 +48,8 @@ public sealed class GuiSettings /// Publish launcher/game status to Discord Rich Presence. public bool DiscordRichPresence { get; set; } = true; + public bool CheckForUpdatesOnStartup { get; set; } = true; + /// Names of SHARPEMU_* switches set to "1" in the emulator's environment at launch. public List EnvironmentToggles { get; set; } = new(); diff --git a/src/SharpEmu.GUI/Languages/en.json b/src/SharpEmu.GUI/Languages/en.json index 803dd63b..8129206b 100644 --- a/src/SharpEmu.GUI/Languages/en.json +++ b/src/SharpEmu.GUI/Languages/en.json @@ -144,5 +144,20 @@ "About.Discord.Label": "Discord", "About.Discord.Desc": "Join the community, get support and follow development.", "About.GithubButton": "Contribute in GitHub!", - "About.DiscordButton": "Join our Discord!" + "About.DiscordButton": "Join our Discord!", + + "Updater.Auto.Label": "Check for updates on startup", + "Updater.Auto.Desc": "Checks GitHub without delaying startup.", + "Updater.Label": "Updates", + "Updater.Check": "Check for updates", + "Updater.DownloadRestart": "Download and restart", + "Updater.Status.Ready": "Current build: {0}", + "Updater.Status.Checking": "Checking for updates…", + "Updater.Status.Current": "You are up to date ({0}).", + "Updater.Status.Available": "A new build is available: {0}", + "Updater.Status.Downloading": "Downloading update… {0}%", + "Updater.Status.Installing": "Installing update…", + "Updater.Status.Timeout": "Update check timed out after 10 seconds.", + "Updater.Status.Failed": "Could not check for updates.", + "Updater.Status.Unsupported": "Automatic updating requires a Windows, Linux or macOS x64 build." } diff --git a/src/SharpEmu.GUI/Languages/tr.json b/src/SharpEmu.GUI/Languages/tr.json index 22e76d5f..957fa806 100644 --- a/src/SharpEmu.GUI/Languages/tr.json +++ b/src/SharpEmu.GUI/Languages/tr.json @@ -125,5 +125,20 @@ "Dialog.PsExecutables": "PS çalıştırılabilirleri", "Dialog.SaveLogFile": "Günlük dosyasının kaydedileceği yeri seçin", "Dialog.PlainTextFiles": "Düz Metin Dosyaları", - "Dialog.LogFiles": "Günlük Dosyaları" + "Dialog.LogFiles": "Günlük Dosyaları", + + "Updater.Auto.Label": "Açılışta güncellemeleri denetle", + "Updater.Auto.Desc": "Açılışı geciktirmeden GitHub'ı denetler.", + "Updater.Label": "Güncellemeler", + "Updater.Check": "Güncellemeleri denetle", + "Updater.DownloadRestart": "İndir ve yeniden başlat", + "Updater.Status.Ready": "Mevcut build: {0}", + "Updater.Status.Checking": "Güncellemeler denetleniyor…", + "Updater.Status.Current": "Güncelsiniz ({0}).", + "Updater.Status.Available": "Yeni build mevcut: {0}", + "Updater.Status.Downloading": "Güncelleme indiriliyor… %{0}", + "Updater.Status.Installing": "Güncelleme kuruluyor…", + "Updater.Status.Timeout": "Güncelleme denetimi 10 saniye sonra zaman aşımına uğradı.", + "Updater.Status.Failed": "Güncellemeler denetlenemedi.", + "Updater.Status.Unsupported": "Otomatik güncelleme Windows, Linux veya macOS x64 build'i gerektirir." } diff --git a/src/SharpEmu.GUI/MainWindow.axaml b/src/SharpEmu.GUI/MainWindow.axaml index 4b5b69ad..223e37c5 100644 --- a/src/SharpEmu.GUI/MainWindow.axaml +++ b/src/SharpEmu.GUI/MainWindow.axaml @@ -315,6 +315,16 @@ SPDX-License-Identifier: GPL-2.0-or-later + + + + + + + + @@ -322,6 +332,16 @@ SPDX-License-Identifier: GPL-2.0-or-later + + + + + + +