1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge pull request #9559 from Joehuu/fix-screens-blocking-home/altf4

Fix certain overlays and screens blocking home and alt-f4
This commit is contained in:
Dan Balasescu 2020-07-15 14:00:54 +09:00 committed by GitHub
commit 50c9421c11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 16 deletions

View File

@ -573,7 +573,9 @@ namespace osu.Game
Origin = Anchor.BottomLeft,
Action = () =>
{
if ((ScreenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
var currentScreen = ScreenStack.CurrentScreen as IOsuScreen;
if (currentScreen?.AllowBackButton == true && !currentScreen.OnBackButton())
ScreenStack.Exit();
}
},

View File

@ -56,5 +56,14 @@ namespace osu.Game.Screens
/// Whether mod rate adjustments are allowed to be applied.
/// </summary>
bool AllowRateAdjustments { get; }
/// <summary>
/// Invoked when the back button has been pressed to close any overlays before exiting this <see cref="IOsuScreen"/>.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
bool OnBackButton();
}
}

View File

@ -250,12 +250,6 @@ namespace osu.Game.Screens.Multi
{
roomManager.PartRoom();
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();
return true;
}
waves.Hide();
this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
@ -269,6 +263,20 @@ namespace osu.Game.Screens.Multi
return false;
}
public override bool OnBackButton()
{
if ((screenStack.CurrentScreen as IMultiplayerSubScreen)?.OnBackButton() == true)
return true;
if (screenStack.CurrentScreen != null && !(screenStack.CurrentScreen is LoungeSubScreen))
{
screenStack.Exit();
return true;
}
return false;
}
protected override void LogoExiting(OsuLogo logo)
{
base.LogoExiting(logo);

View File

@ -258,5 +258,7 @@ namespace osu.Game.Screens
/// Note that the instance created may not be the used instance if it matches the BackgroundMode equality clause.
/// </summary>
protected virtual BackgroundScreen CreateBackground() => null;
public virtual bool OnBackButton() => false;
}
}

View File

@ -194,6 +194,13 @@ namespace osu.Game.Screens.Ranking
}
public override bool OnExiting(IScreen next)
{
Background.FadeTo(1, 250);
return base.OnExiting(next);
}
public override bool OnBackButton()
{
if (statisticsPanel.State.Value == Visibility.Visible)
{
@ -201,9 +208,7 @@ namespace osu.Game.Screens.Ranking
return true;
}
Background.FadeTo(1, 250);
return base.OnExiting(next);
return false;
}
private void addScore(ScoreInfo score)

View File

@ -599,12 +599,6 @@ namespace osu.Game.Screens.Select
public override bool OnExiting(IScreen next)
{
if (ModSelect.State.Value == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
if (base.OnExiting(next))
return true;
@ -620,6 +614,17 @@ namespace osu.Game.Screens.Select
return false;
}
public override bool OnBackButton()
{
if (ModSelect.State.Value == Visibility.Visible)
{
ModSelect.Hide();
return true;
}
return false;
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);