diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs index d69ac665cc..75e8194708 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs @@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay [BackgroundDependencyLoader] private void load(OsuGameBase game) { - Child = globalActionContainer = new GlobalActionContainer(game); + Child = globalActionContainer = new GlobalActionContainer(game, null); } [SetUp] diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 6d038c43cf..ab8a40dbe3 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -13,15 +12,17 @@ namespace osu.Game.Input.Bindings { public class GlobalActionContainer : DatabasedKeyBindingContainer, IHandleGlobalKeyboardInput { + private readonly GlobalInputManager globalInputManager; + private readonly Drawable handler; - public GlobalActionContainer(OsuGameBase game, bool nested = false) + public GlobalActionContainer(OsuGameBase game, GlobalInputManager globalInputManager) : base(matchingMode: KeyCombinationMatchingMode.Modifiers) { + this.globalInputManager = globalInputManager; + if (game is IKeyBindingHandler) handler = game; - - GetInputQueue = () => base.KeyBindingInputQueue.ToArray(); } public override IEnumerable DefaultKeyBindings => GlobalKeyBindings.Concat(InGameKeyBindings).Concat(AudioControlKeyBindings).Concat(EditorKeyBindings); @@ -94,10 +95,15 @@ namespace osu.Game.Input.Bindings new KeyBinding(InputKey.F3, GlobalAction.MusicPlay) }; - public Func GetInputQueue { get; set; } + protected override IEnumerable KeyBindingInputQueue + { + get + { + var inputQueue = globalInputManager?.NonPositionalInputQueue ?? base.KeyBindingInputQueue; - protected override IEnumerable KeyBindingInputQueue => - handler == null ? GetInputQueue() : GetInputQueue().Prepend(handler); + return handler != null ? inputQueue.Prepend(handler) : inputQueue; + } + } } public enum GlobalAction diff --git a/osu.Game/Input/Bindings/GlobalInputManager.cs b/osu.Game/Input/Bindings/GlobalInputManager.cs index 475397408a..91373712fb 100644 --- a/osu.Game/Input/Bindings/GlobalInputManager.cs +++ b/osu.Game/Input/Bindings/GlobalInputManager.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; @@ -23,10 +22,7 @@ namespace osu.Game.Input.Bindings RelativeSizeAxes = Axes.Both, }, // to avoid positional input being blocked by children, ensure the GlobalActionContainer is above everything. - GlobalBindings = new GlobalActionContainer(game, true) - { - GetInputQueue = () => NonPositionalInputQueue.ToArray() - }, + GlobalBindings = new GlobalActionContainer(game, this) }; } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 5fa315a464..809e5d3c1b 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -27,7 +27,6 @@ using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; using osu.Framework.Input.Bindings; -using osu.Framework.Input.Events; using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Collections; diff --git a/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs b/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs index 64f4d7b95b..b3073c8bea 100644 --- a/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs +++ b/osu.Game/Tests/Visual/OsuManualInputManagerTestScene.cs @@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual InputManager = new ManualInputManager { UseParentInput = true, - Child = new GlobalActionContainer(null) + Child = new GlobalActionContainer(null, null) .WithChild((cursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }) .WithChild(content = new OsuTooltipContainer(cursorContainer.Cursor) { RelativeSizeAxes = Axes.Both })) },