From b7a2ad1aa5980dc8e6fd49f8b990121babf98559 Mon Sep 17 00:00:00 2001 From: ekrctb Date: Tue, 2 Oct 2018 12:44:14 +0900 Subject: [PATCH] Use UIEvent level getters for modifier keys. --- osu.Game/Graphics/Cursor/MenuCursor.cs | 2 +- osu.Game/Graphics/UserInterface/SearchTextBox.cs | 5 ++--- osu.Game/Overlays/ChatOverlay.cs | 1 - osu.Game/Overlays/Direct/DirectGridPanel.cs | 2 +- osu.Game/Overlays/KeyBinding/KeyBindingRow.cs | 4 ++-- osu.Game/Overlays/MedalOverlay.cs | 2 +- osu.Game/Overlays/Mods/ModSection.cs | 2 +- osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs | 2 +- osu.Game/Rulesets/UI/RulesetInputManager.cs | 2 +- osu.Game/Screens/Menu/Button.cs | 3 +-- osu.Game/Screens/Menu/MainMenu.cs | 3 +-- osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs | 2 +- osu.Game/Screens/Play/HUD/QuitButton.cs | 2 +- osu.Game/Screens/Play/HUDOverlay.cs | 2 +- osu.Game/Screens/Play/SkipOverlay.cs | 2 +- osu.Game/Screens/Select/SongSelect.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 17 files changed, 18 insertions(+), 22 deletions(-) diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 6bd3b986c8..ba858bf52d 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -90,7 +90,7 @@ namespace osu.Game.Graphics.Cursor protected override bool OnMouseUp(MouseUpEvent e) { - if (!e.CurrentState.Mouse.HasMainButtonPressed) + if (!e.IsPressed(MouseButton.Left) && !e.IsPressed(MouseButton.Right)) { activeCursor.AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint); activeCursor.ScaleTo(1, 500, Easing.OutElastic); diff --git a/osu.Game/Graphics/UserInterface/SearchTextBox.cs b/osu.Game/Graphics/UserInterface/SearchTextBox.cs index 67ee35df04..08e93fad18 100644 --- a/osu.Game/Graphics/UserInterface/SearchTextBox.cs +++ b/osu.Game/Graphics/UserInterface/SearchTextBox.cs @@ -34,8 +34,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnKeyDown(KeyDownEvent e) { - var keyboard = e.CurrentState.Keyboard; - if (!keyboard.ControlPressed && !keyboard.ShiftPressed) + if (!e.ControlPressed && !e.ShiftPressed) { switch (e.Key) { @@ -57,7 +56,7 @@ namespace osu.Game.Graphics.UserInterface } } - if (keyboard.ShiftPressed) + if (e.ShiftPressed) { switch (e.Key) { diff --git a/osu.Game/Overlays/ChatOverlay.cs b/osu.Game/Overlays/ChatOverlay.cs index 5312207e4e..4832c85e74 100644 --- a/osu.Game/Overlays/ChatOverlay.cs +++ b/osu.Game/Overlays/ChatOverlay.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using OpenTK; using OpenTK.Graphics; diff --git a/osu.Game/Overlays/Direct/DirectGridPanel.cs b/osu.Game/Overlays/Direct/DirectGridPanel.cs index 6eef2fc500..1c462e3a73 100644 --- a/osu.Game/Overlays/Direct/DirectGridPanel.cs +++ b/osu.Game/Overlays/Direct/DirectGridPanel.cs @@ -10,7 +10,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Framework.Graphics.Shapes; -using osu.Framework.Input.States; +using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index 87325c69aa..63ddc25fde 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -171,7 +171,7 @@ namespace osu.Game.Overlays.KeyBinding protected override bool OnMouseUp(MouseUpEvent e) { // don't do anything until the last button is released. - if (!HasFocus || e.CurrentState.Mouse.HasAnyButtonPressed) + if (!HasFocus || e.HasAnyButtonPressed) return base.OnMouseUp(e); if (bindTarget.IsHovered) @@ -205,7 +205,7 @@ namespace osu.Game.Overlays.KeyBinding { case Key.Delete: { - if (e.CurrentState.Keyboard.ShiftPressed) + if (e.ShiftPressed) { bindTarget.UpdateKeyCombination(InputKey.None); finalise(); diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 13c01cb88f..dcd325490a 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -183,7 +183,7 @@ namespace osu.Game.Overlays protected override void OnFocusLost(FocusLostEvent e) { - if (e.CurrentState.Keyboard.IsPressed(Key.Escape)) dismiss(); + if (e.CurrentState.Keyboard.Keys.IsPressed(Key.Escape)) dismiss(); } private const double initial_duration = 400; diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index 4759325bc4..c0d2d889c6 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Mods { var index = Array.IndexOf(ToggleKeys, e.Key); if (index > -1 && index < buttons.Length) - buttons[index].SelectNext(e.CurrentState.Keyboard.ShiftPressed ? -1 : 1); + buttons[index].SelectNext(e.ShiftPressed ? -1 : 1); } return base.OnKeyDown(e); diff --git a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs index 167d163d8b..7470dd0cd5 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs @@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Toolbar { base.OnKeyDown(e); - if (e.CurrentState.Keyboard.ControlPressed && !e.Repeat && e.Key >= Key.Number1 && e.Key <= Key.Number9) + if (e.ControlPressed && !e.Repeat && e.Key >= Key.Number1 && e.Key <= Key.Number9) { int requested = e.Key - Key.Number1; diff --git a/osu.Game/Rulesets/UI/RulesetInputManager.cs b/osu.Game/Rulesets/UI/RulesetInputManager.cs index fc6f82544e..b0c75a4990 100644 --- a/osu.Game/Rulesets/UI/RulesetInputManager.cs +++ b/osu.Game/Rulesets/UI/RulesetInputManager.cs @@ -8,7 +8,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Framework.Input.Bindings; -using osu.Framework.Input.EventArgs; +using osu.Framework.Input.Events; using osu.Framework.Input.StateChanges.Events; using osu.Framework.Input.States; using osu.Framework.Timing; diff --git a/osu.Game/Screens/Menu/Button.cs b/osu.Game/Screens/Menu/Button.cs index 83d8ef12b8..2b85ee6158 100644 --- a/osu.Game/Screens/Menu/Button.cs +++ b/osu.Game/Screens/Menu/Button.cs @@ -205,8 +205,7 @@ namespace osu.Game.Screens.Menu protected override bool OnKeyDown(KeyDownEvent e) { - var keyboard = e.CurrentState.Keyboard; - if (e.Repeat || keyboard.ControlPressed || keyboard.ShiftPressed || keyboard.AltPressed) + if (e.Repeat || e.ControlPressed || e.ShiftPressed || e.AltPressed) return false; if (triggerKey == e.Key && triggerKey != Key.Unknown) diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 531ce85d4d..2374d6a2fe 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -201,8 +201,7 @@ namespace osu.Game.Screens.Menu protected override bool OnKeyDown(KeyDownEvent e) { - var keyboard = e.CurrentState.Keyboard; - if (!e.Repeat && keyboard.ControlPressed && keyboard.ShiftPressed && e.Key == Key.D) + if (!e.Repeat && e.ControlPressed && e.ShiftPressed && e.Key == Key.D) { Push(new Drawings()); return true; diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index 1ce557f70f..debce8c680 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Play.HUD { if (e.Repeat) return false; - if (e.CurrentState.Keyboard.ControlPressed) + if (e.ControlPressed) { if (e.Key == Key.H && ReplayLoaded) { diff --git a/osu.Game/Screens/Play/HUD/QuitButton.cs b/osu.Game/Screens/Play/HUD/QuitButton.cs index 347238f1d6..88547e0169 100644 --- a/osu.Game/Screens/Play/HUD/QuitButton.cs +++ b/osu.Game/Screens/Play/HUD/QuitButton.cs @@ -190,7 +190,7 @@ namespace osu.Game.Screens.Play.HUD protected override bool OnMouseUp(MouseUpEvent e) { - if (!e.CurrentState.Mouse.Buttons.Any()) + if (!e.HasAnyButtonPressed) AbortConfirm(); return true; } diff --git a/osu.Game/Screens/Play/HUDOverlay.cs b/osu.Game/Screens/Play/HUDOverlay.cs index aa4d6c039b..db0d7b6ccc 100644 --- a/osu.Game/Screens/Play/HUDOverlay.cs +++ b/osu.Game/Screens/Play/HUDOverlay.cs @@ -155,7 +155,7 @@ namespace osu.Game.Screens.Play { if (e.Repeat) return false; - if (e.CurrentState.Keyboard.ShiftPressed) + if (e.ShiftPressed) { switch (e.Key) { diff --git a/osu.Game/Screens/Play/SkipOverlay.cs b/osu.Game/Screens/Play/SkipOverlay.cs index 68bd5f7d00..cd34623951 100644 --- a/osu.Game/Screens/Play/SkipOverlay.cs +++ b/osu.Game/Screens/Play/SkipOverlay.cs @@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play protected override bool OnMouseMove(MouseMoveEvent e) { - if (!e.CurrentState.Mouse.HasAnyButtonPressed) + if (!e.HasAnyButtonPressed) fadeContainer.State = Visibility.Visible; return base.OnMouseMove(e); } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index 6195a9788c..7402cf4da0 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -560,7 +560,7 @@ namespace osu.Game.Screens.Select switch (e.Key) { case Key.Delete: - if (e.CurrentState.Keyboard.ShiftPressed) + if (e.ShiftPressed) { if (!Beatmap.IsDefault) delete(Beatmap.Value.BeatmapSetInfo); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 5704efd5a0..48400084ca 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -18,7 +18,7 @@ - +