mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Fix multiple issues with textbox content display
- Sometimes would display too many decimal digits due to floating point representation errors. - Placeholder would also look wrong if text was removed during a multiple (but determinate) selection.
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -9,6 +10,7 @@ using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays.Settings;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Timing
|
||||
{
|
||||
@ -65,7 +67,6 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
textbox = new LabelledTextBox
|
||||
{
|
||||
Label = labelText,
|
||||
PlaceholderText = "(multiple)"
|
||||
},
|
||||
slider = new SettingsSlider<T>
|
||||
{
|
||||
@ -104,11 +105,16 @@ namespace osu.Game.Screens.Edit.Timing
|
||||
if (Current.Value is T nonNullValue)
|
||||
{
|
||||
slider.Current.Value = nonNullValue;
|
||||
textbox.Text = slider.Current.ToString();
|
||||
|
||||
// use the value from the slider to ensure that any precision/min/max set on it via the initial indeterminate value have been applied correctly.
|
||||
decimal decimalValue = slider.Current.Value.ToDecimal(NumberFormatInfo.InvariantInfo);
|
||||
textbox.Text = decimalValue.ToString($@"N{FormatUtils.FindPrecision(decimalValue)}");
|
||||
textbox.PlaceholderText = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
textbox.Text = null;
|
||||
textbox.PlaceholderText = "(multiple)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user