From 47b4ef5cd2c00034353f227d33bbc42159d8059f Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 24 Jul 2017 21:55:12 +0800 Subject: [PATCH] Handle control key with OnKeyUp/OnKeyDown. --- osu.Game/Screens/Select/PlaySongSelect.cs | 20 +++++++++++++++----- osu.Game/Screens/Select/SongSelect.cs | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 6f85f541e7..d68e96f2fc 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -22,10 +22,10 @@ namespace osu.Game.Screens.Select public class PlaySongSelect : SongSelect { private OsuScreen player; - private UserInputManager input; private readonly ModSelectOverlay modSelect; private readonly BeatmapDetailArea beatmapDetails; private IEnumerable originalMods; + private bool controlPressed; public PlaySongSelect() { @@ -46,10 +46,8 @@ namespace osu.Game.Screens.Select } [BackgroundDependencyLoader] - private void load(OsuColour colours, UserInputManager input) + private void load(OsuColour colours) { - this.input = input; - Footer.AddButton(@"mods", colours.Yellow, modSelect.ToggleVisibility, Key.F1, float.MaxValue); BeatmapOptions.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, colours.Purple, null, Key.Number1); @@ -111,12 +109,24 @@ namespace osu.Game.Screens.Select return false; } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + controlPressed = state.Keyboard.ControlPressed; + return base.OnKeyDown(state, args); + } + + protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + { + controlPressed = state.Keyboard.ControlPressed; + return base.OnKeyUp(state, args); + } + protected override void OnSelected() { if (player != null) return; originalMods = modSelect.SelectedMods.Value; - if (input.CurrentState.Keyboard.ControlPressed) + if (controlPressed) if (findAutoMod(originalMods) == null) { var auto = findAutoMod(Ruleset.Value.CreateInstance().GetModsFor(ModType.Special)); diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 867b1e60c0..2879cd1ab1 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -9,7 +9,6 @@ using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Audio.Track; -using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input;