1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-21 06:42:54 +08:00

Replace Scores property with DisplayScores method

Also adds null checks to prevent crashes in tests.
This commit is contained in:
TheWildTree 2020-03-04 19:24:52 +01:00
parent 4d19278df4
commit 9aacc3f5ae
3 changed files with 20 additions and 19 deletions

View File

@ -52,25 +52,27 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
highAccuracyColour = colours.GreenLight;
}
public IReadOnlyList<ScoreInfo> Scores
private bool showPerformancePoints;
public void DisplayScores(IReadOnlyList<ScoreInfo> scores, bool showPerformanceColumn)
{
set
{
Content = null;
backgroundFlow.Clear();
if (!scores.Any())
return;
if (value?.Any() != true)
return;
showPerformancePoints = showPerformanceColumn;
for (int i = 0; i < value.Count; i++)
backgroundFlow.Add(new ScoreTableRowBackground(i, value[i], row_height));
for (int i = 0; i < scores.Count; i++)
backgroundFlow.Add(new ScoreTableRowBackground(i, scores[i], row_height));
Columns = createHeaders(value.First());
Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
}
Columns = createHeaders(scores.FirstOrDefault());
Content = scores.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
}
public bool IsBeatmapRanked { get; set; }
public void ClearScores()
{
Content = null;
backgroundFlow.Clear();
}
private TableColumn[] createHeaders(ScoreInfo score)
{
@ -90,7 +92,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
columns.Add(new TableColumn(score.SortedStatistics.LastOrDefault().Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 45, maxSize: 95)));
if (IsBeatmapRanked)
if (showPerformancePoints)
columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
columns.Add(new TableColumn("mods", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)));
@ -151,7 +153,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
});
}
if (IsBeatmapRanked)
if (showPerformancePoints)
{
content.Add(new OsuSpriteText
{

View File

@ -53,7 +53,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
if (value?.Scores.Any() != true)
{
scoreTable.Scores = null;
scoreTable.ClearScores();
scoreTable.Hide();
return;
}
@ -61,8 +61,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
var scoreInfos = value.Scores.Select(s => s.CreateScoreInfo(rulesets)).ToList();
var topScore = scoreInfos.First();
scoreTable.Scores = scoreInfos;
scoreTable.IsBeatmapRanked = topScore.Beatmap.Status == BeatmapSetOnlineStatus.Ranked;
scoreTable.DisplayScores(scoreInfos, topScore.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked);
scoreTable.Show();
var userScore = value.UserScore;

View File

@ -97,7 +97,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
totalScoreColumn.Text = $@"{value.TotalScore:N0}";
accuracyColumn.Text = value.DisplayAccuracy;
maxComboColumn.Text = $@"{value.MaxCombo:N0}x";
ppColumn.Alpha = value.Beatmap.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
ppColumn.Text = $@"{value.PP:N0}";
statisticsColumns.ChildrenEnumerable = value.SortedStatistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));