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

Fix mod overlay not closing on toggle hotkey

This commit is contained in:
Bartłomiej Dach 2022-05-05 21:22:07 +02:00
parent 8f65e0e60f
commit 34cf4c6a38
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 27 additions and 1 deletions

View File

@ -20,6 +20,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Select;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
@ -44,6 +45,15 @@ namespace osu.Game.Overlays.Mods
} }
} }
/// <summary>
/// Hotkey that should be used to hide the mod select screen.
/// </summary>
/// <remarks>
/// This is handled locally here rather than via <see cref="FooterButtonMods"/>, because this overlay is being registered at the game level
/// and therefore takes away keyboard focus from the screen stack.
/// </remarks>
internal GlobalAction? Hotkey { get; set; }
/// <summary> /// <summary>
/// Whether configurable <see cref="Mod"/>s can be configured by the local user. /// Whether configurable <see cref="Mod"/>s can be configured by the local user.
/// </summary> /// </summary>
@ -321,12 +331,23 @@ namespace osu.Game.Overlays.Mods
public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public override bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
if (e.Repeat)
return false;
if (e.Action == GlobalAction.Back && customisationVisible.Value) if (e.Action == GlobalAction.Back && customisationVisible.Value)
{ {
customisationVisible.Value = false; customisationVisible.Value = false;
return true; return true;
} }
if (e.Action == Hotkey)
{
if (customisationVisible.Value)
customisationVisible.Value = false;
Hide();
return true;
}
return base.OnPressed(e); return base.OnPressed(e);
} }

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Input.Bindings;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Overlays; using osu.Game.Overlays;
@ -162,6 +163,7 @@ namespace osu.Game.Screens.OnlinePlay
protected override ModSelectScreen CreateModSelectOverlay() => new UserModSelectScreen(OverlayColourScheme.Plum) protected override ModSelectScreen CreateModSelectOverlay() => new UserModSelectScreen(OverlayColourScheme.Plum)
{ {
Hotkey = GlobalAction.ToggleModSelection,
IsValidMod = IsValidMod IsValidMod = IsValidMod
}; };

View File

@ -333,7 +333,10 @@ namespace osu.Game.Screens.Select
(new FooterButtonOptions(), BeatmapOptions) (new FooterButtonOptions(), BeatmapOptions)
}; };
protected virtual ModSelectScreen CreateModSelectOverlay() => new UserModSelectScreen(); protected virtual ModSelectScreen CreateModSelectOverlay() => new UserModSelectScreen
{
Hotkey = GlobalAction.ToggleModSelection
};
protected virtual void ApplyFilterToCarousel(FilterCriteria criteria) protected virtual void ApplyFilterToCarousel(FilterCriteria criteria)
{ {