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:
parent
490ab9e96a
commit
860f1aebb3
@ -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();
|
||||
}
|
||||
},
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user