1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00

Fix exit confirmation dialog not blocking all exit cases

This commit is contained in:
Salman Ahmed 2022-07-30 10:31:23 +03:00
parent 0a2265b0e8
commit 369ab10212

View File

@ -288,23 +288,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
{
if (Room.RoomID.Value == null)
{
if (dialogOverlay == null || Room.Playlist.Count == 0)
{
settingsOverlay.Hide();
return base.OnBackButton();
}
// if the dialog is already displayed, block exiting until the user explicitly makes a decision.
if (dialogOverlay.CurrentDialog is ConfirmDiscardChangesDialog)
if (!ensureExitConfirmed())
return true;
dialogOverlay?.Push(new ConfirmDiscardChangesDialog(() =>
{
settingsOverlay.Hide();
this.Exit();
}));
return true;
settingsOverlay.Hide();
return base.OnBackButton();
}
if (UserModsSelectOverlay.State.Value == Visibility.Visible)
@ -348,8 +336,13 @@ namespace osu.Game.Screens.OnlinePlay.Match
Scheduler.AddOnce(updateRuleset);
}
private bool exitConfirmed;
public override bool OnExiting(ScreenExitEvent e)
{
if (!ensureExitConfirmed())
return true;
RoomManager?.PartRoom();
Mods.Value = Array.Empty<Mod>();
@ -358,6 +351,28 @@ namespace osu.Game.Screens.OnlinePlay.Match
return base.OnExiting(e);
}
private bool ensureExitConfirmed()
{
if (exitConfirmed)
return true;
if (dialogOverlay == null || Room.RoomID.Value != null || Room.Playlist.Count == 0)
return true;
// if the dialog is already displayed, block exiting until the user explicitly makes a decision.
if (dialogOverlay.CurrentDialog is ConfirmDiscardChangesDialog)
return false;
dialogOverlay.Push(new ConfirmDiscardChangesDialog(() =>
{
exitConfirmed = true;
settingsOverlay.Hide();
this.Exit();
}));
return false;
}
protected void StartPlay()
{
// User may be at song select or otherwise when the host starts gameplay.