From b82ed3f1674520ae8680e845d873eb88d39130d5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Oct 2021 14:23:53 +0900 Subject: [PATCH 01/10] Fix potential blocking operation on OrderByTotalScoreAsync() In reality this wouldn't be a long process, but the blocking is really noticeable if you add a Task.Delay(1000) in GetTotalScoreAsync(). --- osu.Game/Scoring/ScoreManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index dde956233b..5481eea4aa 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -72,9 +72,12 @@ namespace osu.Game.Scoring } } - // We're calling .Result, but this should not be a blocking call due to the above GetDifficultyAsync() calls. - return scores.OrderByDescending(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken).Result) - .ThenBy(s => s.OnlineScoreID) + var totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false); + + return scores.Select((s, i) => (index: i, score: s)) + .OrderByDescending(key => totalScores[key.index]) + .ThenBy(key => key.score.OnlineScoreID) + .Select(key => key.score) .ToArray(); } From d6ac6a5cd60263ae778ebb488541e1a28a65a1c8 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Oct 2021 15:18:01 +0900 Subject: [PATCH 02/10] Fix intermittent results screen test failures --- .../TestScenePlaylistsResultsScreen.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs index 4bcc887b9f..d948aebbbf 100644 --- a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs +++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistsResultsScreen.cs @@ -32,12 +32,14 @@ namespace osu.Game.Tests.Visual.Playlists private TestResultsScreen resultsScreen; private int currentScoreId; private bool requestComplete; + private int totalCount; [SetUp] public void Setup() => Schedule(() => { currentScoreId = 0; requestComplete = false; + totalCount = 0; bindHandler(); }); @@ -53,7 +55,6 @@ namespace osu.Game.Tests.Visual.Playlists }); createResults(() => userScore); - waitForDisplay(); AddAssert("user score selected", () => this.ChildrenOfType().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded); } @@ -62,7 +63,6 @@ namespace osu.Game.Tests.Visual.Playlists public void TestShowNullUserScore() { createResults(); - waitForDisplay(); AddAssert("top score selected", () => this.ChildrenOfType().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded); } @@ -79,7 +79,6 @@ namespace osu.Game.Tests.Visual.Playlists }); createResults(() => userScore); - waitForDisplay(); AddAssert("more than 1 panel displayed", () => this.ChildrenOfType().Count() > 1); AddAssert("user score selected", () => this.ChildrenOfType().Single(p => p.Score.OnlineScoreID == userScore.OnlineScoreID).State == PanelState.Expanded); @@ -91,7 +90,6 @@ namespace osu.Game.Tests.Visual.Playlists AddStep("bind delayed handler", () => bindHandler(true)); createResults(); - waitForDisplay(); AddAssert("top score selected", () => this.ChildrenOfType().OrderByDescending(p => p.Score.TotalScore).First().State == PanelState.Expanded); } @@ -100,7 +98,6 @@ namespace osu.Game.Tests.Visual.Playlists public void TestFetchWhenScrolledToTheRight() { createResults(); - waitForDisplay(); AddStep("bind delayed handler", () => bindHandler(true)); @@ -131,7 +128,6 @@ namespace osu.Game.Tests.Visual.Playlists }); createResults(() => userScore); - waitForDisplay(); AddStep("bind delayed handler", () => bindHandler(true)); @@ -161,13 +157,15 @@ namespace osu.Game.Tests.Visual.Playlists })); }); - AddUntilStep("wait for load", () => resultsScreen.ChildrenOfType().FirstOrDefault()?.AllPanelsVisible == true); + waitForDisplay(); } private void waitForDisplay() { - AddUntilStep("wait for request to complete", () => requestComplete); - AddUntilStep("wait for panels to be visible", () => resultsScreen.ChildrenOfType().FirstOrDefault()?.AllPanelsVisible == true); + AddUntilStep("wait for load to complete", () => + requestComplete + && resultsScreen.ScorePanelList.GetScorePanels().Count() == totalCount + && resultsScreen.ScorePanelList.AllPanelsVisible); AddWaitStep("wait for display", 5); } @@ -203,6 +201,7 @@ namespace osu.Game.Tests.Visual.Playlists triggerFail(s); else triggerSuccess(s, createUserResponse(userScore)); + break; case IndexPlaylistScoresRequest i: @@ -248,6 +247,8 @@ namespace osu.Game.Tests.Visual.Playlists } }; + totalCount++; + for (int i = 1; i <= scores_per_result; i++) { multiplayerUserScore.ScoresAround.Lower.Scores.Add(new MultiplayerScore @@ -285,6 +286,8 @@ namespace osu.Game.Tests.Visual.Playlists }, Statistics = userScore.Statistics }); + + totalCount += 2; } addCursor(multiplayerUserScore.ScoresAround.Lower); @@ -325,6 +328,8 @@ namespace osu.Game.Tests.Visual.Playlists { HitResult.Great, 300 } } }); + + totalCount++; } addCursor(result); From f199d6c5212c360fb9c2c16b70d21d3e9730c7dd Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 8 Oct 2021 15:26:25 +0900 Subject: [PATCH 03/10] Fix another related test failure --- .../Visual/UserInterface/TestSceneDeleteLocalScore.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs index 189b143a35..9a75d3c309 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs @@ -163,7 +163,6 @@ namespace osu.Game.Tests.Visual.UserInterface }); AddUntilStep("wait for fetch", () => leaderboard.Scores != null); - AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != scoreBeingDeleted.OnlineScoreID)); } @@ -171,6 +170,7 @@ namespace osu.Game.Tests.Visual.UserInterface public void TestDeleteViaDatabase() { AddStep("delete top score", () => scoreManager.Delete(importedScores[0])); + AddUntilStep("wait for fetch", () => leaderboard.Scores != null); AddUntilStep("score removed from leaderboard", () => leaderboard.Scores.All(s => s.OnlineScoreID != importedScores[0].OnlineScoreID)); } } From c49d0a501335832ecef06f02a79750cdf6c1ec97 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sun, 10 Oct 2021 15:43:24 +0900 Subject: [PATCH 04/10] Rewrite query to be easier to understand --- osu.Game/Scoring/ScoreManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 5481eea4aa..236e8a4448 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -74,10 +74,9 @@ namespace osu.Game.Scoring var totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false); - return scores.Select((s, i) => (index: i, score: s)) - .OrderByDescending(key => totalScores[key.index]) - .ThenBy(key => key.score.OnlineScoreID) - .Select(key => key.score) + return scores.Select((score, index) => (score: score, totalScore: totalScores[index])) + .OrderByDescending(g => g.totalScore) + .Select(g => g.score) .ToArray(); } From 4475697a9c55897219fc79cf032f2f3da2b5d2ee Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Sun, 10 Oct 2021 15:47:39 +0900 Subject: [PATCH 05/10] Add score id key --- osu.Game/Scoring/ScoreManager.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 236e8a4448..c5d475d631 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -76,6 +76,7 @@ namespace osu.Game.Scoring return scores.Select((score, index) => (score: score, totalScore: totalScores[index])) .OrderByDescending(g => g.totalScore) + .ThenBy(g => g.score.OnlineScoreID) .Select(g => g.score) .ToArray(); } From 49a878dc20ce004169333f86021e02f528a6cf9b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 10 Oct 2021 16:04:41 +0900 Subject: [PATCH 06/10] Fix comma separator support not actually working --- osu.Game/Graphics/UserInterface/ScoreCounter.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 7ebf3819e4..069810d736 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; @@ -29,6 +30,9 @@ namespace osu.Game.Graphics.UserInterface { UseCommaSeparator = useCommaSeparator; + if (useCommaSeparator && leading > 0) + throw new ArgumentException("Should not mix leading zeroes and comma separators as it doesn't make sense"); + RequiredDisplayDigits.Value = leading; RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay()); } @@ -41,14 +45,15 @@ namespace osu.Game.Graphics.UserInterface protected override LocalisableString FormatCount(double count) { string format = new string('0', RequiredDisplayDigits.Value); + var output = ((long)count).ToString(format); if (UseCommaSeparator) { - for (int i = format.Length - 3; i > 0; i -= 3) - format = format.Insert(i, @","); + for (int i = output.Length - 3; i > 0; i -= 3) + output = output.Insert(i, @","); } - return ((long)count).ToString(format); + return output; } protected override OsuSpriteText CreateSpriteText() From 446f091d329db500d7915aa53d75bb8232a6a3f5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 10 Oct 2021 16:06:12 +0900 Subject: [PATCH 07/10] Use comma separator for tournament score displays --- .../Gameplay/Components/TournamentMatchScoreDisplay.cs | 1 + osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs index 994dee4da0..3624c08187 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs @@ -132,6 +132,7 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components private OsuSpriteText displayedSpriteText; public MatchScoreCounter() + : base(useCommaSeparator: true) { Margin = new MarginPadding { Top = bar_height, Horizontal = 10 }; } diff --git a/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs b/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs index d04e60a2ab..37282205f4 100644 --- a/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs +++ b/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs @@ -4,11 +4,9 @@ using System; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Localisation; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; @@ -153,6 +151,7 @@ namespace osu.Game.Screens.Play.HUD private OsuSpriteText displayedSpriteText; public MatchScoreCounter() + : base(useCommaSeparator: true) { Margin = new MarginPadding { Top = bar_height, Horizontal = 10 }; } @@ -173,8 +172,6 @@ namespace osu.Game.Screens.Play.HUD => displayedSpriteText.Font = winning ? OsuFont.Torus.With(weight: FontWeight.Bold, size: font_size, fixedWidth: true) : OsuFont.Torus.With(weight: FontWeight.Regular, size: font_size * 0.8f, fixedWidth: true); - - protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"N0"); } } } From 6d6de5b677353235e9a667c17964ef30fb2d1b73 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 10 Oct 2021 16:50:55 +0900 Subject: [PATCH 08/10] Remove redundant tuple naming --- osu.Game/Scoring/ScoreManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index c5d475d631..cf22a8fda4 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -74,7 +74,7 @@ namespace osu.Game.Scoring var totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false); - return scores.Select((score, index) => (score: score, totalScore: totalScores[index])) + return scores.Select((score, index) => (score, totalScore: totalScores[index])) .OrderByDescending(g => g.totalScore) .ThenBy(g => g.score.OnlineScoreID) .Select(g => g.score) From 06cce0119c4549cd0f67c98fe08a617cda470040 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 10 Oct 2021 17:41:16 +0900 Subject: [PATCH 09/10] Use localisable format string for comma separator mode --- .../Graphics/UserInterface/ScoreCounter.cs | 39 ++++++++----------- .../Screens/Play/HUD/DefaultScoreCounter.cs | 1 - .../Screens/Play/HUD/GameplayScoreCounter.cs | 4 +- osu.Game/Skinning/LegacyScoreCounter.cs | 1 - 4 files changed, 19 insertions(+), 26 deletions(-) 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; From 794b4c46cf9c93ddf9c1294a722f3e4114d11e0d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 10 Oct 2021 17:56:32 +0900 Subject: [PATCH 10/10] Split score counter class into two distinct classes to simplify usages --- .../Components/TournamentMatchScoreDisplay.cs | 3 +-- .../CommaSeparatedScoreCounter.cs | 24 +++++++++++++++++++ .../Graphics/UserInterface/ScoreCounter.cs | 20 ++++------------ .../Screens/Play/HUD/MatchScoreDisplay.cs | 3 +-- 4 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 osu.Game/Graphics/UserInterface/CommaSeparatedScoreCounter.cs diff --git a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs index 3624c08187..77101e4023 100644 --- a/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs +++ b/osu.Game.Tournament/Screens/Gameplay/Components/TournamentMatchScoreDisplay.cs @@ -127,12 +127,11 @@ namespace osu.Game.Tournament.Screens.Gameplay.Components score2Text.X = Math.Max(5 + score2Text.DrawWidth / 2, score2Bar.DrawWidth); } - private class MatchScoreCounter : ScoreCounter + private class MatchScoreCounter : CommaSeparatedScoreCounter { private OsuSpriteText displayedSpriteText; public MatchScoreCounter() - : base(useCommaSeparator: true) { Margin = new MarginPadding { Top = bar_height, Horizontal = 10 }; } diff --git a/osu.Game/Graphics/UserInterface/CommaSeparatedScoreCounter.cs b/osu.Game/Graphics/UserInterface/CommaSeparatedScoreCounter.cs new file mode 100644 index 0000000000..4e1c612f09 --- /dev/null +++ b/osu.Game/Graphics/UserInterface/CommaSeparatedScoreCounter.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Extensions.LocalisationExtensions; +using osu.Framework.Graphics; +using osu.Framework.Localisation; +using osu.Game.Graphics.Sprites; + +namespace osu.Game.Graphics.UserInterface +{ + public abstract class CommaSeparatedScoreCounter : RollingCounter + { + protected override double RollingDuration => 1000; + protected override Easing RollingEasing => Easing.Out; + + protected override double GetProportionalDuration(double currentValue, double newValue) => + currentValue > newValue ? currentValue - newValue : newValue - currentValue; + + protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(@"N0"); + + protected override OsuSpriteText CreateSpriteText() + => base.CreateSpriteText().With(s => s.Font = s.Font.With(fixedWidth: true)); + } +} diff --git a/osu.Game/Graphics/UserInterface/ScoreCounter.cs b/osu.Game/Graphics/UserInterface/ScoreCounter.cs index 778b0ecbc6..25f19aa0a9 100644 --- a/osu.Game/Graphics/UserInterface/ScoreCounter.cs +++ b/osu.Game/Graphics/UserInterface/ScoreCounter.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Bindables; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; @@ -17,23 +16,14 @@ namespace osu.Game.Graphics.UserInterface public Bindable RequiredDisplayDigits { get; } = new Bindable(); - private string formatString = string.Empty; + private string formatString; /// /// Displays score. /// /// How many leading zeroes the counter will have. - /// Whether comma separators should be displayed. - protected ScoreCounter(int leading = 0, bool useCommaSeparator = false) + protected ScoreCounter(int leading = 0) { - if (useCommaSeparator) - { - if (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(displayDigitsChanged, true); } @@ -44,10 +34,8 @@ namespace osu.Game.Graphics.UserInterface UpdateDisplay(); } - protected override double GetProportionalDuration(double currentValue, double newValue) - { - return currentValue > newValue ? currentValue - newValue : newValue - currentValue; - } + protected override double GetProportionalDuration(double currentValue, double newValue) => + currentValue > newValue ? currentValue - newValue : newValue - currentValue; protected override LocalisableString FormatCount(double count) => ((long)count).ToLocalisableString(formatString); diff --git a/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs b/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs index 37282205f4..b1c07512dd 100644 --- a/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs +++ b/osu.Game/Screens/Play/HUD/MatchScoreDisplay.cs @@ -146,12 +146,11 @@ namespace osu.Game.Screens.Play.HUD Score2Text.X = Math.Max(5 + Score2Text.DrawWidth / 2, score2Bar.DrawWidth); } - protected class MatchScoreCounter : ScoreCounter + protected class MatchScoreCounter : CommaSeparatedScoreCounter { private OsuSpriteText displayedSpriteText; public MatchScoreCounter() - : base(useCommaSeparator: true) { Margin = new MarginPadding { Top = bar_height, Horizontal = 10 }; }