1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 13:22:55 +08:00

null reference fixes

This commit is contained in:
Jorolf 2017-04-11 14:12:23 +02:00
parent fb5952186c
commit bfebba3a20

View File

@ -62,9 +62,11 @@ namespace osu.Game.Screens.Select
approachRate.Value = beatmap.Difficulty.ApproachRate; approachRate.Value = beatmap.Difficulty.ApproachRate;
stars.Value = (float)beatmap.StarDifficulty; stars.Value = (float)beatmap.StarDifficulty;
if (beatmap.Metric?.Ratings.Count != 0) if (beatmap.Metric?.Ratings?.Count == 0)
ratingsContainer.Hide();
else
{ {
List<int> ratings = beatmap.Metric?.Ratings; List<int> ratings = beatmap.Metric.Ratings;
ratingsContainer.Show(); ratingsContainer.Show();
negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString();
@ -73,23 +75,22 @@ namespace osu.Game.Screens.Select
ratingsGraph.Values = ratings.Select(rating => (float)rating); ratingsGraph.Values = ratings.Select(rating => (float)rating);
} }
if (beatmap.Metric?.Retries?.Count == 0 && beatmap.Metric?.Fails?.Count == 0)
retryFailContainer.Hide();
else else
ratingsContainer.Hide();
if (beatmap.Metric?.Retries.Count != 0 && beatmap.Metric?.Fails.Count != 0)
{ {
List<int> retries = beatmap.Metric?.Retries; List<int> retries = beatmap.Metric.Retries;
List<int> fails = beatmap.Metric?.Fails; List<int> fails = beatmap.Metric.Fails;
retryFailContainer.Show(); retryFailContainer.Show();
float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); float maxValue = fails.Select((fail, index) => fail + retries[index]).Max();
failGraph.MaxValue = maxValue; failGraph.MaxValue = maxValue;
retryGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue;
failGraph.Values = fails.Select(fail => (float)fail); failGraph.Values = fails.Select(fail => (float)fail);
retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue));
} }
else
retryFailContainer.Hide();
} }
} }