From 676b7a36da45c3d6a474ca4b274c615e6053da94 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Sat, 17 Jan 2026 02:39:28 -0500 Subject: [PATCH] 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 --- .../Graphics/UserInterfaceV2/FormSliderBar.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs b/osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs index cc0e7d5052..e228491880 100644 --- a/osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs +++ b/osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs @@ -330,7 +330,11 @@ namespace osu.Game.Graphics.UserInterfaceV2 break; case Bindable bindableDouble: - bindableDouble.Value = double.Parse(textBox.Current.Value); + bindableDouble.Value = double.Parse(textBox.Current.Value) / (DisplayAsPercentage ? 100 : 1); + break; + + case Bindable 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.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.MAX_DECIMAL_DIGITS - 2)); + } + else + textBox.Text = currentNumberInstantaneous.Value.ToStandardFormattedString(OsuSliderBar.MAX_DECIMAL_DIGITS); + valueLabel.Text = LabelFormat(currentNumberInstantaneous.Value); }