1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 04:23:00 +08:00

Fix incorrect display in beatmap overlay table

This commit is contained in:
smoogipoo 2020-09-25 20:48:16 +09:00
parent a07597c369
commit 2517fffb7e

View File

@ -11,9 +11,11 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Users.Drawables; using osu.Game.Users.Drawables;
using osu.Game.Utils;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -55,6 +57,11 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
highAccuracyColour = colours.GreenLight; highAccuracyColour = colours.GreenLight;
} }
/// <summary>
/// The statistics that appear in the table, in order of appearance.
/// </summary>
private readonly List<HitResult> statisticResultTypes = new List<HitResult>();
private bool showPerformancePoints; private bool showPerformancePoints;
public void DisplayScores(IReadOnlyList<ScoreInfo> scores, bool showPerformanceColumn) public void DisplayScores(IReadOnlyList<ScoreInfo> scores, bool showPerformanceColumn)
@ -65,11 +72,12 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
return; return;
showPerformancePoints = showPerformanceColumn; showPerformancePoints = showPerformanceColumn;
statisticResultTypes.Clear();
for (int i = 0; i < scores.Count; i++) for (int i = 0; i < scores.Count; i++)
backgroundFlow.Add(new ScoreTableRowBackground(i, scores[i], row_height)); backgroundFlow.Add(new ScoreTableRowBackground(i, scores[i], row_height));
Columns = createHeaders(scores.FirstOrDefault()); Columns = createHeaders(scores);
Content = scores.Select((s, i) => createContent(i, s)).ToArray().ToRectangular(); Content = scores.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
} }
@ -79,7 +87,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
backgroundFlow.Clear(); backgroundFlow.Clear();
} }
private TableColumn[] createHeaders(ScoreInfo score) private TableColumn[] createHeaders(IReadOnlyList<ScoreInfo> scores)
{ {
var columns = new List<TableColumn> var columns = new List<TableColumn>
{ {
@ -92,8 +100,17 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120)) new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120))
}; };
foreach (var (key, _, _) in score.GetStatisticsForDisplay()) // All statistics across all scores, unordered.
columns.Add(new TableColumn(key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60))); var allScoreStatistics = scores.SelectMany(s => s.GetStatisticsForDisplay().Select(stat => stat.result)).ToHashSet();
foreach (var result in OrderAttributeUtils.GetValuesInOrder<HitResult>())
{
if (!allScoreStatistics.Contains(result))
continue;
columns.Add(new TableColumn(result.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
statisticResultTypes.Add(result);
}
if (showPerformancePoints) if (showPerformancePoints)
columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30))); columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
@ -146,13 +163,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
} }
}; };
foreach (var (_, value, maxCount) in score.GetStatisticsForDisplay()) var availableStatistics = score.GetStatisticsForDisplay().ToDictionary(tuple => tuple.result);
foreach (var result in statisticResultTypes)
{ {
if (!availableStatistics.TryGetValue(result, out var stat))
stat = (result, 0, null);
content.Add(new OsuSpriteText content.Add(new OsuSpriteText
{ {
Text = maxCount == null ? $"{value}" : $"{value}/{maxCount}", Text = stat.maxCount == null ? $"{stat.count}" : $"{stat.count}/{stat.maxCount}",
Font = OsuFont.GetFont(size: text_size), Font = OsuFont.GetFont(size: text_size),
Colour = value == 0 ? Color4.Gray : Color4.White Colour = stat.count == 0 ? Color4.Gray : Color4.White
}); });
} }