From b6fd5b0f17ca5e3f0c6fd8bbf35359eb171ccc60 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Dec 2017 13:58:24 +0900 Subject: [PATCH] Fix keyboard and mouse input not properly getting blocked by GameplayMenuOverlay --- .../Bindings/GlobalKeyBindingInputManager.cs | 3 +- osu.Game/Screens/Play/GameplayMenuOverlay.cs | 37 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs b/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs index 759396e195..745508ec9e 100644 --- a/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs +++ b/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs @@ -5,11 +5,12 @@ using System.ComponentModel; using System.Linq; using osu.Framework.Graphics; +using osu.Framework.Input; using osu.Framework.Input.Bindings; namespace osu.Game.Input.Bindings { - public class GlobalKeyBindingInputManager : DatabasedKeyBindingInputManager + public class GlobalKeyBindingInputManager : DatabasedKeyBindingInputManager, IHandleGlobalInput { private readonly Drawable handler; diff --git a/osu.Game/Screens/Play/GameplayMenuOverlay.cs b/osu.Game/Screens/Play/GameplayMenuOverlay.cs index 182c4efe89..e49ebb5590 100644 --- a/osu.Game/Screens/Play/GameplayMenuOverlay.cs +++ b/osu.Game/Screens/Play/GameplayMenuOverlay.cs @@ -26,6 +26,8 @@ public abstract class GameplayMenuOverlay : OverlayContainer, IRequireHighFreque protected override bool BlockPassThroughKeyboard => true; + public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true; + public Action OnRetry; public Action OnQuit; @@ -197,6 +199,7 @@ protected void AddButton(string text, Color4 colour, Action action) } private int _selectionIndex = -1; + private int selectionIndex { get { return _selectionIndex; } @@ -219,26 +222,26 @@ private int selectionIndex protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) { - if (args.Repeat) - return false; - - switch (args.Key) + if (!args.Repeat) { - case Key.Up: - if (selectionIndex == -1 || selectionIndex == 0) - selectionIndex = InternalButtons.Count - 1; - else - selectionIndex--; - return true; - case Key.Down: - if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1) - selectionIndex = 0; - else - selectionIndex++; - return true; + switch (args.Key) + { + case Key.Up: + if (selectionIndex == -1 || selectionIndex == 0) + selectionIndex = InternalButtons.Count - 1; + else + selectionIndex--; + return true; + case Key.Down: + if (selectionIndex == -1 || selectionIndex == InternalButtons.Count - 1) + selectionIndex = 0; + else + selectionIndex++; + return true; + } } - return false; + return base.OnKeyDown(state, args); } private void buttonSelectionChanged(DialogButton button, bool isSelected)