From e53c4be3561c85b900fffff27f0b11b330238379 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 21 Apr 2017 13:59:04 +0200 Subject: [PATCH] I guess this works... --- .../Graphics/UserInterface/OsuSliderBar.cs | 10 ++------ osu.Game/Overlays/Options/OptionSlider.cs | 24 +++++++------------ .../Options/Sections/Audio/OffsetOptions.cs | 8 +++++-- .../Sections/Gameplay/SongSelectOptions.cs | 17 +++++++------ .../Options/Sections/Input/MouseOptions.cs | 11 +++++---- .../Overlays/Options/Sections/SkinSection.cs | 16 +++++++------ 6 files changed, 42 insertions(+), 44 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index cf141dd320..027473921f 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -10,8 +10,6 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Input; -using System; -using System.Globalization; namespace osu.Game.Graphics.UserInterface { @@ -25,20 +23,16 @@ public class OsuSliderBar : SliderBar, IHasTooltip where T : struct private readonly Box leftBox; private readonly Box rightBox; - public Func TooltipTextFunc { get; set; } - - public string TooltipText + public virtual string TooltipText { get { - if (TooltipTextFunc != null) return TooltipTextFunc(Current); - var bindableDouble = CurrentNumber as BindableNumber; if (bindableDouble != null) { if (bindableDouble.MaxValue == 1 && (bindableDouble.MinValue == 0 || bindableDouble.MinValue == -1)) return bindableDouble.Value.ToString(@"P0"); - return bindableDouble.Value.ToString(@"n1", CultureInfo.InvariantCulture); + return bindableDouble.Value.ToString(@"n1"); } var bindableInt = CurrentNumber as BindableNumber; diff --git a/osu.Game/Overlays/Options/OptionSlider.cs b/osu.Game/Overlays/Options/OptionSlider.cs index b6989fb7d2..6084a7de80 100644 --- a/osu.Game/Overlays/Options/OptionSlider.cs +++ b/osu.Game/Overlays/Options/OptionSlider.cs @@ -6,15 +6,19 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; +using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using System; namespace osu.Game.Overlays.Options { - public class OptionSlider : FillFlowContainer where T : struct + public class OptionSlider : OptionSlider> where T: struct { - private readonly OsuSliderBar slider; + } + + public class OptionSlider : FillFlowContainer where T : struct where U : SliderBar, new() + { + private readonly SliderBar slider; private readonly SpriteText text; public string LabelText @@ -38,18 +42,6 @@ public Bindable Bindable } } - public Func TooltipText - { - get - { - return slider.TooltipTextFunc; - } - set - { - slider.TooltipTextFunc = value; - } - } - public OptionSlider() { RelativeSizeAxes = Axes.X; @@ -62,7 +54,7 @@ public OptionSlider() { Alpha = 0, }, - slider = new OsuSliderBar + slider = new U() { Margin = new MarginPadding { Top = 5, Bottom = 5 }, RelativeSizeAxes = Axes.X diff --git a/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs index 2a4fea28d4..699a5bff81 100644 --- a/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Audio/OffsetOptions.cs @@ -18,11 +18,10 @@ private void load(OsuConfigManager config) { Children = new Drawable[] { - new OptionSlider + new OptionSlider { LabelText = "Audio Offset", Bindable = (BindableDouble)config.GetBindable(OsuConfig.AudioOffset) - TooltipText = value => value.ToString(@"0ms") }, new OsuButton { @@ -31,5 +30,10 @@ private void load(OsuConfigManager config) } }; } + + private class OffsetSlider : OsuSliderBar + { + public override string TooltipText => Current.Value.ToString(@"0ms"); + } } } diff --git a/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs b/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs index 3a546f5a0d..1a994ff85b 100644 --- a/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Gameplay/SongSelectOptions.cs @@ -5,7 +5,7 @@ using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Game.Configuration; -using System.Globalization; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Options.Sections.Gameplay { @@ -18,20 +18,23 @@ private void load(OsuConfigManager config) { Children = new Drawable[] { - new OptionSlider + new OptionSlider { LabelText = "Display beatmaps from", - Bindable = (BindableDouble)config.GetBindable(OsuConfig.DisplayStarsMinimum), - TooltipText = value => value.ToString(@"0.## stars", CultureInfo.InvariantCulture) + Bindable = (BindableDouble)config.GetBindable(OsuConfig.DisplayStarsMinimum) }, - new OptionSlider + new OptionSlider { LabelText = "up to", - Bindable = (BindableDouble)config.GetBindable(OsuConfig.DisplayStarsMaximum), - TooltipText = value => value.ToString(@"0.## stars", CultureInfo.InvariantCulture) + Bindable = (BindableDouble)config.GetBindable(OsuConfig.DisplayStarsMaximum) }, }; } + + private class StarSlider : OsuSliderBar + { + public override string TooltipText => Current.Value.ToString(@"0.## stars"); + } } } diff --git a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs index 63685aff0d..0882dbab01 100644 --- a/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Input/MouseOptions.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Globalization; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -19,11 +18,10 @@ private void load(OsuConfigManager config) { Children = new Drawable[] { - new OptionSlider + new OptionSlider { LabelText = "Sensitivity", - Bindable = (BindableDouble)config.GetBindable(OsuConfig.MouseSpeed), - TooltipText = value => value.ToString(@"0.##x", CultureInfo.InvariantCulture) + Bindable = (BindableDouble)config.GetBindable(OsuConfig.MouseSpeed) }, new OsuCheckbox { @@ -57,5 +55,10 @@ private void load(OsuConfigManager config) }, }; } + + private class SensitivitySlider : OsuSliderBar + { + public override string TooltipText => Current.Value.ToString(@"0.##x"); + } } } diff --git a/osu.Game/Overlays/Options/Sections/SkinSection.cs b/osu.Game/Overlays/Options/Sections/SkinSection.cs index aa681b94b3..d76c17f09a 100644 --- a/osu.Game/Overlays/Options/Sections/SkinSection.cs +++ b/osu.Game/Overlays/Options/Sections/SkinSection.cs @@ -8,7 +8,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.UserInterface; using OpenTK; -using System.Globalization; namespace osu.Game.Overlays.Options.Sections { @@ -60,17 +59,15 @@ private void load(OsuConfigManager config) LabelText = "Always use skin cursor", Bindable = config.GetBindable(OsuConfig.UseSkinCursor) }, - new OptionSlider + new OptionSlider { LabelText = "Menu cursor size", - Bindable = (BindableDouble)config.GetBindable(OsuConfig.MenuCursorSize), - TooltipText = value => value.ToString(@"0.##x", CultureInfo.InvariantCulture) + Bindable = (BindableDouble)config.GetBindable(OsuConfig.MenuCursorSize) }, - new OptionSlider + new OptionSlider { LabelText = "Gameplay cursor size", - Bindable = (BindableDouble)config.GetBindable(OsuConfig.GameplayCursorSize), - TooltipText = value => value.ToString(@"0.##x", CultureInfo.InvariantCulture) + Bindable = (BindableDouble)config.GetBindable(OsuConfig.GameplayCursorSize) }, new OsuCheckbox { @@ -79,5 +76,10 @@ private void load(OsuConfigManager config) }, }; } + + private class SizeSlider : OsuSliderBar + { + public override string TooltipText => Current.Value.ToString(@"0.##x"); + } } }