mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 15:44:04 +09:00
Make BeatmapSetOverlay accept nulls everywhere
This commit is contained in:
@ -40,10 +40,10 @@ namespace osu.Game.Screens.Select.Details
|
||||
firstValue.Value = Beatmap?.BaseDifficulty?.CircleSize ?? 0;
|
||||
}
|
||||
|
||||
hpDrain.Value = beatmap.BaseDifficulty?.DrainRate ?? 0;
|
||||
accuracy.Value = beatmap.BaseDifficulty?.OverallDifficulty ?? 0;
|
||||
approachRate.Value = beatmap.BaseDifficulty?.ApproachRate ?? 0;
|
||||
starDifficulty.Value = (float)beatmap.StarDifficulty;
|
||||
hpDrain.Value = Beatmap?.BaseDifficulty?.DrainRate ?? 0;
|
||||
accuracy.Value = Beatmap?.BaseDifficulty?.OverallDifficulty ?? 0;
|
||||
approachRate.Value = Beatmap?.BaseDifficulty?.ApproachRate ?? 0;
|
||||
starDifficulty.Value = (float)(Beatmap?.StarDifficulty ?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ namespace osu.Game.Screens.Select.Details
|
||||
if (value == metrics) return;
|
||||
metrics = value;
|
||||
|
||||
var retries = Metrics.Retries;
|
||||
var fails = Metrics.Fails;
|
||||
var retries = Metrics?.Retries ?? new int[0];
|
||||
var fails = Metrics?.Fails ?? new int[0];
|
||||
|
||||
float maxValue = fails.Zip(retries, (fail, retry) => fail + retry).Max();
|
||||
float maxValue = fails.Any() ? fails.Zip(retries, (fail, retry) => fail + retry).Max() : 0;
|
||||
failGraph.MaxValue = maxValue;
|
||||
retryGraph.MaxValue = maxValue;
|
||||
|
||||
|
@ -21,6 +21,7 @@ namespace osu.Game.Screens.Select.Details
|
||||
private readonly BarGraph graph;
|
||||
|
||||
private BeatmapMetrics metrics;
|
||||
|
||||
public BeatmapMetrics Metrics
|
||||
{
|
||||
get { return metrics; }
|
||||
@ -31,15 +32,25 @@ namespace osu.Game.Screens.Select.Details
|
||||
|
||||
const int rating_range = 10;
|
||||
|
||||
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
|
||||
if (metrics == null)
|
||||
{
|
||||
negativeRatings.Text = "0";
|
||||
positiveRatings.Text = "0";
|
||||
ratingsBar.Length = 0;
|
||||
graph.Values = new float[rating_range];
|
||||
}
|
||||
else
|
||||
{
|
||||
var ratings = Metrics.Ratings.Skip(1).Take(rating_range); // adjust for API returning weird empty data at 0.
|
||||
|
||||
var negativeCount = ratings.Take(rating_range / 2).Sum();
|
||||
var totalCount = ratings.Sum();
|
||||
var negativeCount = ratings.Take(rating_range / 2).Sum();
|
||||
var totalCount = ratings.Sum();
|
||||
|
||||
negativeRatings.Text = negativeCount.ToString();
|
||||
positiveRatings.Text = (totalCount - negativeCount).ToString();
|
||||
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
|
||||
graph.Values = ratings.Take(rating_range).Select(r => (float)r);
|
||||
negativeRatings.Text = negativeCount.ToString();
|
||||
positiveRatings.Text = (totalCount - negativeCount).ToString();
|
||||
ratingsBar.Length = totalCount == 0 ? 0 : (float)negativeCount / totalCount;
|
||||
graph.Values = ratings.Take(rating_range).Select(r => (float)r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user