diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboardProvider.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboardProvider.cs index 964f53c973..5ba6b5432c 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboardProvider.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSoloGameplayLeaderboardProvider.cs @@ -37,6 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay TotalScore = 10_000 * (100 - i), Position = i, }).ToArray(), + 1337, null ); }); @@ -83,6 +84,7 @@ namespace osu.Game.Tests.Visual.Gameplay TotalScore = 600_000 + 10_000 * (40 - i), Position = i, }).ToArray(), + 1337, null ); }); @@ -129,6 +131,7 @@ namespace osu.Game.Tests.Visual.Gameplay TotalScore = 500_000 + 10_000 * (50 - i), Position = i }).ToArray(), + 1337, new ScoreInfo { TotalScore = 200_000 } ); }); diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapLeaderboardWedge.cs b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapLeaderboardWedge.cs index 61d23c4513..992651d73c 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapLeaderboardWedge.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestSceneBeatmapLeaderboardWedge.cs @@ -312,7 +312,8 @@ namespace osu.Game.Tests.Visual.SongSelectV2 Username = @"waaiiru", CountryCode = CountryCode.ES, }, - }); + Date = DateTimeOffset.Now, + }, 1234567); } private void showPersonalBest() @@ -332,8 +333,9 @@ namespace osu.Game.Tests.Visual.SongSelectV2 Id = 6602580, Username = @"waaiiru", CountryCode = CountryCode.ES, - } - }); + }, + Date = DateTimeOffset.Now, + }, 1234567); } private void setScope(BeatmapLeaderboardScope scope) @@ -364,7 +366,7 @@ namespace osu.Game.Tests.Visual.SongSelectV2 private partial class TestBeatmapLeaderboardWedge : BeatmapLeaderboardWedge { public new void SetState(LeaderboardState state) => base.SetState(state); - public new void SetScores(IEnumerable scores, ScoreInfo? userScore = null) => base.SetScores(scores, userScore); + public new void SetScores(IEnumerable scores, ScoreInfo? userScore = null, int? totalCount = null) => base.SetScores(scores, userScore, totalCount); } } } diff --git a/osu.Game/Online/API/Requests/Responses/APIScoresCollection.cs b/osu.Game/Online/API/Requests/Responses/APIScoresCollection.cs index 4ef39be5e5..ae73e377c4 100644 --- a/osu.Game/Online/API/Requests/Responses/APIScoresCollection.cs +++ b/osu.Game/Online/API/Requests/Responses/APIScoresCollection.cs @@ -10,6 +10,9 @@ namespace osu.Game.Online.API.Requests.Responses { public class APIScoresCollection { + [JsonProperty(@"score_count")] + public int ScoresCount; + [JsonProperty(@"scores")] public List Scores; diff --git a/osu.Game/Online/Leaderboards/LeaderboardManager.cs b/osu.Game/Online/Leaderboards/LeaderboardManager.cs index 4aca3b1a4a..d5d1672e1b 100644 --- a/osu.Game/Online/Leaderboards/LeaderboardManager.cs +++ b/osu.Game/Online/Leaderboards/LeaderboardManager.cs @@ -133,6 +133,7 @@ namespace osu.Game.Online.Leaderboards return s; }) .ToArray(), + response.ScoresCount, response.UserScore?.CreateScoreInfo(rulesets, newCriteria.Beatmap) ); inFlightOnlineRequest = null; @@ -181,7 +182,8 @@ namespace osu.Game.Online.Leaderboards newScores = newScores.Detach().OrderByTotalScore(); - scores.Value = LeaderboardScores.Success(newScores.ToArray(), null); + var newScoresArray = newScores.ToArray(); + scores.Value = LeaderboardScores.Success(newScoresArray, newScoresArray.Length, null); } } @@ -195,6 +197,7 @@ namespace osu.Game.Online.Leaderboards public record LeaderboardScores { public ICollection TopScores { get; } + public int TotalScores { get; } public ScoreInfo? UserScore { get; } public LeaderboardFailState? FailState { get; } @@ -210,15 +213,16 @@ namespace osu.Game.Online.Leaderboards } } - private LeaderboardScores(ICollection topScores, ScoreInfo? userScore, LeaderboardFailState? failState) + private LeaderboardScores(ICollection topScores, int totalScores, ScoreInfo? userScore, LeaderboardFailState? failState) { TopScores = topScores; + TotalScores = totalScores; UserScore = userScore; FailState = failState; } - public static LeaderboardScores Success(ICollection topScores, ScoreInfo? userScore) => new LeaderboardScores(topScores, userScore, null); - public static LeaderboardScores Failure(LeaderboardFailState failState) => new LeaderboardScores([], null, failState); + public static LeaderboardScores Success(ICollection topScores, int totalScores, ScoreInfo? userScore) => new LeaderboardScores(topScores, totalScores, userScore, null); + public static LeaderboardScores Failure(LeaderboardFailState failState) => new LeaderboardScores([], 0, null, failState); } public enum LeaderboardFailState