diff --git a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs index 39369350ef..d6bc4a2095 100644 --- a/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs +++ b/osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs @@ -67,7 +67,7 @@ protected override bool OnClick(InputState state) return base.OnClick(state); } - public bool OnPressed(GlobalAction action) + public virtual bool OnPressed(GlobalAction action) { if (action == GlobalAction.Back) { diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 83ffd415ae..b21deff509 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -39,7 +39,10 @@ public GlobalActionContainer(OsuGameBase game) new KeyBinding(InputKey.F4, GlobalAction.ToggleMute), new KeyBinding(InputKey.Escape, GlobalAction.Back), - new KeyBinding(InputKey.MouseButton1, GlobalAction.Back) + new KeyBinding(InputKey.MouseButton1, GlobalAction.Back), + + new KeyBinding(InputKey.Space, GlobalAction.Select), + new KeyBinding(InputKey.Enter, GlobalAction.Select), }; public IEnumerable InGameKeyBindings => new[] @@ -86,7 +89,7 @@ public enum GlobalAction [Description("Toggle gameplay mouse buttons")] ToggleGameplayMouseButtons, - [Description("Go back")] + [Description("Back")] Back, [Description("Increase scroll speed")] @@ -94,5 +97,8 @@ public enum GlobalAction [Description("Decrease scroll speed")] DecreaseScrollSpeed, + + [Description("Select")] + Select, } } diff --git a/osu.Game/Overlays/Dialog/PopupDialog.cs b/osu.Game/Overlays/Dialog/PopupDialog.cs index d90a850f4a..636cffac89 100644 --- a/osu.Game/Overlays/Dialog/PopupDialog.cs +++ b/osu.Game/Overlays/Dialog/PopupDialog.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Input.Bindings; using OpenTK; using OpenTK.Graphics; using OpenTK.Input; @@ -192,16 +193,22 @@ public PopupDialog() }; } + public override bool OnPressed(GlobalAction action) + { + switch (action) + { + case GlobalAction.Select: + Buttons.OfType().FirstOrDefault()?.TriggerOnClick(); + return true; + } + + return base.OnPressed(action); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false; - if (args.Key == Key.Enter || args.Key == Key.KeypadEnter) - { - Buttons.OfType().FirstOrDefault()?.TriggerOnClick(); - return true; - } - // press button at number if 1-9 on number row or keypad are pressed var k = args.Key; if (k >= Key.Number1 && k <= Key.Number9) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index 374877673f..762f826425 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Threading; using osu.Game.Graphics; @@ -139,26 +138,15 @@ private void load(AudioManager audio, OsuGame game) sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) - { - if (args.Repeat) return false; - - switch (args.Key) - { - case Key.Space: - logo?.TriggerOnClick(state); - return true; - } - - return false; - } - public bool OnPressed(GlobalAction action) { switch (action) { case GlobalAction.Back: return goBack(); + case GlobalAction.Select: + logo?.TriggerOnClick(); + return true; default: return false; } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 2a7daff3d0..4b893f0118 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -101,7 +101,7 @@ private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bind sampleExit = audio.Sample.Get(@"UI/screen-back"); } - public bool OnPressed(GlobalAction action) + public virtual bool OnPressed(GlobalAction action) { if (!IsCurrentScreen) return false; diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 94c16f1797..9c62f92311 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -17,6 +17,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Containers; +using osu.Game.Input.Bindings; using osu.Game.Overlays; using osu.Game.Rulesets; using osu.Game.Screens.Backgrounds; @@ -67,6 +68,7 @@ public abstract class SongSelect : OsuScreen protected new readonly Bindable Ruleset = new Bindable(); private DependencyContainer dependencies; + protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(base.CreateLocalDependencies(parent)); @@ -464,7 +466,8 @@ private void ensurePlayingSelected(bool preview = false) private void carouselBeatmapsLoaded() { - if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false && Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false)) + if (!Beatmap.IsDefault && Beatmap.Value.BeatmapSetInfo?.DeletePending == false && Beatmap.Value.BeatmapSetInfo?.Protected == false + && Carousel.SelectBeatmap(Beatmap.Value.BeatmapInfo, false)) return; if (Carousel.SelectedBeatmapSet == null && !Carousel.SelectNextRandom()) @@ -481,16 +484,26 @@ private void delete(BeatmapSetInfo beatmap) dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap)); } + public override bool OnPressed(GlobalAction action) + { + if (!IsCurrentScreen) return false; + + switch (action) + { + case GlobalAction.Select: + FinaliseSelection(); + return true; + } + + return base.OnPressed(action); + } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { if (args.Repeat) return false; switch (args.Key) { - case Key.KeypadEnter: - case Key.Enter: - FinaliseSelection(); - return true; case Key.Delete: if (state.Keyboard.ShiftPressed) {