From 95a207ef56a9907fff4c892f7e36c47fbf6e843d Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:17:42 +0200 Subject: [PATCH 01/12] Fixed the parallax background missing from the space occupied by the top toolbar. --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..38dbf1a65d 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,7 +160,7 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale / overscan), + Scale = new Vector2(1 / circle_outer_scale), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From ca05fde14c7c9f984caf6c7fcbbdbe3ce78ed010 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:47:03 +0200 Subject: [PATCH 02/12] Fix the Parallax Background not filling the entire Circle Container. --- osu.Game/Screens/Ranking/Results.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 38dbf1a65d..a2990d7902 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -159,8 +159,11 @@ namespace osu.Game.Screens.Ranking backgroundParallax = new ParallaxContainer { RelativeSizeAxes = Axes.Both, - ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale), + ParallaxAmount = 0.02f, + //Compensate for the Toolbar + Scale = new Vector2(1.06f / circle_outer_scale / overscan), + //Offset the background to account for the toolbar. + Position = new Vector2(0, -20), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From be56d8cb8253a7c710579f54377f5563e9c01170 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 00:53:31 +0200 Subject: [PATCH 03/12] Change the parallax amount --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index a2990d7902..17e8666ebf 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -159,7 +159,7 @@ namespace osu.Game.Screens.Ranking backgroundParallax = new ParallaxContainer { RelativeSizeAxes = Axes.Both, - ParallaxAmount = 0.02f, + ParallaxAmount = 0.01f, //Compensate for the Toolbar Scale = new Vector2(1.06f / circle_outer_scale / overscan), //Offset the background to account for the toolbar. From be1159444d2fb9cb15f0019b275fa9f6a6df48e4 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Tue, 15 May 2018 15:56:49 +0200 Subject: [PATCH 04/12] Use the absolute value of ParallaxAmount to make sure we're not scaling stuff down when using a negative ParallaxAmount --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index dc635ce7e7..51be40c1e8 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); } firstUpdate = false; From 1e88f216f27831a8c5bc76cf09ce271be61e0580 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:27:18 +0200 Subject: [PATCH 05/12] Revert the ParallaxContainer changes I made by accident back. --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- osu.Game/Screens/Ranking/Results.cs | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 51be40c1e8..dc635ce7e7 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); + content.Scale = new Vector2(1 + ParallaxAmount); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); } firstUpdate = false; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 17e8666ebf..32161a0b8e 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,10 +160,7 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - //Compensate for the Toolbar - Scale = new Vector2(1.06f / circle_outer_scale / overscan), - //Offset the background to account for the toolbar. - Position = new Vector2(0, -20), + Scale = new Vector2(1 / circle_outer_scale / overscan), Anchor = Anchor.Centre, Origin = Anchor.Centre, Children = new Drawable[] From 428d0f5deec85cfb2153d8246301f3f269865346 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:30:16 +0200 Subject: [PATCH 06/12] Re-implement the fix after it got deleted in the previous commit. --- osu.Game/Screens/Ranking/Results.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 32161a0b8e..162c428444 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,8 +160,11 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - Scale = new Vector2(1 / circle_outer_scale / overscan), + //Compensate for the Toolbar + Scale = new Vector2(1.06f / circle_outer_scale / overscan), + //Offset the background to account for the toolbar. Anchor = Anchor.Centre, + Position = new Vector2(0, -20), Origin = Anchor.Centre, Children = new Drawable[] { From 3b708f650591a015ccd1e54721981f4316fbce4b Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:34:08 +0200 Subject: [PATCH 07/12] make it equal with the original codebase. --- osu.Game/Screens/Ranking/Results.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 162c428444..67949f8e14 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -160,17 +160,14 @@ namespace osu.Game.Screens.Ranking { RelativeSizeAxes = Axes.Both, ParallaxAmount = 0.01f, - //Compensate for the Toolbar - Scale = new Vector2(1.06f / circle_outer_scale / overscan), - //Offset the background to account for the toolbar. + Scale = new Vector2(1 / circle_outer_scale / overscan), Anchor = Anchor.Centre, - Position = new Vector2(0, -20), Origin = Anchor.Centre, Children = new Drawable[] { new Sprite { - RelativeSizeAxes = Axes.Both, + RelativeSsizeAxes = Axes.Both, Alpha = 0.2f, Texture = Beatmap.Value.Background, Anchor = Anchor.Centre, From 705960dabbc32591ccd36841e66e101e41133189 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:36:26 +0200 Subject: [PATCH 08/12] Fix typo --- osu.Game/Screens/Ranking/Results.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 67949f8e14..32161a0b8e 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -167,7 +167,7 @@ namespace osu.Game.Screens.Ranking { new Sprite { - RelativeSsizeAxes = Axes.Both, + RelativeSizeAxes = Axes.Both, Alpha = 0.2f, Texture = Beatmap.Value.Background, Anchor = Anchor.Centre, From d2b2d3e2e078de26188030f79c1722e2f30d2589 Mon Sep 17 00:00:00 2001 From: KoziLord Date: Wed, 16 May 2018 01:38:46 +0200 Subject: [PATCH 09/12] Use the absolute value of ParallaxAmount to make sure we're not scaling things down when using a negative value for the Parallax (moving against the cursor instead of with it) --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index dc635ce7e7..51be40c1e8 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers if (!parallaxEnabled) { content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint); - content.Scale = new Vector2(1 + ParallaxAmount); + content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount)); } }; } @@ -69,7 +69,7 @@ namespace osu.Game.Graphics.Containers double elapsed = MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 1000); content.Position = Interpolation.ValueAt(elapsed, content.Position, offset, 0, 1000, Easing.OutQuint); - content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + ParallaxAmount), 0, 1000, Easing.OutQuint); + content.Scale = Interpolation.ValueAt(elapsed, content.Scale, new Vector2(1 + System.Math.Abs(ParallaxAmount)), 0, 1000, Easing.OutQuint); } firstUpdate = false; From 5f2d1d4a1e93289b55aad46fa7ddf74ff39798f2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:48:44 +0900 Subject: [PATCH 10/12] Dim TestCase background a bit --- osu.Game/Tests/OsuTestBrowser.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/osu.Game/Tests/OsuTestBrowser.cs b/osu.Game/Tests/OsuTestBrowser.cs index 738bb2d642..217af8eb77 100644 --- a/osu.Game/Tests/OsuTestBrowser.cs +++ b/osu.Game/Tests/OsuTestBrowser.cs @@ -3,6 +3,7 @@ using osu.Framework.Platform; using osu.Framework.Testing; +using osu.Game.Graphics; using osu.Game.Screens.Backgrounds; namespace osu.Game.Tests @@ -13,7 +14,11 @@ namespace osu.Game.Tests { base.LoadComplete(); - LoadComponentAsync(new BackgroundScreenDefault { Depth = 10 }, AddInternal); + LoadComponentAsync(new BackgroundScreenDefault + { + Colour = OsuColour.Gray(0.5f), + Depth = 10 + }, AddInternal); // Have to construct this here, rather than in the constructor, because // we depend on some dependencies to be loaded within OsuGameBase.load(). From df0083e3d938d404855a73be9895656a3efb95f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:48:57 +0900 Subject: [PATCH 11/12] Add tests for ParallaxContainer --- .../Visual/TestCaseParallaxContainer.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 osu.Game.Tests/Visual/TestCaseParallaxContainer.cs diff --git a/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs b/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs new file mode 100644 index 0000000000..8c12589c6f --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseParallaxContainer.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics.Containers; +using osu.Game.Screens.Backgrounds; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseParallaxContainer : OsuTestCase + { + public TestCaseParallaxContainer() + { + ParallaxContainer parallax; + + Add(parallax = new ParallaxContainer + { + Child = new BackgroundScreenDefault { Alpha = 0.8f } + }); + + AddStep("default parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT); + AddStep("high parallax", () => parallax.ParallaxAmount = ParallaxContainer.DEFAULT_PARALLAX_AMOUNT * 10); + AddStep("no parallax", () => parallax.ParallaxAmount = 0); + AddStep("negative parallax", () => parallax.ParallaxAmount = -ParallaxContainer.DEFAULT_PARALLAX_AMOUNT); + } + } +} From 74f732038f7542fe489bf6fe409e2a2db93a3a79 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Jun 2018 12:49:07 +0900 Subject: [PATCH 12/12] Add documentation for negative values of ParallaxAmount --- osu.Game/Graphics/Containers/ParallaxContainer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Graphics/Containers/ParallaxContainer.cs b/osu.Game/Graphics/Containers/ParallaxContainer.cs index 51be40c1e8..8e1e5d54fa 100644 --- a/osu.Game/Graphics/Containers/ParallaxContainer.cs +++ b/osu.Game/Graphics/Containers/ParallaxContainer.cs @@ -16,6 +16,9 @@ namespace osu.Game.Graphics.Containers { public const float DEFAULT_PARALLAX_AMOUNT = 0.02f; + /// + /// The amount of parallax movement. Negative values will reverse the direction of parallax relative to user input. + /// public float ParallaxAmount = DEFAULT_PARALLAX_AMOUNT; private Bindable parallaxEnabled;