1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 18:12:56 +08:00

Merge pull request #18145 from peppy/simplify-hide-logic

Simplify and centralise hiding logic for mod overlay
This commit is contained in:
Bartłomiej Dach 2022-05-08 10:26:57 +02:00 committed by GitHub
commit 4199bab1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -393,30 +393,38 @@ namespace osu.Game.Overlays.Mods
if (e.Repeat)
return false;
// This is handled locally here because this overlay is being registered at the game level
// and therefore takes away keyboard focus from the screen stack.
if (e.Action == GlobalAction.Back)
{
if (customisationVisible.Value)
customisationVisible.Value = false;
else
backButton.TriggerClick();
return true;
}
switch (e.Action)
{
case GlobalAction.Back:
// Pressing the back binding should only go back one step at a time.
hideOverlay(false);
return true;
// This is handled locally here because this overlay is being registered at the game level
// and therefore takes away keyboard focus from the screen stack.
case GlobalAction.ToggleModSelection:
case GlobalAction.Select:
{
if (customisationVisible.Value)
customisationVisible.Value = false;
Hide();
// Pressing toggle or select should completely hide the overlay in one shot.
hideOverlay(true);
return true;
}
}
default:
return base.OnPressed(e);
return base.OnPressed(e);
void hideOverlay(bool immediate)
{
if (customisationVisible.Value)
{
Debug.Assert(customisationButton != null);
customisationButton.TriggerClick();
if (!immediate)
return;
}
backButton.TriggerClick();
}
}