Skip to content

Commit

Permalink
Fix improper handling of decimal separator in "form" number boxes / s…
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Oct 4, 2024
1 parent 4fc0aae commit 45a6a74
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion osu.Game/Graphics/UserInterfaceV2/FormNumberBox.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +20,7 @@ internal partial class InnerNumberBox : InnerTextBox
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));
}
}
}
13 changes: 10 additions & 3 deletions osu.Game/Graphics/UserInterfaceV2/FormSliderBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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
Expand Down Expand Up @@ -83,8 +84,10 @@ public CompositeDrawable? TabbableContentContainer
[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;
Expand Down Expand Up @@ -150,6 +153,9 @@ private void load(OsuColour colours)
},
},
};

if (game != null)
currentLanguage.BindTo(game.CurrentLanguage);
}

protected override void LoadComplete()
Expand All @@ -164,10 +170,11 @@ protected override void LoadComplete()

slider.IsDragging.BindValueChanged(_ => updateState());

currentLanguage.BindValueChanged(_ => Schedule(updateValueDisplay));
current.BindValueChanged(_ =>
{
updateState();
updateTextBoxFromSlider();
updateValueDisplay();
}, true);
}

Expand Down Expand Up @@ -258,7 +265,7 @@ private void updateState()
background.Colour = colourProvider.Background5;
}

private void updateTextBoxFromSlider()
private void updateValueDisplay()
{
if (updatingFromTextBox) return;

Expand Down

0 comments on commit 45a6a74

Please sign in to comment.