Fix multiplayer aggregate score inheriting from ScoreInfo

This commit is contained in:
Dean Herbert
2019-12-03 16:10:25 +09:00
parent bb00b4166e
commit 36224dca13
7 changed files with 63 additions and 32 deletions

View File

@ -13,9 +13,9 @@ using osu.Game.Online.Multiplayer;
namespace osu.Game.Screens.Multi.Match.Components
{
public class MatchLeaderboard : Leaderboard<MatchLeaderboardScope, APIRoomScoreInfo>
public class MatchLeaderboard : Leaderboard<MatchLeaderboardScope, APIUserScoreAggregate>
{
public Action<IEnumerable<APIRoomScoreInfo>> ScoresLoaded;
public Action<IEnumerable<APIUserScoreAggregate>> ScoresLoaded;
[Resolved(typeof(Room), nameof(Room.RoomID))]
private Bindable<int?> roomId { get; set; }
@ -35,7 +35,7 @@ namespace osu.Game.Screens.Multi.Match.Components
protected override bool IsOnlineScope => true;
protected override APIRequest FetchScores(Action<IEnumerable<APIRoomScoreInfo>> scoresCallback)
protected override APIRequest FetchScores(Action<IEnumerable<APIUserScoreAggregate>> scoresCallback)
{
if (roomId.Value == null)
return null;
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Multi.Match.Components
return req;
}
protected override LeaderboardScore CreateDrawableScore(APIRoomScoreInfo model, int index) => new MatchLeaderboardScore(model, index);
protected override LeaderboardScore CreateDrawableScore(APIUserScoreAggregate model, int index) => new MatchLeaderboardScore(model, index);
}
public enum MatchLeaderboardScope

View File

@ -12,9 +12,12 @@ namespace osu.Game.Screens.Multi.Match.Components
{
public class MatchLeaderboardScore : LeaderboardScore
{
public MatchLeaderboardScore(APIRoomScoreInfo score, int rank)
: base(score, rank)
private readonly APIUserScoreAggregate score;
public MatchLeaderboardScore(APIUserScoreAggregate score, int rank)
: base(score.CreateScoreInfo(), rank)
{
this.score = score;
}
[BackgroundDependencyLoader]
@ -26,8 +29,8 @@ namespace osu.Game.Screens.Multi.Match.Components
protected override IEnumerable<LeaderboardScoreStatistic> GetStatistics(ScoreInfo model) => new[]
{
new LeaderboardScoreStatistic(FontAwesome.Solid.Crosshairs, "Accuracy", string.Format(model.Accuracy % 1 == 0 ? @"{0:P0}" : @"{0:P2}", model.Accuracy)),
new LeaderboardScoreStatistic(FontAwesome.Solid.Sync, "Total Attempts", ((APIRoomScoreInfo)model).TotalAttempts.ToString()),
new LeaderboardScoreStatistic(FontAwesome.Solid.Check, "Completed Beatmaps", ((APIRoomScoreInfo)model).CompletedBeatmaps.ToString()),
new LeaderboardScoreStatistic(FontAwesome.Solid.Sync, "Total Attempts", score.TotalAttempts.ToString()),
new LeaderboardScoreStatistic(FontAwesome.Solid.Check, "Completed Beatmaps", score.CompletedBeatmaps.ToString()),
};
}
}

View File

@ -74,7 +74,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
leaderboard.ScoresLoaded = scoresLoaded;
}
private void scoresLoaded(IEnumerable<APIRoomScoreInfo> scores)
private void scoresLoaded(IEnumerable<APIUserScoreAggregate> scores)
{
void gray(SpriteText s) => s.Colour = colours.GrayC;
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
rankText.AddText(name + "\n", white);
rankText.AddText("You are placed ", gray);
int index = scores.IndexOf(new APIRoomScoreInfo { User = Score.User }, new FuncEqualityComparer<APIRoomScoreInfo>((s1, s2) => s1.User.Id.Equals(s2.User.Id)));
int index = scores.IndexOf(new APIUserScoreAggregate { User = Score.User }, new FuncEqualityComparer<APIUserScoreAggregate>((s1, s2) => s1.User.Id.Equals(s2.User.Id)));
rankText.AddText($"#{index + 1} ", s =>
{
@ -104,7 +104,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
{
protected override bool FadeTop => true;
protected override LeaderboardScore CreateDrawableScore(APIRoomScoreInfo model, int index)
protected override LeaderboardScore CreateDrawableScore(APIUserScoreAggregate model, int index)
=> new ResultsMatchLeaderboardScore(model, index);
protected override FillFlowContainer<LeaderboardScore> CreateScoreFlow()
@ -120,7 +120,7 @@ namespace osu.Game.Screens.Multi.Ranking.Pages
private class ResultsMatchLeaderboardScore : MatchLeaderboardScore
{
public ResultsMatchLeaderboardScore(APIRoomScoreInfo score, int rank)
public ResultsMatchLeaderboardScore(APIUserScoreAggregate score, int rank)
: base(score, rank)
{
}