From e0dab3490f09e711b92a61ee7d12390b6df970ed Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Thu, 16 Feb 2017 19:00:18 -0400 Subject: [PATCH] Added toggling mods with keys --- osu.Game/Overlays/Mods/AssistedSection.cs | 12 ++++++++++++ osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs | 6 ++++++ osu.Game/Overlays/Mods/DifficultyReductionSection.cs | 4 ++++ osu.Game/Overlays/Mods/ModButton.cs | 12 ++++++++++++ 4 files changed, 34 insertions(+) diff --git a/osu.Game/Overlays/Mods/AssistedSection.cs b/osu.Game/Overlays/Mods/AssistedSection.cs index c521344e7c..4b843ed2dc 100644 --- a/osu.Game/Overlays/Mods/AssistedSection.cs +++ b/osu.Game/Overlays/Mods/AssistedSection.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; using osu.Game.Modes; @@ -98,6 +99,7 @@ namespace osu.Game { relaxButton = new ModButton { + ToggleKey = Key.Z, Mods = new Mod[] { new ModRelax(), @@ -105,6 +107,7 @@ namespace osu.Game }, autopilotButton = new ModButton { + ToggleKey = Key.X, Mods = new Mod[] { new ModAutopilot(), @@ -112,6 +115,7 @@ namespace osu.Game }, targetPracticeButton = new ModButton { + ToggleKey = Key.C, Mods = new Mod[] { new ModTarget(), @@ -119,6 +123,7 @@ namespace osu.Game }, spunOutButton = new ModButton { + ToggleKey = Key.V, Mods = new Mod[] { new ModSpunOut(), @@ -126,6 +131,7 @@ namespace osu.Game }, autoplayCinemaButton = new ModButton { + ToggleKey = Key.B, Mods = new Mod[] { new ModAutoplay(), @@ -141,6 +147,7 @@ namespace osu.Game { relaxButton = new ModButton { + ToggleKey = Key.Z, Mods = new Mod[] { new ModRelax(), @@ -148,6 +155,7 @@ namespace osu.Game }, autoplayCinemaButton = new ModButton { + ToggleKey = Key.X, Mods = new Mod[] { new ModAutoplay(), @@ -162,6 +170,7 @@ namespace osu.Game { keyButton = new ModButton { + ToggleKey = Key.Z, Mods = new Mod[] { new ModKey4(), @@ -177,6 +186,7 @@ namespace osu.Game }, coopButton = new ModButton { + ToggleKey = Key.X, Mods = new Mod[] { new ModKeyCoop(), @@ -184,6 +194,7 @@ namespace osu.Game }, randomButton = new ModButton { + ToggleKey = Key.C, Mods = new Mod[] { new ModRandom(), @@ -191,6 +202,7 @@ namespace osu.Game }, autoplayCinemaButton = new ModButton { + ToggleKey = Key.V, Mods = new Mod[] { new ModAutoplay(), diff --git a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs index b9884a311c..8df6d1ddd6 100644 --- a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; using osu.Game.Modes; @@ -29,6 +30,7 @@ namespace osu.Game { new ModButton { + ToggleKey = Key.A, Mods = new Mod[] { new ModHardRock(), @@ -36,6 +38,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.S, Mods = new Mod[] { new ModSuddenDeath(), @@ -44,6 +47,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.D, Mods = new Mod[] { new ModDoubleTime(), @@ -52,6 +56,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.F, Mods = new Mod[] { new ModHidden(), @@ -59,6 +64,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.G, Mods = new Mod[] { new ModFlashlight(), diff --git a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs index 810f40502b..c4e1e81b5c 100644 --- a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; using osu.Game.Modes; @@ -27,6 +28,7 @@ namespace osu.Game { new ModButton { + ToggleKey = Key.Q, Mods = new Mod[] { new ModEasy(), @@ -34,6 +36,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.W, Mods = new Mod[] { new ModNoFail(), @@ -41,6 +44,7 @@ namespace osu.Game }, new ModButton { + ToggleKey = Key.E, Mods = new Mod[] { new ModHalfTime(), diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 545ea16df3..5f8bda03e8 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -27,6 +27,7 @@ namespace osu.Game.Overlays.Mods private AudioSample sampleOn, sampleOff; public Action Action; // Passed the selected mod or null if none + public Key ToggleKey; private int _selectedMod = -1; private int selectedMod @@ -216,6 +217,17 @@ namespace osu.Game.Overlays.Mods } } + protected override bool OnKeyDown(Framework.Input.InputState state, KeyDownEventArgs args) + { + if (args.Key == ToggleKey) + { + SelectNext(); + return true; + } + + return base.OnKeyDown(state, args); + } + public ModButton() { Direction = FlowDirections.Vertical;