From 2c7343e9659b73c37d4d7e4f77c9275fb04722b0 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 12:42:11 +1030 Subject: [PATCH 01/11] Add revert-to-default glow for settings items --- osu.Game/Overlays/Settings/SettingsItem.cs | 89 ++++++++++++++++++- osu.Game/Overlays/Settings/SettingsSection.cs | 5 +- .../Overlays/Settings/SettingsSubsection.cs | 2 +- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index f2044f178b..c98b2f1ee9 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -2,17 +2,23 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Framework.Allocation; using OpenTK.Graphics; using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Framework.Input; +using osu.Game.Graphics; using osu.Game.Graphics.Sprites; namespace osu.Game.Overlays.Settings { - public abstract class SettingsItem : FillFlowContainer, IFilterable + public abstract class SettingsItem : Container, IFilterable { protected abstract Drawable CreateControl(); @@ -20,8 +26,16 @@ namespace osu.Game.Overlays.Settings private IHasCurrentValue controlWithCurrent => Control as IHasCurrentValue; + protected override Container Content => FlowContent; + + protected readonly FillFlowContainer FlowContent; + private SpriteText text; + private readonly SettingsItemDefaultIndicator defaultIndicator = new SettingsItemDefaultIndicator(); + + public bool ShowsDefaultIndicator = true; + public virtual string LabelText { get { return text?.Text ?? string.Empty; } @@ -51,6 +65,11 @@ namespace osu.Game.Overlays.Settings { bindable = value; controlWithCurrent?.Current.BindTo(bindable); + if (ShowsDefaultIndicator) + { + defaultIndicator.Bindable.BindTo(bindable); + defaultIndicator.Bindable.TriggerChange(); + } } } @@ -69,14 +88,78 @@ namespace osu.Game.Overlays.Settings { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - Padding = new MarginPadding { Right = 5 }; + Padding = new MarginPadding { Right = SettingsOverlay.CONTENT_MARGINS }; + + FlowContent = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = 5 }, + }; if ((Control = CreateControl()) != null) { if (controlWithCurrent != null) controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; }; - Add(Control); + FlowContent.Add(Control); } } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { + AddInternal(FlowContent); + + if (defaultIndicator != null) + { + defaultIndicator.Colour = ColourInfo.GradientHorizontal(colours.Yellow.Opacity(0.8f), colours.Yellow.Opacity(0)); + defaultIndicator.Alpha = 0f; + AddInternal(defaultIndicator); + } + } + + private class SettingsItemDefaultIndicator : Box + { + internal readonly Bindable Bindable = new Bindable(); + + private bool hovering; + + public SettingsItemDefaultIndicator() + { + Bindable.ValueChanged += value => updateAlpha(); + + RelativeSizeAxes = Axes.Y; + Width = SettingsOverlay.CONTENT_MARGINS; + Alpha = 0f; + } + + public override bool HandleInput => true; + + protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; + + protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) => true; + + protected override bool OnClick(InputState state) + { + Bindable.SetDefault(); + return true; + } + + protected override bool OnHover(InputState state) + { + hovering = true; + updateAlpha(); + return true; + } + + protected override void OnHoverLost(InputState state) + { + hovering = false; + updateAlpha(); + } + + private void updateAlpha() => + Alpha = Bindable.IsDefault ? 0f : hovering ? 1f : 0.5f; + } } } diff --git a/osu.Game/Overlays/Settings/SettingsSection.cs b/osu.Game/Overlays/Settings/SettingsSection.cs index eb6e398477..a107878fb8 100644 --- a/osu.Game/Overlays/Settings/SettingsSection.cs +++ b/osu.Game/Overlays/Settings/SettingsSection.cs @@ -69,8 +69,6 @@ namespace osu.Game.Overlays.Settings Padding = new MarginPadding { Top = 20 + border_size, - Left = SettingsOverlay.CONTENT_MARGINS, - Right = SettingsOverlay.CONTENT_MARGINS, Bottom = 10, }, RelativeSizeAxes = Axes.X, @@ -81,7 +79,8 @@ namespace osu.Game.Overlays.Settings { TextSize = header_size, Text = Header, - Colour = colours.Yellow + Colour = colours.Yellow, + Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS } }, FlowContent } diff --git a/osu.Game/Overlays/Settings/SettingsSubsection.cs b/osu.Game/Overlays/Settings/SettingsSubsection.cs index 4164ceee21..79a644b2cb 100644 --- a/osu.Game/Overlays/Settings/SettingsSubsection.cs +++ b/osu.Game/Overlays/Settings/SettingsSubsection.cs @@ -52,7 +52,7 @@ namespace osu.Game.Overlays.Settings new OsuSpriteText { Text = Header.ToUpper(), - Margin = new MarginPadding { Bottom = 10 }, + Margin = new MarginPadding { Bottom = 10, Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }, Font = @"Exo2.0-Black", }, FlowContent From 98044a17d3de8bc29e240a10c920ce95b3766a45 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 13:16:06 +1030 Subject: [PATCH 02/11] Fix misaligned settings buttons --- .../KeyBinding/KeyBindingsSubsection.cs | 1 + .../Settings/Sections/Audio/OffsetSettings.cs | 3 +-- .../Settings/Sections/Debug/GCSettings.cs | 3 +-- .../Settings/Sections/General/LoginSettings.cs | 6 ++---- .../Settings/Sections/General/UpdateSettings.cs | 3 +-- .../Settings/Sections/Input/KeyboardSettings.cs | 3 +-- .../Sections/Maintenance/GeneralSettings.cs | 9 +++------ osu.Game/Overlays/Settings/SettingsButton.cs | 17 +++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 9 files changed, 28 insertions(+), 18 deletions(-) create mode 100644 osu.Game/Overlays/Settings/SettingsButton.cs diff --git a/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs b/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs index 128b5e2f09..2ff5d7b81f 100644 --- a/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs +++ b/osu.Game/Overlays/KeyBinding/KeyBindingsSubsection.cs @@ -28,6 +28,7 @@ namespace osu.Game.Overlays.KeyBinding this.variant = variant; FlowContent.Spacing = new Vector2(0, 1); + FlowContent.Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }; } [BackgroundDependencyLoader] diff --git a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs index bc09a2145a..8d3f4ee672 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs @@ -22,9 +22,8 @@ namespace osu.Game.Overlays.Settings.Sections.Audio LabelText = "Audio Offset", Bindable = config.GetBindable(OsuSetting.AudioOffset) }, - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Offset wizard" } }; diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs index 495a2543d1..50768fb646 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs @@ -24,9 +24,8 @@ namespace osu.Game.Overlays.Settings.Sections.Debug LabelText = "Active mode", Bindable = config.GetBindable(DebugSetting.ActiveGCMode) }, - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Force garbage collection", Action = GC.Collect }, diff --git a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs index 8b7d7b0d69..56b9a55398 100644 --- a/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/LoginSettings.cs @@ -230,15 +230,13 @@ namespace osu.Game.Overlays.Settings.Sections.General LabelText = "Stay logged in", Bindable = config.GetBindable(OsuSetting.SavePassword), }, - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Sign in", Action = performLogin }, - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Register new account", //Action = registerLink } diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 833a5ff966..6ccb16f538 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -23,9 +23,8 @@ namespace osu.Game.Overlays.Settings.Sections.General LabelText = "Release stream", Bindable = config.GetBindable(OsuSetting.ReleaseStream), }, - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Open osu! folder", Action = storage.OpenInNativeExplorer, } diff --git a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs index b68fd4bc04..4bc16cd0e1 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs @@ -14,9 +14,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input { Children = new Drawable[] { - new OsuButton + new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Key Configuration", Action = keyConfig.ToggleVisibility }, diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 233ca7be60..e14094cf3a 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -22,9 +22,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance { Children = new Drawable[] { - importButton = new OsuButton + importButton = new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Import beatmaps from stable", Action = () => { @@ -32,9 +31,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true)); } }, - deleteButton = new OsuButton + deleteButton = new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Delete ALL beatmaps", Action = () => { @@ -42,9 +40,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true)); } }, - restoreButton = new OsuButton + restoreButton = new SettingsButton { - RelativeSizeAxes = Axes.X, Text = "Restore all hidden difficulties", Action = () => { diff --git a/osu.Game/Overlays/Settings/SettingsButton.cs b/osu.Game/Overlays/Settings/SettingsButton.cs new file mode 100644 index 0000000000..252ef30629 --- /dev/null +++ b/osu.Game/Overlays/Settings/SettingsButton.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Settings.Sections +{ + public class SettingsButton : OsuButton + { + public SettingsButton() + { + RelativeSizeAxes = Axes.X; + Padding = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }; + } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 601c99e19f..16589c72ff 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -288,6 +288,7 @@ + From 290fac89909bd6c4accc8e2c9ca417cb3c57eaef Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 13:17:03 +1030 Subject: [PATCH 03/11] Temporarily disable revert functionality for audio device, since it crashes --- .../Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs index a2f3ad545b..1e1dd86808 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio Children = new Drawable[] { - dropdown = new SettingsDropdown() + dropdown = new SettingsDropdown { ShowsDefaultIndicator = false } }; updateItems(); From b4d575fbcd4fab7fb30ffa568d0564d2678993d2 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 13:22:21 +1030 Subject: [PATCH 04/11] Fix namespace and unnecessary using --- osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs | 1 - osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs | 1 - osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs | 1 - osu.Game/Overlays/Settings/SettingsButton.cs | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs index 50768fb646..23e7433732 100644 --- a/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Debug/GCSettings.cs @@ -6,7 +6,6 @@ using System.Runtime; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings.Sections.Debug { diff --git a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs index 6ccb16f538..3bca0af3af 100644 --- a/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/General/UpdateSettings.cs @@ -5,7 +5,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Game.Configuration; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings.Sections.General { diff --git a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs index 4bc16cd0e1..00a1c093fd 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/KeyboardSettings.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings.Sections.Input { diff --git a/osu.Game/Overlays/Settings/SettingsButton.cs b/osu.Game/Overlays/Settings/SettingsButton.cs index 252ef30629..6ac8aa9f46 100644 --- a/osu.Game/Overlays/Settings/SettingsButton.cs +++ b/osu.Game/Overlays/Settings/SettingsButton.cs @@ -4,7 +4,7 @@ using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; -namespace osu.Game.Overlays.Settings.Sections +namespace osu.Game.Overlays.Settings { public class SettingsButton : OsuButton { From 840ba9f48efa82f31018e2042a72f2608561cf8a Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 16:05:37 +1030 Subject: [PATCH 05/11] Allow the default indicator colour to be specified, and fix bug where disabled bindables could be reset --- osu.Game/Overlays/Settings/SettingsItem.cs | 43 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index c98b2f1ee9..01b76605e0 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -36,6 +36,18 @@ namespace osu.Game.Overlays.Settings public bool ShowsDefaultIndicator = true; + private Color4? defaultIndicatorColour; + + public Color4 DefaultIndicatorColour + { + get { return defaultIndicatorColour ?? Color4.White; } + set + { + defaultIndicatorColour = value; + defaultIndicator?.SetIndicatorColour(DefaultIndicatorColour); + } + } + public virtual string LabelText { get { return text?.Text ?? string.Empty; } @@ -112,8 +124,9 @@ namespace osu.Game.Overlays.Settings if (defaultIndicator != null) { - defaultIndicator.Colour = ColourInfo.GradientHorizontal(colours.Yellow.Opacity(0.8f), colours.Yellow.Opacity(0)); - defaultIndicator.Alpha = 0f; + if (!defaultIndicatorColour.HasValue) + defaultIndicatorColour = colours.Yellow; + defaultIndicator.SetIndicatorColour(DefaultIndicatorColour); AddInternal(defaultIndicator); } } @@ -122,11 +135,14 @@ namespace osu.Game.Overlays.Settings { internal readonly Bindable Bindable = new Bindable(); + private Color4 indicatorColour; + private bool hovering; public SettingsItemDefaultIndicator() { - Bindable.ValueChanged += value => updateAlpha(); + Bindable.ValueChanged += value => UpdateState(); + Bindable.DisabledChanged += disabled => UpdateState(); RelativeSizeAxes = Axes.Y; Width = SettingsOverlay.CONTENT_MARGINS; @@ -141,25 +157,36 @@ namespace osu.Game.Overlays.Settings protected override bool OnClick(InputState state) { - Bindable.SetDefault(); + if (!Bindable.Disabled) + Bindable.SetDefault(); return true; } protected override bool OnHover(InputState state) { hovering = true; - updateAlpha(); + UpdateState(); return true; } protected override void OnHoverLost(InputState state) { hovering = false; - updateAlpha(); + UpdateState(); } - private void updateAlpha() => - Alpha = Bindable.IsDefault ? 0f : hovering ? 1f : 0.5f; + internal void SetIndicatorColour(Color4 indicatorColour) + { + this.indicatorColour = indicatorColour; + UpdateState(); + } + + internal void UpdateState() + { + var colour = Bindable.Disabled ? Color4.Gray : indicatorColour; + Alpha = Bindable.IsDefault ? 0f : (hovering && !Bindable.Disabled) ? 1f : 0.5f; + Colour = ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)); + } } } } From f5946c0e07b7aa39dd7fb14e62a29c7cc77f3f71 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 16:28:03 +1030 Subject: [PATCH 06/11] Fix wrong license header --- osu.Game/Overlays/Settings/SettingsButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsButton.cs b/osu.Game/Overlays/Settings/SettingsButton.cs index 6ac8aa9f46..5320cef850 100644 --- a/osu.Game/Overlays/Settings/SettingsButton.cs +++ b/osu.Game/Overlays/Settings/SettingsButton.cs @@ -1,5 +1,5 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Game.Graphics.UserInterface; From 59b10981dc24659bec8a10be7aa9131ffbd193bb Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sat, 21 Oct 2017 17:06:28 +1030 Subject: [PATCH 07/11] CI fixes --- osu.Game/Overlays/Settings/SettingsItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index 01b76605e0..d77552bb47 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -184,7 +184,7 @@ namespace osu.Game.Overlays.Settings internal void UpdateState() { var colour = Bindable.Disabled ? Color4.Gray : indicatorColour; - Alpha = Bindable.IsDefault ? 0f : (hovering && !Bindable.Disabled) ? 1f : 0.5f; + Alpha = Bindable.IsDefault ? 0f : hovering && !Bindable.Disabled ? 1f : 0.5f; Colour = ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)); } } From 5785af9f6a74727ceb2f01e134d6376c715341e4 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sun, 22 Oct 2017 14:22:57 +1030 Subject: [PATCH 08/11] Reenable revert indicator on audio device since the potential crash was addressed in #1101 --- .../Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs index 1e1dd86808..a2f3ad545b 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/AudioDevicesSettings.cs @@ -59,7 +59,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio Children = new Drawable[] { - dropdown = new SettingsDropdown { ShowsDefaultIndicator = false } + dropdown = new SettingsDropdown() }; updateItems(); From 448ff3bf384a3116a0bde63ca8d41dfb43b2526b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 22 Oct 2017 13:28:17 +0900 Subject: [PATCH 09/11] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 383a8da7bc..88e7c85a9b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 383a8da7bc45af498288b4b72c72a048a0996e74 +Subproject commit 88e7c85a9bb20ad5806528d8682ca61baf3d5237 From 2e6a68d358aa47f32bd5da2cccade93f08645319 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Sun, 22 Oct 2017 16:10:41 +1030 Subject: [PATCH 10/11] Rename indicator class, add colour/fade easing, and add tooltip --- osu.Game/Overlays/Settings/SettingsItem.cs | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index d77552bb47..5a0f25f7e0 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; @@ -32,19 +33,19 @@ namespace osu.Game.Overlays.Settings private SpriteText text; - private readonly SettingsItemDefaultIndicator defaultIndicator = new SettingsItemDefaultIndicator(); + private readonly RestoreDefaultValueButton restoreDefaultValueButton = new RestoreDefaultValueButton(); public bool ShowsDefaultIndicator = true; - private Color4? defaultIndicatorColour; + private Color4? restoreDefaultValueColour; - public Color4 DefaultIndicatorColour + public Color4 RestoreDefaultValueColour { - get { return defaultIndicatorColour ?? Color4.White; } + get { return restoreDefaultValueColour ?? Color4.White; } set { - defaultIndicatorColour = value; - defaultIndicator?.SetIndicatorColour(DefaultIndicatorColour); + restoreDefaultValueColour = value; + restoreDefaultValueButton?.SetButtonColour(RestoreDefaultValueColour); } } @@ -79,8 +80,8 @@ namespace osu.Game.Overlays.Settings controlWithCurrent?.Current.BindTo(bindable); if (ShowsDefaultIndicator) { - defaultIndicator.Bindable.BindTo(bindable); - defaultIndicator.Bindable.TriggerChange(); + restoreDefaultValueButton.Bindable.BindTo(bindable); + restoreDefaultValueButton.Bindable.TriggerChange(); } } } @@ -122,24 +123,24 @@ namespace osu.Game.Overlays.Settings { AddInternal(FlowContent); - if (defaultIndicator != null) + if (restoreDefaultValueButton != null) { - if (!defaultIndicatorColour.HasValue) - defaultIndicatorColour = colours.Yellow; - defaultIndicator.SetIndicatorColour(DefaultIndicatorColour); - AddInternal(defaultIndicator); + if (!restoreDefaultValueColour.HasValue) + restoreDefaultValueColour = colours.Yellow; + restoreDefaultValueButton.SetButtonColour(RestoreDefaultValueColour); + AddInternal(restoreDefaultValueButton); } } - private class SettingsItemDefaultIndicator : Box + private class RestoreDefaultValueButton : Box, IHasTooltip { internal readonly Bindable Bindable = new Bindable(); - private Color4 indicatorColour; + private Color4 buttonColour; private bool hovering; - public SettingsItemDefaultIndicator() + public RestoreDefaultValueButton() { Bindable.ValueChanged += value => UpdateState(); Bindable.DisabledChanged += disabled => UpdateState(); @@ -149,6 +150,8 @@ namespace osu.Game.Overlays.Settings Alpha = 0f; } + public string TooltipText => "Revert to default"; + public override bool HandleInput => true; protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true; @@ -175,17 +178,17 @@ namespace osu.Game.Overlays.Settings UpdateState(); } - internal void SetIndicatorColour(Color4 indicatorColour) + internal void SetButtonColour(Color4 buttonColour) { - this.indicatorColour = indicatorColour; + this.buttonColour = buttonColour; UpdateState(); } internal void UpdateState() { - var colour = Bindable.Disabled ? Color4.Gray : indicatorColour; - Alpha = Bindable.IsDefault ? 0f : hovering && !Bindable.Disabled ? 1f : 0.5f; - Colour = ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)); + var colour = Bindable.Disabled ? Color4.Gray : buttonColour; + this.FadeTo(Bindable.IsDefault ? 0f : hovering && !Bindable.Disabled ? 1f : 0.5f, 200, Easing.OutQuint); + this.FadeColour(ColourInfo.GradientHorizontal(colour.Opacity(0.8f), colour.Opacity(0)), 200, Easing.OutQuint); } } } From ea2934d92c69f437e5550bcb5ed40de6f33847c7 Mon Sep 17 00:00:00 2001 From: Shane Woolcock Date: Mon, 23 Oct 2017 16:06:08 +1030 Subject: [PATCH 11/11] Add KeyboardStep values for configuration options --- .../Settings/Sections/Audio/OffsetSettings.cs | 3 ++- .../Settings/Sections/Audio/VolumeSettings.cs | 6 +++--- .../Settings/Sections/Gameplay/GeneralSettings.cs | 3 ++- .../Settings/Sections/Gameplay/SongSelectSettings.cs | 6 ++++-- .../Settings/Sections/Graphics/LayoutSettings.cs | 6 ++++-- osu.Game/Overlays/Settings/Sections/SkinSection.cs | 6 ++++-- osu.Game/Overlays/Settings/SettingsSlider.cs | 11 +++++++++++ .../Screens/Play/ReplaySettings/PlaybackSettings.cs | 3 ++- 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs index bc09a2145a..984fe28ec5 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/OffsetSettings.cs @@ -20,7 +20,8 @@ namespace osu.Game.Overlays.Settings.Sections.Audio new SettingsSlider { LabelText = "Audio Offset", - Bindable = config.GetBindable(OsuSetting.AudioOffset) + Bindable = config.GetBindable(OsuSetting.AudioOffset), + KeyboardStep = 100f }, new OsuButton { diff --git a/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs b/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs index ea442cdfc2..d197f8c466 100644 --- a/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Audio/VolumeSettings.cs @@ -16,9 +16,9 @@ namespace osu.Game.Overlays.Settings.Sections.Audio { Children = new Drawable[] { - new SettingsSlider { LabelText = "Master", Bindable = audio.Volume }, - new SettingsSlider { LabelText = "Effect", Bindable = audio.VolumeSample }, - new SettingsSlider { LabelText = "Music", Bindable = audio.VolumeTrack }, + new SettingsSlider { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.1f }, + new SettingsSlider { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.1f }, + new SettingsSlider { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.1f }, }; } } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index a8ec04514a..8ec6af5cd0 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -19,7 +19,8 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay new SettingsSlider { LabelText = "Background dim", - Bindable = config.GetBindable(OsuSetting.DimLevel) + Bindable = config.GetBindable(OsuSetting.DimLevel), + KeyboardStep = 0.1f }, new SettingsCheckbox { diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs index 08dba011df..07a8e7464a 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/SongSelectSettings.cs @@ -20,12 +20,14 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay new SettingsSlider { LabelText = "Display beatmaps from", - Bindable = config.GetBindable(OsuSetting.DisplayStarsMinimum) + Bindable = config.GetBindable(OsuSetting.DisplayStarsMinimum), + KeyboardStep = 1f }, new SettingsSlider { LabelText = "up to", - Bindable = config.GetBindable(OsuSetting.DisplayStarsMaximum) + Bindable = config.GetBindable(OsuSetting.DisplayStarsMaximum), + KeyboardStep = 1f }, new SettingsEnumDropdown { diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs index c4ce742153..3d09d6b901 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/LayoutSettings.cs @@ -49,12 +49,14 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics new SettingsSlider { LabelText = "Horizontal position", - Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionX) + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionX), + KeyboardStep = 0.1f }, new SettingsSlider { LabelText = "Vertical position", - Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionY) + Bindable = config.GetBindable(FrameworkSetting.LetterboxPositionY), + KeyboardStep = 0.1f }, } }, diff --git a/osu.Game/Overlays/Settings/Sections/SkinSection.cs b/osu.Game/Overlays/Settings/Sections/SkinSection.cs index 4b4426aca8..b4475aebb1 100644 --- a/osu.Game/Overlays/Settings/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Settings/Sections/SkinSection.cs @@ -24,12 +24,14 @@ namespace osu.Game.Overlays.Settings.Sections new SettingsSlider { LabelText = "Menu cursor size", - Bindable = config.GetBindable(OsuSetting.MenuCursorSize) + Bindable = config.GetBindable(OsuSetting.MenuCursorSize), + KeyboardStep = 0.1f }, new SettingsSlider { LabelText = "Gameplay cursor size", - Bindable = config.GetBindable(OsuSetting.GameplayCursorSize) + Bindable = config.GetBindable(OsuSetting.GameplayCursorSize), + KeyboardStep = 0.1f }, new SettingsCheckbox { diff --git a/osu.Game/Overlays/Settings/SettingsSlider.cs b/osu.Game/Overlays/Settings/SettingsSlider.cs index 2881d02302..49d73f77ec 100644 --- a/osu.Game/Overlays/Settings/SettingsSlider.cs +++ b/osu.Game/Overlays/Settings/SettingsSlider.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; @@ -22,5 +23,15 @@ namespace osu.Game.Overlays.Settings Margin = new MarginPadding { Top = 5, Bottom = 5 }, RelativeSizeAxes = Axes.X }; + + public float KeyboardStep; + + [BackgroundDependencyLoader] + private void load() + { + var slider = Control as U; + if (slider != null) + slider.KeyboardStep = KeyboardStep; + } } } diff --git a/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs b/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs index ea958d05f9..16868e5843 100644 --- a/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/ReplaySettings/PlaybackSettings.cs @@ -19,7 +19,8 @@ namespace osu.Game.Screens.Play.ReplaySettings new ReplaySliderBar { LabelText = "Playback speed", - Bindable = config.GetBindable(OsuSetting.PlaybackSpeed) + Bindable = config.GetBindable(OsuSetting.PlaybackSpeed), + KeyboardStep = 0.5f } }; }