Move checking logic out of ScoreTable

This commit is contained in:
TheWildTree 2020-02-29 15:29:00 +01:00
parent d71b516902
commit f661806513
2 changed files with 6 additions and 6 deletions

View File

@ -29,7 +29,6 @@ public class ScoreTable : TableContainer
private readonly FillFlowContainer backgroundFlow;
private Color4 highAccuracyColour;
private bool isBeatmapRanked;
public ScoreTable()
{
@ -67,13 +66,13 @@ public IReadOnlyList<ScoreInfo> Scores
for (int i = 0; i < value.Count; i++)
backgroundFlow.Add(new ScoreTableRowBackground(i, value[i], row_height));
isBeatmapRanked = value.First().Beatmap.Status == BeatmapSetOnlineStatus.Ranked;
Columns = createHeaders(value.First());
Content = value.Select((s, i) => createContent(i, s)).ToArray().ToRectangular();
}
}
public bool IsBeatmapRanked { get; set; }
private TableColumn[] createHeaders(ScoreInfo score)
{
var columns = new List<TableColumn>
@ -92,7 +91,7 @@ private TableColumn[] createHeaders(ScoreInfo score)
columns.Add(new TableColumn(score.SortedStatistics.LastOrDefault().Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 45, maxSize: 95)));
if (isBeatmapRanked)
if (IsBeatmapRanked)
columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
columns.Add(new TableColumn("mods", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)));
@ -153,7 +152,7 @@ private Drawable[] createContent(int index, ScoreInfo score)
});
}
if (isBeatmapRanked)
if (IsBeatmapRanked)
{
content.Add(new OsuSpriteText
{

View File

@ -59,11 +59,12 @@ protected APILegacyScores 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.Show();
var topScore = scoreInfos.First();
var userScore = value.UserScore;
var userScoreInfo = userScore?.Score.CreateScoreInfo(rulesets);