From ddc9edab5423899579c1f50ff0909e1a34e7ac2f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 2 Jan 2018 14:33:28 +0900 Subject: [PATCH] Make OsuSliderBar support both float and double values --- osu.Game/Graphics/UserInterface/OsuSliderBar.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs index fd75269610..4ff65dea93 100644 --- a/osu.Game/Graphics/UserInterface/OsuSliderBar.cs +++ b/osu.Game/Graphics/UserInterface/OsuSliderBar.cs @@ -32,11 +32,18 @@ namespace osu.Game.Graphics.UserInterface get { var bindableDouble = CurrentNumber as BindableNumber; - if (bindableDouble != null) + var bindableFloat = CurrentNumber as BindableNumber; + var floatValue = bindableDouble?.Value ?? bindableFloat?.Value ?? null; + + if (floatValue != null) { - if (bindableDouble.MaxValue == 1 && (bindableDouble.MinValue == 0 || bindableDouble.MinValue == -1)) - return bindableDouble.Value.ToString(@"P0"); - return bindableDouble.Value.ToString(@"n1"); + var floatMinValue = bindableDouble?.MinValue ?? bindableFloat?.MinValue ?? null; + var floatMaxValue = bindableDouble?.MaxValue ?? bindableFloat?.MaxValue ?? null; + + if (floatMaxValue == 1 && (floatMinValue == 0 || floatMinValue == -1)) + return floatValue.Value.ToString(@"P0"); + + return floatValue.Value.ToString(@"n1"); } var bindableInt = CurrentNumber as BindableNumber;