mirror of
https://github.com/ppy/osu.git
synced 2026-06-03 18:03:55 +08:00
Improve input handling in percentage-based slider bars (#36195)
Reported in https://github.com/ppy/osu/pull/36193#issuecomment-3703406223. Preview: https://github.com/user-attachments/assets/ac2b86cf-ad92-496b-b3dd-19ad47753a9b --------- Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
committed by
GitHub
Unverified
parent
b5a989d31e
commit
676b7a36da
@@ -330,7 +330,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
break;
|
||||
|
||||
case Bindable<double> bindableDouble:
|
||||
bindableDouble.Value = double.Parse(textBox.Current.Value);
|
||||
bindableDouble.Value = double.Parse(textBox.Current.Value) / (DisplayAsPercentage ? 100 : 1);
|
||||
break;
|
||||
|
||||
case Bindable<float> bindableFloat:
|
||||
bindableFloat.Value = float.Parse(textBox.Current.Value) / (DisplayAsPercentage ? 100 : 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -397,7 +401,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
if (updatingFromTextBox) return;
|
||||
|
||||
textBox.Text = currentNumberInstantaneous.Value.ToStandardFormattedString(OsuSliderBar<T>.MAX_DECIMAL_DIGITS);
|
||||
if (DisplayAsPercentage)
|
||||
{
|
||||
double floatValue = double.CreateTruncating(currentNumberInstantaneous.Value);
|
||||
|
||||
if (currentNumberInstantaneous.Value is int)
|
||||
floatValue /= 100;
|
||||
|
||||
textBox.Text = floatValue.ToStandardFormattedString(Math.Max(0, OsuSliderBar<T>.MAX_DECIMAL_DIGITS - 2));
|
||||
}
|
||||
else
|
||||
textBox.Text = currentNumberInstantaneous.Value.ToStandardFormattedString(OsuSliderBar<T>.MAX_DECIMAL_DIGITS);
|
||||
|
||||
valueLabel.Text = LabelFormat(currentNumberInstantaneous.Value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user