From bfebba3a206a7e818bf5aa3ad635d1144cd357ef Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Apr 2017 14:12:23 +0200 Subject: [PATCH] null reference fixes --- osu.Game/Screens/Select/BeatmapDetails.cs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index fab36ba5a6..a76497b221 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -62,9 +62,11 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - if (beatmap.Metric?.Ratings.Count != 0) + if (beatmap.Metric?.Ratings?.Count == 0) + ratingsContainer.Hide(); + else { - List ratings = beatmap.Metric?.Ratings; + List ratings = beatmap.Metric.Ratings; ratingsContainer.Show(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); @@ -73,23 +75,22 @@ namespace osu.Game.Screens.Select ratingsGraph.Values = ratings.Select(rating => (float)rating); } + + if (beatmap.Metric?.Retries?.Count == 0 && beatmap.Metric?.Fails?.Count == 0) + retryFailContainer.Hide(); else - ratingsContainer.Hide(); - - if (beatmap.Metric?.Retries.Count != 0 && beatmap.Metric?.Fails.Count != 0) { - List retries = beatmap.Metric?.Retries; - List fails = beatmap.Metric?.Fails; - + List retries = beatmap.Metric.Retries; + List fails = beatmap.Metric.Fails; retryFailContainer.Show(); + float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); failGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue; + failGraph.Values = fails.Select(fail => (float)fail); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); } - else - retryFailContainer.Hide(); } }