From 7bd13d76a82c22a2d0e493de6eac679959245e46 Mon Sep 17 00:00:00 2001 From: Jorolf Date: Wed, 29 Mar 2017 14:48:43 +0200 Subject: [PATCH] fixes + updates to DetailsBar and a button for the TestCaseDetails --- osu.Desktop.VisualTests/Tests/TestCaseDetails.cs | 13 ++++++++++++- osu.Game/Screens/Select/Details.cs | 2 +- osu.Game/Screens/Select/DetailsBar.cs | 10 ++++++---- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs index 3f50f4aaed..2d22009f21 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDetails.cs @@ -16,12 +16,12 @@ namespace osu.Desktop.VisualTests.Tests { class TestCaseDetails : TestCase { + private Details details; public override void Reset() { base.Reset(); - Details details; Add(details = new Details { RelativeSizeAxes = Axes.Both, @@ -48,6 +48,17 @@ namespace osu.Desktop.VisualTests.Tests 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)); + + AddButton("new retry/fail values", newRetryAndFailValues); + } + + private int lastRange = 1; + + private void newRetryAndFailValues() + { + lastRange += 100; + details.Fails = Enumerable.Range(lastRange, 100).Select(i => (int)(Math.Cos(i) * 100)); + details.Retries = Enumerable.Range(lastRange, 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 e99d218445..c50cae0f4f 100644 --- a/osu.Game/Screens/Select/Details.cs +++ b/osu.Game/Screens/Select/Details.cs @@ -50,7 +50,7 @@ namespace osu.Game.Screens.Select beatmap = value; description.Text = beatmap.Version; source.Text = beatmap.Metadata.Source; - tags.Children = beatmap.Metadata.Tags.Split(' ').Select(text => new SpriteText + tags.Children = beatmap.Metadata.Tags?.Split(' ').Select(text => new SpriteText { Text = text, TextSize = 14, diff --git a/osu.Game/Screens/Select/DetailsBar.cs b/osu.Game/Screens/Select/DetailsBar.cs index daefcc9a54..b48b618fad 100644 --- a/osu.Game/Screens/Select/DetailsBar.cs +++ b/osu.Game/Screens/Select/DetailsBar.cs @@ -6,7 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; -using System; +using osu.Framework.Graphics.Transforms; namespace osu.Game.Screens.Select { @@ -17,6 +17,8 @@ namespace osu.Game.Screens.Select private const int resize_duration = 250; + private const EasingTypes easing = EasingTypes.InOutCubic; + private float length; public float Length { @@ -26,7 +28,7 @@ namespace osu.Game.Screens.Select } set { - length = value; + length = MathHelper.Clamp(value,0,1); updateBarLength(); } } @@ -90,11 +92,11 @@ namespace osu.Game.Screens.Select { case BarDirection.LeftToRight: case BarDirection.RightToLeft: - bar.ResizeTo(new Vector2(length, 1), resize_duration); + bar.ResizeTo(new Vector2(length, 1), resize_duration, easing); break; case BarDirection.TopToBottom: case BarDirection.BottomToTop: - bar.ResizeTo(new Vector2(1, length), resize_duration); + bar.ResizeTo(new Vector2(1, length), resize_duration, easing); break; }