Disallow exiting the editor without saving (unless explicitly confirming)

This commit is contained in:
Dean Herbert
2022-03-22 15:28:31 +09:00
parent f95bd89166
commit 61ddf1e6cf
3 changed files with 30 additions and 8 deletions

View File

@ -98,7 +98,7 @@ namespace osu.Game.Screens.Edit
private bool canSave;
private bool exitConfirmed;
protected bool ExitConfirmed { get; private set; }
private string lastSavedHash;
@ -587,7 +587,7 @@ namespace osu.Game.Screens.Edit
public override bool OnExiting(IScreen next)
{
if (!exitConfirmed)
if (!ExitConfirmed)
{
// dialog overlay may not be available in visual tests.
if (dialogOverlay == null)
@ -596,12 +596,9 @@ namespace osu.Game.Screens.Edit
return true;
}
// if the dialog is already displayed, confirm exit with no save.
// if the dialog is already displayed, block exiting until the user explicitly makes a decision.
if (dialogOverlay.CurrentDialog is PromptForSaveDialog saveDialog)
{
saveDialog.PerformAction<PopupDialogDangerousButton>();
return true;
}
if (isNewBeatmap || HasUnsavedChanges)
{
@ -646,7 +643,7 @@ namespace osu.Game.Screens.Edit
{
Save();
exitConfirmed = true;
ExitConfirmed = true;
this.Exit();
}
@ -669,7 +666,7 @@ namespace osu.Game.Screens.Edit
Beatmap.SetDefault();
}
exitConfirmed = true;
ExitConfirmed = true;
this.Exit();
}