From d4ada3000cb059b1a55ea43c3f348d6a731ed4d9 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 2 May 2018 19:37:47 +0900 Subject: [PATCH 1/6] Add keybind to disable mouse buttons --- osu.Game/Configuration/OsuConfigManager.cs | 6 ++++++ osu.Game/Input/Bindings/GlobalActionContainer.cs | 5 ++++- osu.Game/OsuGame.cs | 3 +++ osu.Game/Overlays/OnScreenDisplay.cs | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 509622c2fe7b..b3082e49de7f 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Configuration; +using osu.Framework.Configuration.Tracking; using osu.Framework.Platform; using osu.Game.Overlays; using osu.Game.Screens.Select; @@ -95,6 +96,11 @@ protected override void InitialiseDefaults() public OsuConfigManager(Storage storage) : base(storage) { } + + public override TrackedSettings CreateTrackedSettings() => new TrackedSettings + { + new TrackedSetting(OsuSetting.MouseDisableButtons, v => new SettingDescription(!v, "gameplay mouse buttons", v ? "disabled" : "enabled")) + }; } public enum OsuSetting diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index dd8f00f6cdc0..44e12be1dd2d 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -26,7 +26,8 @@ public GlobalActionContainer(OsuGameBase game) { new KeyBinding(InputKey.F8, GlobalAction.ToggleChat), new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial), - new KeyBinding(InputKey.F12,GlobalAction.TakeScreenshot), + new KeyBinding(InputKey.F10, GlobalAction.ToggleMouseButtons), + new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot), new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings), new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar), @@ -75,6 +76,8 @@ public enum GlobalAction [Description("Quick Retry (Hold)")] QuickRetry, + [Description("Toggle gameplay mouse buttons")] + ToggleMouseButtons, [Description("Take screenshot")] TakeScreenshot } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d443ed36ae72..d2d47a78a653 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -466,6 +466,9 @@ public bool OnPressed(GlobalAction action) case GlobalAction.ToggleDirect: direct.ToggleVisibility(); return true; + case GlobalAction.ToggleMouseButtons: + LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get(OsuSetting.MouseDisableButtons)); + return true; } return false; diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 3dd088891d73..9882ea01f00f 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -14,6 +14,7 @@ using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; +using osu.Game.Configuration; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays @@ -116,9 +117,10 @@ public OnScreenDisplay() } [BackgroundDependencyLoader] - private void load(FrameworkConfigManager frameworkConfig) + private void load(FrameworkConfigManager frameworkConfig, OsuConfigManager osuConfig) { BeginTracking(this, frameworkConfig); + BeginTracking(this, osuConfig); } private readonly Dictionary<(object, IConfigManager), TrackedSettings> trackedConfigManagers = new Dictionary<(object, IConfigManager), TrackedSettings>(); From 482ae2db87e8cebec289a4b5090282b8a99c4c43 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 2 May 2018 19:42:03 +0900 Subject: [PATCH 2/6] Unify naming --- osu.Game/Input/Bindings/GlobalActionContainer.cs | 4 ++-- osu.Game/OsuGame.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 44e12be1dd2d..2ae895785cc1 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -26,7 +26,7 @@ public GlobalActionContainer(OsuGameBase game) { new KeyBinding(InputKey.F8, GlobalAction.ToggleChat), new KeyBinding(InputKey.F9, GlobalAction.ToggleSocial), - new KeyBinding(InputKey.F10, GlobalAction.ToggleMouseButtons), + new KeyBinding(InputKey.F10, GlobalAction.ToggleGameplayMouseButtons), new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot), new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings), @@ -77,7 +77,7 @@ public enum GlobalAction QuickRetry, [Description("Toggle gameplay mouse buttons")] - ToggleMouseButtons, + ToggleGameplayMouseButtons, [Description("Take screenshot")] TakeScreenshot } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d2d47a78a653..fe5ca4f27840 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -466,7 +466,7 @@ public bool OnPressed(GlobalAction action) case GlobalAction.ToggleDirect: direct.ToggleVisibility(); return true; - case GlobalAction.ToggleMouseButtons: + case GlobalAction.ToggleGameplayMouseButtons: LocalConfig.Set(OsuSetting.MouseDisableButtons, !LocalConfig.Get(OsuSetting.MouseDisableButtons)); return true; } From 9f1efeb19df1d3a9b1c43771ec28c36f0c0ba473 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 7 May 2018 15:41:14 +0900 Subject: [PATCH 3/6] Move keybind to last in enum --- osu.Game/Input/Bindings/GlobalActionContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 2ae895785cc1..1658bb4e79ac 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -76,9 +76,9 @@ public enum GlobalAction [Description("Quick Retry (Hold)")] QuickRetry, + [Description("Take screenshot")] + TakeScreenshot, [Description("Toggle gameplay mouse buttons")] ToggleGameplayMouseButtons, - [Description("Take screenshot")] - TakeScreenshot } } From c03ab9014f1eb2276ec9057bdd1b1a608add5d03 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 10 May 2018 15:49:37 +0900 Subject: [PATCH 4/6] Improve TestCaseOnScreenDisplay Now doesn't rely on framesync. --- .../Visual/TestCaseOnScreenDisplay.cs | 82 +++++++++++++++---- osu.Game/Overlays/OnScreenDisplay.cs | 23 ++++-- 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseOnScreenDisplay.cs b/osu.Game.Tests/Visual/TestCaseOnScreenDisplay.cs index 233c418d4a5a..123c1fe05580 100644 --- a/osu.Game.Tests/Visual/TestCaseOnScreenDisplay.cs +++ b/osu.Game.Tests/Visual/TestCaseOnScreenDisplay.cs @@ -4,6 +4,8 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Configuration.Tracking; +using osu.Framework.Graphics; using osu.Game.Overlays; namespace osu.Game.Tests.Visual @@ -11,36 +13,82 @@ namespace osu.Game.Tests.Visual [TestFixture] public class TestCaseOnScreenDisplay : OsuTestCase { - private FrameworkConfigManager config; - private Bindable frameSyncMode; + [BackgroundDependencyLoader] + private void load() + { + var config = new TestConfigManager(); + + var osd = new TestOnScreenDisplay(); + osd.BeginTracking(this, config); + Add(osd); - protected override void LoadComplete() + AddRepeatStep("Change toggle (no bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingNoKeybind), 2); + AddRepeatStep("Change toggle (with bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingWithKeybind), 2); + AddRepeatStep("Change enum (no bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingNoKeybind), 3); + AddRepeatStep("Change enum (with bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingWithKeybind), 3); + } + + private class TestConfigManager : ConfigManager { - base.LoadComplete(); + public TestConfigManager() + { + InitialiseDefaults(); + } + + protected override void InitialiseDefaults() + { + Set(TestConfigSetting.ToggleSettingNoKeybind, false); + Set(TestConfigSetting.EnumSettingNoKeybind, EnumSetting.Setting1); + Set(TestConfigSetting.ToggleSettingWithKeybind, false); + Set(TestConfigSetting.EnumSettingWithKeybind, EnumSetting.Setting1); - Add(new OnScreenDisplay()); + base.InitialiseDefaults(); + } - frameSyncMode = config.GetBindable(FrameworkSetting.FrameSync); + public void ToggleSetting(TestConfigSetting setting) => Set(setting, !Get(setting)); - FrameSync initial = frameSyncMode.Value; + public void IncrementEnumSetting(TestConfigSetting setting) + { + var nextValue = Get(setting) + 1; + if (nextValue > EnumSetting.Setting4) + nextValue = EnumSetting.Setting1; + Set(setting, nextValue); + } - AddRepeatStep(@"Change frame limiter", setNextMode, 3); + public override TrackedSettings CreateTrackedSettings() => new TrackedSettings + { + new TrackedSetting(TestConfigSetting.ToggleSettingNoKeybind, b => new SettingDescription(b, "toggle setting with no keybind", b ? "enabled" : "disabled")), + new TrackedSetting(TestConfigSetting.EnumSettingNoKeybind, v => new SettingDescription(v, "enum setting with no keybind", v.ToString())), + new TrackedSetting(TestConfigSetting.ToggleSettingWithKeybind, b => new SettingDescription(b, "toggle setting with keybind", b ? "enabled" : "disabled", "fake keybind")), + new TrackedSetting(TestConfigSetting.EnumSettingWithKeybind, v => new SettingDescription(v, "enum setting with keybind", v.ToString(), "fake keybind")), + }; - AddStep(@"Restore frame limiter", () => frameSyncMode.Value = initial); + protected override void PerformLoad() + { + } + + protected override bool PerformSave() => false; } - private void setNextMode() + private enum TestConfigSetting { - var nextMode = frameSyncMode.Value + 1; - if (nextMode > FrameSync.Unlimited) - nextMode = FrameSync.VSync; - frameSyncMode.Value = nextMode; + ToggleSettingNoKeybind, + EnumSettingNoKeybind, + ToggleSettingWithKeybind, + EnumSettingWithKeybind } - [BackgroundDependencyLoader] - private void load(FrameworkConfigManager config) + private enum EnumSetting + { + Setting1, + Setting2, + Setting3, + Setting4 + } + + private class TestOnScreenDisplay : OnScreenDisplay { - this.config = config; + protected override void Display(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110); } } } diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 9882ea01f00f..a643080df88b 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -102,12 +102,12 @@ public OnScreenDisplay() }, textLine3 = new OsuSpriteText { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, Padding = new MarginPadding { Bottom = 15 }, Font = @"Exo2.0-Bold", TextSize = 12, Alpha = 0.3f, - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, }, } } @@ -177,13 +177,7 @@ private void display(SettingDescription description) textLine2.Text = description.Value; textLine3.Text = description.Shortcut.ToUpper(); - box.Animate( - b => b.FadeIn(500, Easing.OutQuint), - b => b.ResizeHeightTo(height, 500, Easing.OutQuint) - ).Then( - b => b.FadeOutFromOne(1500, Easing.InQuint), - b => b.ResizeHeightTo(height_contracted, 1500, Easing.InQuint) - ); + Display(box); int optionCount = 0; int selectedOption = -1; @@ -215,6 +209,17 @@ private void display(SettingDescription description) }); } + protected virtual void Display(Drawable toDisplay) + { + toDisplay.Animate( + b => b.FadeIn(500, Easing.OutQuint), + b => b.ResizeHeightTo(height, 500, Easing.OutQuint) + ).Then( + b => b.FadeOutFromOne(1500, Easing.InQuint), + b => b.ResizeHeightTo(height_contracted, 1500, Easing.InQuint) + ); + } + private class OptionLight : Container { private Color4 glowingColour, idleColour; From df604c40ccd33a1b70637a89f09211f6b7de5c87 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 10 May 2018 18:49:19 +0900 Subject: [PATCH 5/6] Keep shortcut padding even when there is no shortut --- osu-framework | 2 +- osu.Game/Overlays/OnScreenDisplay.cs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/osu-framework b/osu-framework index 0773d895d9aa..5c135a736038 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 0773d895d9aa0729995cd4a23efc28238e35ceed +Subproject commit 5c135a7360388dc41b1dc4387769a98ee1635d36 diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index a643080df88b..8f6bf0f53937 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -31,6 +31,7 @@ public class OnScreenDisplay : Container private readonly SpriteText textLine3; private const float height = 110; + private const float height_notext = 98; private const float height_contracted = height * 0.9f; private readonly FillFlowContainer optionLights; @@ -100,15 +101,20 @@ public OnScreenDisplay() Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both }, - textLine3 = new OsuSpriteText + new Container { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - Padding = new MarginPadding { Bottom = 15 }, - Font = @"Exo2.0-Bold", - TextSize = 12, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Bottom = 15 }, Alpha = 0.3f, - }, + Child = textLine3 = new OsuSpriteText + { + Font = @"Exo2.0-Bold", + TextSize = 12, + AlwaysPresent = true + }, + } } } } From 17861c2a162f1d562aa79fb4bc3e267e96dbe530 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 14 May 2018 19:20:53 +0900 Subject: [PATCH 6/6] Display "no key bound" when no shortcut --- osu.Game/Overlays/OnScreenDisplay.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/osu.Game/Overlays/OnScreenDisplay.cs b/osu.Game/Overlays/OnScreenDisplay.cs index 8f6bf0f53937..1c80f2e626c0 100644 --- a/osu.Game/Overlays/OnScreenDisplay.cs +++ b/osu.Game/Overlays/OnScreenDisplay.cs @@ -101,20 +101,15 @@ public OnScreenDisplay() Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both }, - new Container + textLine3 = new OsuSpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, - AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Bottom = 15 }, + Font = @"Exo2.0-Bold", + TextSize = 12, Alpha = 0.3f, - Child = textLine3 = new OsuSpriteText - { - Font = @"Exo2.0-Bold", - TextSize = 12, - AlwaysPresent = true - }, - } + }, } } } @@ -183,6 +178,9 @@ private void display(SettingDescription description) textLine2.Text = description.Value; textLine3.Text = description.Shortcut.ToUpper(); + if (string.IsNullOrEmpty(textLine3.Text)) + textLine3.Text = "NO KEY BOUND"; + Display(box); int optionCount = 0;