diff --git a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs index 4a38f98810..b30d6b1546 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestCaseBeatmapScoresContainer.cs @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.SongSelect } }; - IEnumerable scores = new[] + var scores = new List { new ScoreInfo { diff --git a/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs index 15ec5d3b13..c629caaa6f 100644 --- a/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs +++ b/osu.Game/Online/API/Requests/Responses/APILegacyScores.cs @@ -9,6 +9,6 @@ namespace osu.Game.Online.API.Requests.Responses public class APILegacyScores { [JsonProperty(@"scores")] - public IEnumerable Scores; + public List Scores; } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs index 08e73da841..ada442d50e 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTable.cs @@ -48,24 +48,27 @@ namespace osu.Game.Overlays.BeatmapSet.Scores }; } - public IEnumerable Scores + public IReadOnlyList Scores { set { if (value == null || !value.Any()) return; - var content = new List { new ScoreTableHeaderRow().CreateDrawables().ToArray() }; - - int index = 0; - foreach (var s in value) - content.Add(new ScoreTableScoreRow(index++, s).CreateDrawables().ToArray()); - - scoresGrid.Content = content.ToArray(); + var content = new List + { + new ScoreTableHeaderRow(value.First()).CreateDrawables().ToArray() + }; backgroundFlow.Clear(); - for (int i = 0; i < index; i++) + + for (int i = 0; i < value.Count; i++) + { + content.Add(new ScoreTableScoreRow(i, value[i]).CreateDrawables().ToArray()); backgroundFlow.Add(new ScoreTableRowBackground(i)); + } + + scoresGrid.Content = content.ToArray(); } } diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs index a48716b71a..c73543eb10 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableHeaderRow.cs @@ -2,15 +2,24 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Scoring; namespace osu.Game.Overlays.BeatmapSet.Scores { public class ScoreTableHeaderRow : ScoreTableRow { + private readonly ScoreInfo score; + + public ScoreTableHeaderRow(ScoreInfo score) + { + this.score = score; + } + protected override Drawable CreateIndexCell() => new CellText("rank"); protected override Drawable CreateRankCell() => new Container(); @@ -21,14 +30,13 @@ namespace osu.Game.Overlays.BeatmapSet.Scores protected override Drawable CreatePlayerCell() => new CellText("player"); - protected override IEnumerable CreateStatisticsCells() => new[] + protected override IEnumerable CreateStatisticsCells() { - new CellText("max combo"), - new CellText("300"), - new CellText("100"), - new CellText("50"), - new CellText("miss"), - }; + yield return new CellText("max combo"); + + foreach (var kvp in score.Statistics) + yield return new CellText(kvp.Key.GetDescription()); + } protected override Drawable CreatePpCell() => new CellText("pp"); diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs index 83901cc662..2cb16a5785 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoreTableScoreRow.cs @@ -10,7 +10,6 @@ using osu.Framework.Input.Events; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Leaderboards; -using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Scoring; using osu.Game.Users; @@ -74,33 +73,15 @@ namespace osu.Game.Overlays.BeatmapSet.Scores Font = OsuFont.GetFont(size: TEXT_SIZE) }; - yield return new OsuSpriteText + foreach (var kvp in score.Statistics) { - Text = $"{score.Statistics[HitResult.Great]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Great] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Good]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Good] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Meh]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Meh] == 0 ? Color4.Gray : Color4.White - }; - - yield return new OsuSpriteText - { - Text = $"{score.Statistics[HitResult.Miss]}", - Font = OsuFont.GetFont(size: TEXT_SIZE), - Colour = score.Statistics[HitResult.Miss] == 0 ? Color4.Gray : Color4.White - }; + yield return new OsuSpriteText + { + Text = $"{kvp.Value}", + Font = OsuFont.GetFont(size: TEXT_SIZE), + Colour = kvp.Value == 0 ? Color4.Gray : Color4.White + }; + } } protected override Drawable CreatePpCell() => new OsuSpriteText diff --git a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs index a29d812088..de080732f9 100644 --- a/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs +++ b/osu.Game/Overlays/BeatmapSet/Scores/ScoresContainer.cs @@ -83,9 +83,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores } private GetScoresRequest getScoresRequest; - private IEnumerable scores; + private IReadOnlyList scores; - public IEnumerable Scores + public IReadOnlyList Scores { get => scores; set @@ -121,11 +121,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores private void updateDisplay() { - scoreTable.Scores = Enumerable.Empty(); + scoreTable.Scores = new List(); loading = false; - var scoreCount = scores?.Count() ?? 0; + var scoreCount = scores?.Count ?? 0; if (scoreCount == 0) {