From f22d0fa1b4e4ba922fbb928363d576515655fdac Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jun 2019 13:33:51 +0900 Subject: [PATCH 1/3] Update test case for dynamic compilation and corret naming --- ...iguration.cs => TestSceneKeyBindingPanel.cs} | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) rename osu.Game.Tests/Visual/Settings/{TestSceneKeyConfiguration.cs => TestSceneKeyBindingPanel.cs} (50%) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneKeyConfiguration.cs b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs similarity index 50% rename from osu.Game.Tests/Visual/Settings/TestSceneKeyConfiguration.cs rename to osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs index d06d82ddb5..426ff988c4 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneKeyConfiguration.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs @@ -1,17 +1,30 @@ // 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 NUnit.Framework; using osu.Game.Overlays; +using osu.Game.Overlays.KeyBinding; namespace osu.Game.Tests.Visual.Settings { [TestFixture] - public class TestSceneKeyConfiguration : OsuTestScene + public class TestSceneKeyBindingPanel : OsuTestScene { private readonly KeyBindingPanel panel; - public TestSceneKeyConfiguration() + public override IReadOnlyList RequiredTypes => new[] + { + typeof(KeyBindingRow), + typeof(GlobalKeyBindingsSection), + typeof(KeyBindingRow), + typeof(KeyBindingsSubsection), + typeof(RulesetBindingsSection), + typeof(VariantBindingsSubsection), + }; + + public TestSceneKeyBindingPanel() { Child = panel = new KeyBindingPanel(); } From a6e5c6a62a6868f30b2d5ee58922f0b564d0955b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jun 2019 13:50:05 +0900 Subject: [PATCH 2/3] Add cancel/clear buttons in place of instructional text --- osu.Game/Overlays/KeyBinding/KeyBindingRow.cs | 73 ++++++++++++------- .../KeyBinding/KeyBindingsSubsection.cs | 2 +- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index 9a707adaea..f0adc3d95f 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -13,9 +13,10 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Graphics; -using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; using osu.Game.Input; +using osuTK; using osuTK.Graphics; using osuTK.Input; @@ -47,7 +48,7 @@ namespace osu.Game.Overlays.KeyBinding public bool FilteringActive { get; set; } private OsuSpriteText text; - private OsuTextFlowContainer pressAKey; + private Drawable pressAKey; private FillFlowContainer buttons; @@ -80,7 +81,7 @@ namespace osu.Game.Overlays.KeyBinding Hollow = true, }; - Children = new Drawable[] + Children = new[] { new Box { @@ -99,15 +100,19 @@ namespace osu.Game.Overlays.KeyBinding Anchor = Anchor.TopRight, Origin = Anchor.TopRight }, - pressAKey = new OsuTextFlowContainer + pressAKey = new FillFlowContainer { - Text = "Press a key to change binding, Shift+Delete to delete, Escape to cancel.", - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Margin = new MarginPadding(padding), - Padding = new MarginPadding { Top = height }, + AutoSizeAxes = Axes.Both, + Padding = new MarginPadding(padding) { Top = height + padding * 2 }, + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, Alpha = 0, - Colour = colours.YellowDark + Spacing = new Vector2(5), + Children = new Drawable[] + { + new CancelButton { Action = finalise }, + new ClearButton { Action = clear }, + }, } }; @@ -205,21 +210,6 @@ namespace osu.Game.Overlays.KeyBinding if (!HasFocus) return false; - switch (e.Key) - { - case Key.Delete: - { - if (e.ShiftPressed) - { - bindTarget.UpdateKeyCombination(InputKey.None); - finalise(); - return true; - } - - break; - } - } - bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(e.CurrentState)); if (!isModifier(e.Key)) finalise(); @@ -254,6 +244,12 @@ namespace osu.Game.Overlays.KeyBinding return true; } + private void clear() + { + bindTarget.UpdateKeyCombination(InputKey.None); + finalise(); + } + private void finalise() { if (bindTarget != null) @@ -300,6 +296,33 @@ namespace osu.Game.Overlays.KeyBinding if (bindTarget != null) bindTarget.IsBinding = true; } + private class CancelButton : TriangleButton + { + public CancelButton() + { + Text = "Cancel"; + Size = new Vector2(80, 20); + } + } + + private class ClearButton : TriangleButton + { + public ClearButton() + { + Text = "Clear"; + Size = new Vector2(80, 20); + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + BackgroundColour = colours.Pink; + + Triangles.ColourDark = colours.PinkDark; + Triangles.ColourLight = colours.PinkLight; + } + } + private class KeyButton : Container { public readonly Framework.Input.Bindings.KeyBinding KeyBinding; diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs b/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs index 08288516e3..d784b7aec9 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs @@ -60,7 +60,7 @@ namespace osu.Game.Overlays.KeyBinding [BackgroundDependencyLoader] private void load(OsuColour colours) { - Text = "Reset"; + Text = "Reset all bindings in section"; RelativeSizeAxes = Axes.X; Margin = new MarginPadding { Top = 5 }; Height = 20; From 666d5744cdeb6f0cf186adaaaaf854de61569fbc Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 21 Jun 2019 14:43:00 +0900 Subject: [PATCH 3/3] Fix unbinding not working correctly --- osu.Game/Overlays/KeyBinding/KeyBindingRow.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs index f0adc3d95f..8317951c8a 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingRow.cs @@ -313,6 +313,14 @@ namespace osu.Game.Overlays.KeyBinding Size = new Vector2(80, 20); } + protected override bool OnMouseUp(MouseUpEvent e) + { + base.OnMouseUp(e); + + // without this, the mouse up triggers a finalise (and deselection) of the current binding target. + return true; + } + [BackgroundDependencyLoader] private void load(OsuColour colours) {