Skip to content

Commit

Permalink
Remove confirmation when game is asked to be restarted by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 16, 2024
1 parent 2fdbc50 commit fbd1b84
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
8 changes: 6 additions & 2 deletions osu.Desktop/OsuGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using osu.Framework.Logging;
using osu.Game.Updater;
using osu.Desktop.Windows;
using osu.Game.Configuration;
using osu.Game.IO;
using osu.Game.IPC;
using osu.Game.Online.Multiplayer;
Expand Down Expand Up @@ -109,7 +110,7 @@ protected override UpdateManager CreateUpdateManager()
}
}

public override bool RestartAppWhenExited()
public override bool Restart()
{
switch (RuntimeInfo.OS)
{
Expand All @@ -125,7 +126,10 @@ public override bool RestartAppWhenExited()
return true;
}

return base.RestartAppWhenExited();
SessionStatics.SetValue(Static.RestartRequested, true);
AttemptExit();

return base.Restart();
}

protected override void LoadComplete()
Expand Down
4 changes: 2 additions & 2 deletions osu.Desktop/Updater/SquirrelUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class SquirrelUpdateManager : UpdateManager
private readonly SquirrelLogger squirrelLogger = new SquirrelLogger();

[Resolved]
private OsuGameBase game { get; set; } = null!;
private OsuGame game { get; set; } = null!;

[Resolved]
private ILocalUserPlayInfo? localUserInfo { get; set; }
Expand Down Expand Up @@ -150,7 +150,7 @@ private async Task<bool> checkForUpdateAsync(bool useDeltaPatching = true, Updat
private bool restartToApplyUpdate()
{
PrepareUpdateAsync()
.ContinueWith(_ => Schedule(() => game.AttemptExit()));
.ContinueWith(_ => Schedule(() => game.Restart()));
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Screens/Setup/TournamentSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void load(TournamentStorage storage)

Action = () =>
{
game.RestartAppWhenExited();
game.Restart();
game.AttemptExit();
};
folderButton.Action = () => storage.PresentExternally();
Expand Down
6 changes: 6 additions & 0 deletions osu.Game/Configuration/SessionStatics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class SessionStatics : InMemoryConfigManager<Static>
protected override void InitialiseDefaults()
{
SetDefault(Static.LoginOverlayDisplayed, false);
SetDefault(Static.RestartRequested, false);
SetDefault(Static.MutedAudioNotificationShownOnce, false);
SetDefault(Static.LowBatteryNotificationShownOnce, false);
SetDefault(Static.FeaturedArtistDisclaimerShownOnce, false);
Expand Down Expand Up @@ -80,5 +81,10 @@ public enum Static
/// Stores the local user's last score (can be completed or aborted).
/// </summary>
LastLocalUserScore,

/// <summary>
/// Whether the game is in the process of being restarted. This should always be the result of user intention to restart.
/// </summary>
RestartRequested
}
}
2 changes: 1 addition & 1 deletion osu.Game/OsuGameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public virtual void AttemptExit()
/// If supported by the platform, the game will automatically restart after the next exit.
/// </summary>
/// <returns>Whether a restart operation was queued.</returns>
public virtual bool RestartAppWhenExited() => false;
public virtual bool Restart() => false;

public bool Migrate(string path)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ private void load(FrameworkConfigManager config, OsuConfigManager osuConfig, IDi
if (r.NewValue == RendererType.Automatic && automaticRendererInUse)
return;
if (game?.RestartAppWhenExited() == true)
{
game.AttemptExit();
}
else
if (game?.Restart() != true)
{
dialogOverlay?.Push(new ConfirmDialog(GraphicsSettingsStrings.ChangeRendererConfirmation, () => game?.AttemptExit(), () =>
{
Expand Down
8 changes: 6 additions & 2 deletions osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public partial class MainMenu : OsuScreen, IHandlePresentBeatmap, IKeyBindingHan

private Bindable<double> holdDelay;
private Bindable<bool> loginDisplayed;
private Bindable<bool> isRestarting;

private HoldToExitGameOverlay holdToExitGameOverlay;

Expand All @@ -113,6 +114,7 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
{
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
isRestarting = statics.GetBindable<bool>(Static.RestartRequested);

if (host.CanExit)
{
Expand Down Expand Up @@ -388,8 +390,10 @@ public override bool OnExiting(ScreenExitEvent e)
dialogOverlay != null
// if the dialog has already displayed and been accepted by the user, we are good.
&& !exitConfirmedViaDialog
// Only require confirmation if there is either an ongoing operation or the user exited via a non-hold escape press.
&& (notifications.HasOngoingOperations || !exitConfirmedViaHoldOrClick);
// Only require confirmation if there is either an ongoing operation or the exit process wasn't triggered via user intention.
&& (notifications.HasOngoingOperations || (!exitConfirmedViaHoldOrClick && !isRestarting.Value));

isRestarting.Value = false;

if (requiresConfirmation)
{
Expand Down

0 comments on commit fbd1b84

Please sign in to comment.