1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 21:43:21 +08:00

Make OsuSliderBar support both float and double values

This commit is contained in:
smoogipoo 2018-01-02 14:33:28 +09:00
parent 33eaf96bcb
commit ddc9edab54

View File

@ -32,11 +32,18 @@ namespace osu.Game.Graphics.UserInterface
get get
{ {
var bindableDouble = CurrentNumber as BindableNumber<double>; var bindableDouble = CurrentNumber as BindableNumber<double>;
if (bindableDouble != null) var bindableFloat = CurrentNumber as BindableNumber<float>;
var floatValue = bindableDouble?.Value ?? bindableFloat?.Value ?? null;
if (floatValue != null)
{ {
if (bindableDouble.MaxValue == 1 && (bindableDouble.MinValue == 0 || bindableDouble.MinValue == -1)) var floatMinValue = bindableDouble?.MinValue ?? bindableFloat?.MinValue ?? null;
return bindableDouble.Value.ToString(@"P0"); var floatMaxValue = bindableDouble?.MaxValue ?? bindableFloat?.MaxValue ?? null;
return bindableDouble.Value.ToString(@"n1");
if (floatMaxValue == 1 && (floatMinValue == 0 || floatMinValue == -1))
return floatValue.Value.ToString(@"P0");
return floatValue.Value.ToString(@"n1");
} }
var bindableInt = CurrentNumber as BindableNumber<int>; var bindableInt = CurrentNumber as BindableNumber<int>;