From 836efe3f7c697448b82a1f3b053ef0dd85f3efc0 Mon Sep 17 00:00:00 2001 From: Craftplacer Date: Thu, 7 May 2020 08:07:22 +0200 Subject: [PATCH] Initial commit --- osu.Desktop/Updater/SquirrelUpdateManager.cs | 4 +++- .../Settings/Sections/General/UpdateSettings.cs | 13 ++++++++++++- osu.Game/Updater/SimpleUpdateManager.cs | 4 +++- osu.Game/Updater/UpdateManager.cs | 6 ++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/osu.Desktop/Updater/SquirrelUpdateManager.cs b/osu.Desktop/Updater/SquirrelUpdateManager.cs index ade8460dd7..b287dd6527 100644 --- a/osu.Desktop/Updater/SquirrelUpdateManager.cs +++ b/osu.Desktop/Updater/SquirrelUpdateManager.cs @@ -37,10 +37,12 @@ namespace osu.Desktop.Updater if (game.IsDeployedBuild) { Splat.Locator.CurrentMutable.Register(() => new SquirrelLogger(), typeof(Splat.ILogger)); - Schedule(() => Task.Run(() => checkForUpdateAsync())); + CheckForUpdate(); } } + public override void CheckForUpdate() => Schedule(() => Task.Run(() => checkForUpdateAsync())); + private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // should we schedule a retry on completion of this check? diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 188c9c05ef..71deeee693 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -5,15 +5,19 @@ using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Game.Configuration; +using osu.Game.Updater; namespace osu.Game.Overlays.Settings.Sections.General { public class UpdateSettings : SettingsSubsection { + [Resolved(CanBeNull = true)] + private UpdateManager updateManager { get; set; } + protected override string Header => "Updates"; [BackgroundDependencyLoader] - private void load(Storage storage, OsuConfigManager config) + private void load(Storage storage, OsuConfigManager config, OsuGameBase game) { Add(new SettingsEnumDropdown { @@ -21,6 +25,13 @@ namespace osu.Game.Overlays.Settings.Sections.General Bindable = config.GetBindable(OsuSetting.ReleaseStream), }); + Add(new SettingsButton + { + Text = "Check for updates", + Action = () => updateManager?.CheckForUpdate(), + Enabled = { Value = game.IsDeployedBuild } + }); + if (RuntimeInfo.IsDesktop) { Add(new SettingsButton diff --git a/osu.Game/Updater/SimpleUpdateManager.cs b/osu.Game/Updater/SimpleUpdateManager.cs index 1e8a96444f..41248ed796 100644 --- a/osu.Game/Updater/SimpleUpdateManager.cs +++ b/osu.Game/Updater/SimpleUpdateManager.cs @@ -30,9 +30,11 @@ namespace osu.Game.Updater version = game.Version; if (game.IsDeployedBuild) - Schedule(() => Task.Run(checkForUpdateAsync)); + CheckForUpdate(); } + public override void CheckForUpdate() => Schedule(() => Task.Run(checkForUpdateAsync)); + private async void checkForUpdateAsync() { try diff --git a/osu.Game/Updater/UpdateManager.cs b/osu.Game/Updater/UpdateManager.cs index 28a295215f..f628bde324 100644 --- a/osu.Game/Updater/UpdateManager.cs +++ b/osu.Game/Updater/UpdateManager.cs @@ -4,6 +4,7 @@ using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using osu.Framework.Logging; using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Overlays; @@ -44,6 +45,11 @@ namespace osu.Game.Updater config.Set(OsuSetting.Version, version); } + public virtual void CheckForUpdate() + { + Logger.Log("CheckForUpdate was called on the base class (UpdateManager)", LoggingTarget.Information); + } + private class UpdateCompleteNotification : SimpleNotification { private readonly string version;