1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge pull request #26189 from peppy/fix-escape-key-spectator-fail

Fix using "Back" binding at spectator fail screen not working
This commit is contained in:
Bartłomiej Dach 2023-12-28 13:23:38 +01:00 committed by GitHub
commit e0279920b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -44,7 +44,15 @@ namespace osu.Game.Screens.Play
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
/// </summary>
protected virtual Action BackAction => () => InternalButtons.LastOrDefault()?.TriggerClick();
protected virtual Action BackAction => () =>
{
// We prefer triggering the button click as it will animate...
// but sometimes buttons aren't present (see FailOverlay's constructor as an example).
if (Buttons.Any())
Buttons.Last().TriggerClick();
else
OnQuit?.Invoke();
};
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Select"/> is triggered.

View File

@ -29,7 +29,13 @@ namespace osu.Game.Screens.Play
private SkinnableSound pauseLoop;
protected override Action BackAction => () => InternalButtons.First().TriggerClick();
protected override Action BackAction => () =>
{
if (Buttons.Any())
Buttons.First().TriggerClick();
else
OnResume?.Invoke();
};
[BackgroundDependencyLoader]
private void load(OsuColour colours)