From 6a87fd611235afb6e61515dfaea096414fdac3f6 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Fri, 7 Apr 2017 20:19:03 +0200 Subject: [PATCH] retries and fails hide if they're not present --- osu.Game/Screens/Select/BeatmapDetails.cs | 46 +++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 2655fce8c5..23e3fcf0d5 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -37,6 +37,7 @@ public class BeatmapDetails : Container private readonly OsuSpriteText positiveRatings; private readonly BarGraph ratingsGraph; + private readonly FillFlowContainer retryAndFailContainer; private readonly BarGraph retryGraph; private readonly BarGraph failGraph; @@ -119,8 +120,14 @@ public IEnumerable Fails private void calcRetryAndFailGraph() { - failGraph.Values = fails.Select(fail => (float)fail); - retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails?[index] ?? 0) ?? new List(); + if ((fails?.Count ?? 0) == 0 || (retries?.Count ?? 0) == 0) + retryAndFailContainer.FadeOut(250); + else + { + retryAndFailContainer.FadeIn(250); + failGraph.Values = fails.Select(fail => (float)fail); + retryGraph.Values = retries?.Select((retry, index) => (float)retry + fails[index]) ?? new List(); + } } public BeatmapDetails() @@ -304,26 +311,35 @@ public BeatmapDetails() }, }, }, - new OsuSpriteText - { - Text = "Points of Failure", - Font = @"Exo2.0-Regular", - }, - new Container + retryAndFailContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, - Size = new Vector2(1/0.6f, 50), - Children = new[] + AutoSizeAxes = Axes.Y, + Alpha = 0, + Children = new Drawable[] { - retryGraph = new BarGraph + new OsuSpriteText { - RelativeSizeAxes = Axes.Both, + Text = "Points of Failure", + Font = @"Exo2.0-Regular", }, - failGraph = new BarGraph + new Container { - RelativeSizeAxes = Axes.Both, + RelativeSizeAxes = Axes.X, + Size = new Vector2(1/0.6f, 50), + Children = new[] + { + retryGraph = new BarGraph + { + RelativeSizeAxes = Axes.Both, + }, + failGraph = new BarGraph + { + RelativeSizeAxes = Axes.Both, + }, + }, }, - }, + } }, }, },