1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 19:22:56 +08:00

Merge pull request #18760 from peppy/reidrect-graceful-exit

Redirect graceful exiting to standard exit flow
This commit is contained in:
Bartłomiej Dach 2022-06-19 14:38:29 +02:00 committed by GitHub
commit 9518e1db05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 6 deletions

View File

@ -154,7 +154,7 @@ namespace osu.Desktop.Updater
Activated = () =>
{
updateManager.PrepareUpdateAsync()
.ContinueWith(_ => updateManager.Schedule(() => game?.GracefullyExit()));
.ContinueWith(_ => updateManager.Schedule(() => game?.AttemptExit()));
return true;
};
}

View File

@ -27,7 +27,7 @@ namespace osu.Game.Tournament.Screens.Setup
dropdown.Items = storage.ListTournaments();
dropdown.Current.BindValueChanged(v => Button.Enabled.Value = v.NewValue != startupTournament, true);
Action = () => game.GracefullyExit();
Action = () => game.AttemptExit();
folderButton.Action = () => storage.PresentExternally();
ButtonText = "Close osu!";

View File

@ -637,6 +637,12 @@ namespace osu.Game
Add(performFromMainMenuTask = new PerformFromMenuRunner(action, validScreens, () => ScreenStack.CurrentScreen));
}
public override void AttemptExit()
{
// Using PerformFromScreen gives the user a chance to interrupt the exit process if needed.
PerformFromScreen(menu => menu.Exit());
}
/// <summary>
/// Wait for the game (and target component) to become loaded and then run an action.
/// </summary>

View File

@ -417,14 +417,15 @@ namespace osu.Game
/// <summary>
/// Use to programatically exit the game as if the user was triggering via alt-f4.
/// Will keep persisting until an exit occurs (exit may be blocked multiple times).
/// By default, will keep persisting until an exit occurs (exit may be blocked multiple times).
/// May be interrupted (see <see cref="OsuGame"/>'s override).
/// </summary>
public void GracefullyExit()
public virtual void AttemptExit()
{
if (!OnExiting())
Exit();
else
Scheduler.AddDelayed(GracefullyExit, 2000);
Scheduler.AddDelayed(AttemptExit, 2000);
}
public bool Migrate(string path)

View File

@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
dialogOverlay.Push(new ConfirmDialog("To complete this operation, osu! will close. Please open it again to use the new data location.", () =>
{
(storage as OsuStorage)?.ChangeDataPath(target.FullName);
game.GracefullyExit();
game.Exit();
}, () => { }));
},
() => { }));