diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs
index 069810d736..778b0ecbc6 100644
--- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs
+++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs
@@ -3,6 +3,7 @@
using System;
using osu.Framework.Bindables;
+using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Graphics.Sprites;
@@ -14,13 +15,10 @@ namespace osu.Game.Graphics.UserInterface
protected override double RollingDuration => 1000;
protected override Easing RollingEasing => Easing.Out;
- ///
- /// Whether comma separators should be displayed.
- ///
- public bool UseCommaSeparator { get; }
-
public Bindable RequiredDisplayDigits { get; } = new Bindable();
+ private string formatString = string.Empty;
+
///
/// Displays score.
///
@@ -28,13 +26,22 @@ namespace osu.Game.Graphics.UserInterface
/// Whether comma separators should be displayed.
protected ScoreCounter(int leading = 0, bool useCommaSeparator = false)
{
- UseCommaSeparator = useCommaSeparator;
+ if (useCommaSeparator)
+ {
+ if (leading > 0)
+ throw new ArgumentException("Should not mix leading zeroes and comma separators as it doesn't make sense");
- if (useCommaSeparator && leading > 0)
- throw new ArgumentException("Should not mix leading zeroes and comma separators as it doesn't make sense");
+ formatString = @"N0";
+ }
RequiredDisplayDigits.Value = leading;
- RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
+ RequiredDisplayDigits.BindValueChanged(displayDigitsChanged, true);
+ }
+
+ private void displayDigitsChanged(ValueChangedEvent _)
+ {
+ formatString = new string('0', RequiredDisplayDigits.Value);
+ UpdateDisplay();
}
protected override double GetProportionalDuration(double currentValue, double newValue)
@@ -42,19 +49,7 @@ namespace osu.Game.Graphics.UserInterface
return currentValue > newValue ? currentValue - newValue : newValue - currentValue;
}
- protected override LocalisableString FormatCount(double count)
- {
- string format = new string('0', RequiredDisplayDigits.Value);
- var output = ((long)count).ToString(format);
-
- if (UseCommaSeparator)
- {
- for (int i = output.Length - 3; i > 0; i -= 3)
- output = output.Insert(i, @",");
- }
-
- return output;
- }
+ protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(formatString);
protected override OsuSpriteText CreateSpriteText()
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true));
diff --git a/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs b/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs
index 63de5c8de5..87b19e8433 100644
--- a/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs
+++ b/osu.Game/Screens/Play/HUD/DefaultScoreCounter.cs
@@ -11,7 +11,6 @@ namespace osu.Game.Screens.Play.HUD
public class DefaultScoreCounter : GameplayScoreCounter, ISkinnableDrawable
{
public DefaultScoreCounter()
- : base(6)
{
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
diff --git a/osu.Game/Screens/Play/HUD/GameplayScoreCounter.cs b/osu.Game/Screens/Play/HUD/GameplayScoreCounter.cs
index e09630d2c4..e05eff5f3e 100644
--- a/osu.Game/Screens/Play/HUD/GameplayScoreCounter.cs
+++ b/osu.Game/Screens/Play/HUD/GameplayScoreCounter.cs
@@ -14,8 +14,8 @@ namespace osu.Game.Screens.Play.HUD
{
private Bindable scoreDisplayMode;
- protected GameplayScoreCounter(int leading = 0, bool useCommaSeparator = false)
- : base(leading, useCommaSeparator)
+ protected GameplayScoreCounter()
+ : base(6)
{
}
diff --git a/osu.Game/Skinning/LegacyScoreCounter.cs b/osu.Game/Skinning/LegacyScoreCounter.cs
index a12defe87e..0c9a82074f 100644
--- a/osu.Game/Skinning/LegacyScoreCounter.cs
+++ b/osu.Game/Skinning/LegacyScoreCounter.cs
@@ -16,7 +16,6 @@ namespace osu.Game.Skinning
public bool UsesFixedAnchor { get; set; }
public LegacyScoreCounter()
- : base(6)
{
Anchor = Anchor.TopRight;
Origin = Anchor.TopRight;