mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:02:55 +08:00
Fix exit confirmation dialog not blocking all exit cases
This commit is contained in:
parent
0a2265b0e8
commit
369ab10212
@ -288,23 +288,11 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
{
|
{
|
||||||
if (Room.RoomID.Value == null)
|
if (Room.RoomID.Value == null)
|
||||||
{
|
{
|
||||||
if (dialogOverlay == null || Room.Playlist.Count == 0)
|
if (!ensureExitConfirmed())
|
||||||
{
|
|
||||||
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)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
dialogOverlay?.Push(new ConfirmDiscardChangesDialog(() =>
|
settingsOverlay.Hide();
|
||||||
{
|
return base.OnBackButton();
|
||||||
settingsOverlay.Hide();
|
|
||||||
this.Exit();
|
|
||||||
}));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserModsSelectOverlay.State.Value == Visibility.Visible)
|
if (UserModsSelectOverlay.State.Value == Visibility.Visible)
|
||||||
@ -348,8 +336,13 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
Scheduler.AddOnce(updateRuleset);
|
Scheduler.AddOnce(updateRuleset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool exitConfirmed;
|
||||||
|
|
||||||
public override bool OnExiting(ScreenExitEvent e)
|
public override bool OnExiting(ScreenExitEvent e)
|
||||||
{
|
{
|
||||||
|
if (!ensureExitConfirmed())
|
||||||
|
return true;
|
||||||
|
|
||||||
RoomManager?.PartRoom();
|
RoomManager?.PartRoom();
|
||||||
Mods.Value = Array.Empty<Mod>();
|
Mods.Value = Array.Empty<Mod>();
|
||||||
|
|
||||||
@ -358,6 +351,28 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
return base.OnExiting(e);
|
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()
|
protected void StartPlay()
|
||||||
{
|
{
|
||||||
// User may be at song select or otherwise when the host starts gameplay.
|
// User may be at song select or otherwise when the host starts gameplay.
|
||||||
|
Loading…
Reference in New Issue
Block a user