diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs index f96d272e40..fb18cc8a59 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneOverallRanking.cs @@ -105,6 +105,40 @@ namespace osu.Game.Tests.Visual.Ranking displayUpdate(statistics, statistics); } + [Test] + public void TestFromNothing() + { + createDisplay(); + displayUpdate( + new UserStatistics(), + new UserStatistics + { + GlobalRank = 12_345, + Accuracy = 98.99, + MaxCombo = 2_322, + RankedScore = 23_123_543_456, + TotalScore = 123_123_543_456, + PP = 5_072 + }); + } + + [Test] + public void TestToNothing() + { + createDisplay(); + displayUpdate( + new UserStatistics + { + GlobalRank = 12_345, + Accuracy = 98.99, + MaxCombo = 2_322, + RankedScore = 23_123_543_456, + TotalScore = 123_123_543_456, + PP = 5_072 + }, + new UserStatistics()); + } + private void createDisplay() => AddStep("create display", () => { statisticsUpdate.Value = null; diff --git a/osu.Game/Screens/Ranking/Statistics/User/GlobalRankChangeRow.cs b/osu.Game/Screens/Ranking/Statistics/User/GlobalRankChangeRow.cs index 0d91d6f8f9..5ffea094cd 100644 --- a/osu.Game/Screens/Ranking/Statistics/User/GlobalRankChangeRow.cs +++ b/osu.Game/Screens/Ranking/Statistics/User/GlobalRankChangeRow.cs @@ -2,9 +2,9 @@ // See the LICENCE file in the repository root for full licence text. using System.Diagnostics; +using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Localisation; using osu.Game.Resources.Localisation.Web; -using osu.Game.Utils; namespace osu.Game.Screens.Ranking.Statistics.User { @@ -18,7 +18,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User protected override LocalisableString Label => UsersStrings.ShowRankGlobalSimple; protected override LocalisableString FormatCurrentValue(int? current) - => current == null ? string.Empty : current.Value.FormatRank(); + => current?.ToLocalisableString(@"N0") ?? string.Empty; protected override int CalculateDifference(int? previous, int? current, out LocalisableString formattedDifference) { @@ -30,13 +30,13 @@ namespace osu.Game.Screens.Ranking.Statistics.User if (previous == null && current != null) { - formattedDifference = LocalisableString.Interpolate($"+{current.Value.FormatRank()}"); + formattedDifference = LocalisableString.Interpolate($"+{current.Value:N0}"); return 1; } if (previous != null && current == null) { - formattedDifference = LocalisableString.Interpolate($"-{previous.Value.FormatRank()}"); + formattedDifference = LocalisableString.Interpolate($"-{previous.Value:N0}"); return -1; } @@ -46,9 +46,9 @@ namespace osu.Game.Screens.Ranking.Statistics.User int difference = previous.Value - current.Value; if (difference < 0) - formattedDifference = difference.FormatRank(); + formattedDifference = difference.ToLocalisableString(@"N0"); else if (difference > 0) - formattedDifference = LocalisableString.Interpolate($"+{difference.FormatRank()}"); + formattedDifference = LocalisableString.Interpolate($"+{difference:N0}"); else formattedDifference = string.Empty;