From 199c70ff95bed34a9140452ad42fe124ca6b58dd Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 28 Mar 2017 20:18:56 +0200 Subject: [PATCH] Added fails and retries --- .../Tests/TestCaseDetails.cs | 13 +- osu.Game/Screens/Select/Details.cs | 143 +++++++++++++++++- osu.Game/Screens/Select/DetailsBar.cs | 7 +- 3 files changed, 150 insertions(+), 13 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index d0d7602831..3f50f4aaed 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; +using osu.Framework.Graphics.Primitives; using osu.Framework.Screens.Testing; using osu.Game.Database; using osu.Game.Screens.Select; @@ -20,9 +21,11 @@ namespace osu.Desktop.VisualTests.Tests { base.Reset(); - Add(new Details + Details details; + Add(details = new Details { RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding(150), Beatmap = new BeatmapInfo { Version = "VisualTest", @@ -40,11 +43,11 @@ namespace osu.Desktop.VisualTests.Tests }, StarDifficulty = 5.3f, }, - Ratings = new[] - { - 1,2,3,4,5,6,7,8,9,10 - } }); + + details.Ratings = Enumerable.Range(1, 10); + details.Fails = Enumerable.Range(1, 100).Select(i => (int)(Math.Cos(i) * 100)); + details.Retries = Enumerable.Range(1, 100).Select(i => (int)(Math.Sin(i) * 100)); } } } diff --git a/osu.Game/Screens/Select/Details.cs b/osu.Game/Screens/Select/Details.cs index 54f3d5b519..e99d218445 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -13,6 +13,7 @@ using osu.Game.Database; using osu.Game.Graphics; using System.Collections.Generic; using System.Linq; +using System; namespace osu.Game.Screens.Select { @@ -33,6 +34,8 @@ namespace osu.Game.Screens.Select private SpriteText positiveRatings; private FillFlowContainer ratingsGraph; + private FillFlowContainer retryAndFailGraph; + private BeatmapInfo beatmap; public BeatmapInfo Beatmap { @@ -91,7 +94,53 @@ namespace osu.Game.Screens.Select }); } } - + + private List retries = Enumerable.Repeat(0,100).ToList(); + public IEnumerable Retries + { + get + { + return retries; + } + set + { + retries = value.ToList(); + calcRetryAndFailBarLength(); + } + } + + private List fails = Enumerable.Repeat(0,100).ToList(); + public IEnumerable Fails + { + get + { + return fails; + } + set + { + fails = value.ToList(); + calcRetryAndFailBarLength(); + } + } + + private void calcRetryAndFailBarLength() + { + List retryAndFailGraphBars = retryAndFailGraph.Children.ToList(); + for (int i = 0; i < 100; i++) + if (retryAndFailGraphBars.Count > i) + { + retryAndFailGraphBars[i].FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); + retryAndFailGraphBars[i].RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)); + } + else + retryAndFailGraph.Add(new RetryAndFailBar + { + RelativeSizeAxes = Axes.Both, + Width = 0.01f, + FailLength = (float)fails[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), + RetryLength = (float)retries[i] / ((fails?.Max() ?? 0) + (retries?.Max() ?? 0)), + }); + } public Details() { @@ -280,7 +329,7 @@ namespace osu.Game.Screens.Select Text = "Rating Spread", TextSize = 14, Font = @"Exo2.0-Medium", - Anchor = Anchor.BottomCentre, + Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, ratingsGraph = new FillFlowContainer @@ -288,13 +337,40 @@ namespace osu.Game.Screens.Select RelativeSizeAxes = Axes.X, Direction = FillDirection.Horizontal, Height = 50, - } + }, }, }, }, }, }, }, + new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Direction = FillDirection.Vertical, + Padding = new MarginPadding { Left = 10, Right = 10 }, + Children = new Drawable[] + { + retryAndFailGraph = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + Direction = FillDirection.Horizontal, + Height = 50, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }, + new SpriteText + { + Text = "Points of Failure", + TextSize = 14, + Font = @"Exo2.0-Medium", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + }, + }, + }, }; } @@ -305,11 +381,10 @@ namespace osu.Game.Screens.Select source.Colour = colour.GrayB; tags.Colour = colour.YellowLight; - stars.BarColour = colour.YellowLight; + stars.BarColour = colour.Yellow; ratingsBar.BackgroundColour = colour.Green; ratingsBar.BarColour = colour.YellowDark; - ratingsGraph.Colour = colour.BlueDark; } @@ -407,5 +482,63 @@ namespace osu.Game.Screens.Select valueText.Colour = colour.GrayB; } } + + private class RetryAndFailBar : Container + { + private DetailsBar retryBar; + private DetailsBar failBar; + + public float RetryLength + { + get + { + return retryBar.Length; + } + set + { + retryBar.Length = value + FailLength; + } + } + + public float FailLength + { + get + { + return failBar.Length; + } + set + { + failBar.Length = value; + } + } + + public RetryAndFailBar() + { + Children = new[] + { + retryBar = new DetailsBar + { + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + Length = 0, + BackgroundColour = new Color4(0,0,0,0), + }, + failBar = new DetailsBar + { + RelativeSizeAxes = Axes.Both, + Direction = BarDirection.BottomToTop, + Length = 0, + BackgroundColour = new Color4(0,0,0,0), + }, + }; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colour) + { + retryBar.Colour = colour.Yellow; + failBar.Colour = colour.YellowDarker; + } + } } } diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index 650d690a78..daefcc9a54 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; +using System; namespace osu.Game.Screens.Select { @@ -14,7 +15,7 @@ namespace osu.Game.Screens.Select private Box background; private Box bar; - private const int resizeDuration = 250; + private const int resize_duration = 250; private float length; public float Length @@ -89,11 +90,11 @@ namespace osu.Game.Screens.Select { case BarDirection.LeftToRight: case BarDirection.RightToLeft: - bar.ResizeTo(new Vector2(length, 1), resizeDuration); + bar.ResizeTo(new Vector2(length, 1), resize_duration); break; case BarDirection.TopToBottom: case BarDirection.BottomToTop: - bar.ResizeTo(new Vector2(1, length), resizeDuration); + bar.ResizeTo(new Vector2(1, length), resize_duration); break; }