1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 21:52:55 +08:00

Only call OnBackButton() if the screen has finished loading

This commit is contained in:
smoogipoo 2021-06-08 17:38:12 +09:00
parent 490ab9e96a
commit 860f1aebb3
3 changed files with 7 additions and 3 deletions

View File

@ -651,9 +651,10 @@ namespace osu.Game
Origin = Anchor.BottomLeft,
Action = () =>
{
var currentScreen = ScreenStack.CurrentScreen as IOsuScreen;
if (!(ScreenStack.CurrentScreen is IOsuScreen currentScreen))
return;
if (currentScreen?.AllowBackButton == true && !currentScreen.OnBackButton())
if (!((Drawable)currentScreen).IsLoaded || currentScreen.AllowBackButton && !currentScreen.OnBackButton())
ScreenStack.Exit();
}
},

View File

@ -67,8 +67,11 @@ namespace osu.Game.Screens
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.
/// </summary>
/// <remarks>
/// If this <see cref="IOsuScreen"/> has not yet finished loading, the exit will occur immediately without this method being invoked.
/// <para>
/// Return <c>true</c> to block this <see cref="IOsuScreen"/> from being exited after closing an overlay.
/// Return <c>false</c> if this <see cref="IOsuScreen"/> should continue exiting.
/// </para>
/// </remarks>
bool OnBackButton();
}

View File

@ -665,7 +665,7 @@ namespace osu.Game.Screens.Select
public override bool OnBackButton()
{
if (ModSelect?.State.Value == Visibility.Visible)
if (ModSelect.State.Value == Visibility.Visible)
{
ModSelect.Hide();
return true;