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

Merge pull request #30113 from bdach/fix-separator-jank

Fix improper handling of decimal separator in "form" number boxes / sliders
This commit is contained in:
Dean Herbert 2024-10-07 13:42:02 +09:00 committed by GitHub
commit 5859021003
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Globalization;
namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class FormNumberBox : FormTextBox
@ -18,7 +20,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
public bool AllowDecimals { get; init; }
protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && character == '.');
=> char.IsAsciiDigit(character) || (AllowDecimals && CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator.Contains(character));
}
}
}

View File

@ -17,6 +17,7 @@ using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterfaceV2
@ -83,8 +84,10 @@ namespace osu.Game.Graphics.UserInterfaceV2
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
private readonly Bindable<Language> currentLanguage = new Bindable<Language>();
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, OsuGame? game)
{
RelativeSizeAxes = Axes.X;
Height = 50;
@ -150,6 +153,9 @@ namespace osu.Game.Graphics.UserInterfaceV2
},
},
};
if (game != null)
currentLanguage.BindTo(game.CurrentLanguage);
}
protected override void LoadComplete()
@ -164,10 +170,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
slider.IsDragging.BindValueChanged(_ => updateState());
currentLanguage.BindValueChanged(_ => Schedule(updateValueDisplay));
current.BindValueChanged(_ =>
{
updateState();
updateTextBoxFromSlider();
updateValueDisplay();
}, true);
}
@ -258,7 +265,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
background.Colour = colourProvider.Background5;
}
private void updateTextBoxFromSlider()
private void updateValueDisplay()
{
if (updatingFromTextBox) return;