From d9e36237c77db26f5a189042af299449400fc9f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 10 Aug 2017 16:45:10 +0900 Subject: [PATCH] Move all OsuGame events to OsuAction --- .../Input/GlobalActionMappingInputManager.cs | 4 +++ osu.Game/Input/KeyCombination.cs | 2 ++ osu.Game/Input/OsuAction.cs | 6 +++- osu.Game/OsuGame.cs | 35 ++++++------------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/osu.Game/Input/GlobalActionMappingInputManager.cs b/osu.Game/Input/GlobalActionMappingInputManager.cs index cd601ac944..250640422d 100644 --- a/osu.Game/Input/GlobalActionMappingInputManager.cs +++ b/osu.Game/Input/GlobalActionMappingInputManager.cs @@ -12,6 +12,10 @@ namespace osu.Game.Input { { Key.F8, OsuAction.ToggleChat }, { Key.F9, OsuAction.ToggleSocial }, + { new[] { Key.LControl, Key.LAlt, Key.R }, OsuAction.ResetInputSettings }, + { new[] { Key.LControl, Key.T }, OsuAction.ToggleToolbar }, + { new[] { Key.LControl, Key.O }, OsuAction.ToggleSettings }, + { new[] { Key.LControl, Key.D }, OsuAction.ToggleDirect }, }; } } diff --git a/osu.Game/Input/KeyCombination.cs b/osu.Game/Input/KeyCombination.cs index ef1d578dee..67966b8935 100644 --- a/osu.Game/Input/KeyCombination.cs +++ b/osu.Game/Input/KeyCombination.cs @@ -53,6 +53,8 @@ namespace osu.Game.Input public static implicit operator KeyCombination(string stringRepresentation) => new KeyCombination(stringRepresentation); + public static implicit operator KeyCombination(Key[] keys) => new KeyCombination(keys); + public override string ToString() => Keys.Select(k => ((int)k).ToString()).Aggregate((s1, s2) => $"{s1},{s2}"); } } \ No newline at end of file diff --git a/osu.Game/Input/OsuAction.cs b/osu.Game/Input/OsuAction.cs index 8e956746ed..c80f212df8 100644 --- a/osu.Game/Input/OsuAction.cs +++ b/osu.Game/Input/OsuAction.cs @@ -6,6 +6,10 @@ namespace osu.Game.Input public enum OsuAction { ToggleChat, - ToggleSocial + ToggleSocial, + ResetInputSettings, + ToggleToolbar, + ToggleSettings, + ToggleDirect } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 27d3fb601c..d9321654f7 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Overlays; using osu.Framework.Input; -using OpenTK.Input; using osu.Framework.Logging; using osu.Game.Graphics.UserInterface.Volume; using osu.Framework.Allocation; @@ -266,36 +265,22 @@ namespace osu.Game case OsuAction.ToggleSocial: social.ToggleVisibility(); return true; - } - } + case OsuAction.ResetInputSettings: + var sensitivity = frameworkConfig.GetBindable(FrameworkSetting.CursorSensitivity); - if (state.Keyboard.ControlPressed) - { - switch (args.Key) - { - case Key.R: - if (state.Keyboard.AltPressed) - { - var sensitivity = frameworkConfig.GetBindable(FrameworkSetting.CursorSensitivity); + sensitivity.Disabled = false; + sensitivity.Value = 1; + sensitivity.Disabled = true; - sensitivity.Disabled = false; - sensitivity.Value = 1; - sensitivity.Disabled = true; - - frameworkConfig.Set(FrameworkSetting.ActiveInputHandlers, string.Empty); - return true; - } - break; - case Key.T: + frameworkConfig.Set(FrameworkSetting.ActiveInputHandlers, string.Empty); + return true; + case OsuAction.ToggleToolbar: Toolbar.ToggleVisibility(); return true; - case Key.O: + case OsuAction.ToggleSettings: settings.ToggleVisibility(); return true; - case Key.D: - if (state.Keyboard.ShiftPressed || state.Keyboard.AltPressed) - return false; - + case OsuAction.ToggleDirect: direct.ToggleVisibility(); return true; }