mirror of
https://github.com/ppy/osu.git
synced 2026-05-18 11:20:24 +08:00
Expose total scores count from backend
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
});
|
||||
|
||||
@@ -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<ScoreInfo> scores, ScoreInfo? userScore = null) => base.SetScores(scores, userScore);
|
||||
public new void SetScores(IEnumerable<ScoreInfo> scores, ScoreInfo? userScore = null, int? totalCount = null) => base.SetScores(scores, userScore, totalCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIScoresCollection
|
||||
{
|
||||
[JsonProperty(@"score_count")]
|
||||
public int ScoresCount;
|
||||
|
||||
[JsonProperty(@"scores")]
|
||||
public List<SoloScoreInfo> Scores;
|
||||
|
||||
|
||||
@@ -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<ScoreInfo> 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<ScoreInfo> topScores, ScoreInfo? userScore, LeaderboardFailState? failState)
|
||||
private LeaderboardScores(ICollection<ScoreInfo> topScores, int totalScores, ScoreInfo? userScore, LeaderboardFailState? failState)
|
||||
{
|
||||
TopScores = topScores;
|
||||
TotalScores = totalScores;
|
||||
UserScore = userScore;
|
||||
FailState = failState;
|
||||
}
|
||||
|
||||
public static LeaderboardScores Success(ICollection<ScoreInfo> topScores, ScoreInfo? userScore) => new LeaderboardScores(topScores, userScore, null);
|
||||
public static LeaderboardScores Failure(LeaderboardFailState failState) => new LeaderboardScores([], null, failState);
|
||||
public static LeaderboardScores Success(ICollection<ScoreInfo> 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
|
||||
|
||||
Reference in New Issue
Block a user