From dfb47b571a6ae22e5e6a13c3d76523e0d09156b3 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 12:24:38 +0900 Subject: [PATCH 1/9] Make HitRenderer's Playfield public so it can be used in testing. --- osu.Game/Rulesets/UI/HitRenderer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/HitRenderer.cs b/osu.Game/Rulesets/UI/HitRenderer.cs index 47339fb6e6..13ea83dc48 100644 --- a/osu.Game/Rulesets/UI/HitRenderer.cs +++ b/osu.Game/Rulesets/UI/HitRenderer.cs @@ -225,7 +225,7 @@ namespace osu.Game.Rulesets.UI /// /// The playfield. /// - protected Playfield Playfield { get; private set; } + public Playfield Playfield { get; private set; } protected override Container Content => content; private readonly Container content; From 1c5584f06879191abbd2458da1299ee14031cbc2 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 12:45:50 +0900 Subject: [PATCH 2/9] Make ScrollingPlayfield store a list of SpeedAdjustments instead of a Container. Because they're removed from the container when they're not alive, and any further adding methods fail. --- osu.Game/Rulesets/UI/ScrollingPlayfield.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index a54ece4c05..204742eec9 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -168,7 +168,7 @@ namespace osu.Game.Rulesets.UI /// Hit objects that are to be re-processed on the next update. /// private readonly List queuedHitObjects = new List(); - private readonly Container speedAdjustments; + private readonly List speedAdjustments = new List(); private readonly Axes scrollingAxes; @@ -179,8 +179,6 @@ namespace osu.Game.Rulesets.UI public ScrollingHitObjectContainer(Axes scrollingAxes) { this.scrollingAxes = scrollingAxes; - - AddInternal(speedAdjustments = new Container { RelativeSizeAxes = Axes.Both }); } /// @@ -193,6 +191,8 @@ namespace osu.Game.Rulesets.UI speedAdjustment.ScrollingAxes = scrollingAxes; speedAdjustment.Reversed = Reversed; speedAdjustments.Add(speedAdjustment); + + AddInternal(speedAdjustment); } public override IEnumerable Objects => speedAdjustments.SelectMany(s => s.Children); From 431a9649a4b569f624254715171f654ac45904a1 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 13:38:12 +0900 Subject: [PATCH 3/9] Remove unused using. --- osu.Game/Rulesets/UI/ScrollingPlayfield.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index 204742eec9..3a66d1c929 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -7,7 +7,6 @@ using System.Linq; using OpenTK.Input; using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Transforms; using osu.Framework.Input; using osu.Framework.MathUtils; From a20753abc69c3963c35e0345aa135732112ce308 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:10:10 +0900 Subject: [PATCH 4/9] Applied suggested changes. --- .../Visual/TestCaseScrollingPlayfield.cs | 2 +- .../Timing/SpeedAdjustmentContainer.cs | 14 ++------- osu.Game/Rulesets/UI/ScrollingPlayfield.cs | 29 +++++-------------- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs index 7f067efa78..82fa93797d 100644 --- a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs @@ -53,7 +53,7 @@ namespace osu.Desktop.Tests.Visual TestHitRenderer hitRenderer; Add(hitRenderer = new TestHitRenderer(beatmap, true)); - AddStep("Reverse direction", () => hitRenderer.Playfield.Reversed.Value = !hitRenderer.Playfield.Reversed); + AddStep("Reverse direction", () => hitRenderer.Playfield.Reversed.Toggle()); } private class TestHitRenderer : ScrollingHitRenderer diff --git a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs index d582f19660..f9ca43d0fc 100644 --- a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs +++ b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs @@ -16,25 +16,15 @@ namespace osu.Game.Rulesets.Timing /// public class SpeedAdjustmentContainer : Container { - private readonly Bindable visibleTimeRange = new Bindable { Default = 1000 }; /// /// Gets or sets the range of time that is visible by the length of the scrolling axes. /// - public Bindable VisibleTimeRange - { - get { return visibleTimeRange; } - set { visibleTimeRange.BindTo(value); } - } + public readonly Bindable VisibleTimeRange = new Bindable { Default = 1000 }; - private readonly BindableBool reversed = new BindableBool(); /// /// Whether to reverse the scrolling direction is reversed. /// - public BindableBool Reversed - { - get { return reversed; } - set { reversed.BindTo(value); } - } + public readonly BindableBool Reversed = new BindableBool(); protected override Container Content => content; private Container content; diff --git a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs index 3a66d1c929..66ca2dd7c4 100644 --- a/osu.Game/Rulesets/UI/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/ScrollingPlayfield.cs @@ -71,12 +71,9 @@ namespace osu.Game.Rulesets.UI protected ScrollingPlayfield(Axes scrollingAxes, float? customWidth = null) : base(customWidth) { - base.HitObjects = HitObjects = new ScrollingHitObjectContainer(scrollingAxes) - { - RelativeSizeAxes = Axes.Both, - VisibleTimeRange = VisibleTimeRange, - Reversed = Reversed - }; + base.HitObjects = HitObjects = new ScrollingHitObjectContainer(scrollingAxes) { RelativeSizeAxes = Axes.Both }; + HitObjects.VisibleTimeRange.BindTo(VisibleTimeRange); + HitObjects.Reversed.BindTo(Reversed); } private List> nestedPlayfields; @@ -142,26 +139,16 @@ namespace osu.Game.Rulesets.UI /// internal class ScrollingHitObjectContainer : HitObjectContainer { - private readonly BindableDouble visibleTimeRange = new BindableDouble { Default = 1000 }; /// /// Gets or sets the range of time that is visible by the length of the scrolling axes. /// For example, only hit objects with start time less than or equal to 1000 will be visible with = 1000. /// - public Bindable VisibleTimeRange - { - get { return visibleTimeRange; } - set { visibleTimeRange.BindTo(value); } - } + public readonly BindableDouble VisibleTimeRange = new BindableDouble { Default = 1000 }; - private readonly BindableBool reversed = new BindableBool(); /// /// Whether to reverse the scrolling direction is reversed. /// - public BindableBool Reversed - { - get { return reversed; } - set { reversed.BindTo(value); } - } + public readonly BindableBool Reversed = new BindableBool(); /// /// Hit objects that are to be re-processed on the next update. @@ -186,11 +173,11 @@ namespace osu.Game.Rulesets.UI /// The . public void AddSpeedAdjustment(SpeedAdjustmentContainer speedAdjustment) { - speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange); speedAdjustment.ScrollingAxes = scrollingAxes; - speedAdjustment.Reversed = Reversed; - speedAdjustments.Add(speedAdjustment); + speedAdjustment.VisibleTimeRange.BindTo(VisibleTimeRange); + speedAdjustment.Reversed.BindTo(Reversed); + speedAdjustments.Add(speedAdjustment); AddInternal(speedAdjustment); } From 346aebebc0a135490eb085d54fab1c809e73d456 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:24:07 +0900 Subject: [PATCH 5/9] Fix origins not being set correctly when reverting from reversed playfield. --- osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs index f9ca43d0fc..e9640dba24 100644 --- a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs +++ b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs @@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.Timing { RelativeChildSize = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 1, (ScrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 1); RelativeChildOffset = Vector2.Zero; - Anchor = Anchor = Anchor.TopLeft; + Origin = Anchor = Anchor.TopLeft; } } From ea073c02b37e2c6fa74239f3851e807b7d3bee8b Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:24:29 +0900 Subject: [PATCH 6/9] Showcase both horizontal and vertical styles in TestCaseScrollingPlayfield. --- .../Visual/TestCaseScrollingPlayfield.cs | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs index 82fa93797d..1dd55974e8 100644 --- a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs @@ -50,17 +50,27 @@ namespace osu.Desktop.Tests.Visual WorkingBeatmap beatmap = new TestWorkingBeatmap(b); - TestHitRenderer hitRenderer; - Add(hitRenderer = new TestHitRenderer(beatmap, true)); + TestHitRenderer horizontalHitRenderer; + Add(horizontalHitRenderer = new TestHitRenderer(Axes.X, beatmap, true)); - AddStep("Reverse direction", () => hitRenderer.Playfield.Reversed.Toggle()); + TestHitRenderer verticalHitRenderer; + Add(verticalHitRenderer = new TestHitRenderer(Axes.Y, beatmap, true)); + + AddStep("Reverse direction", () => + { + horizontalHitRenderer.Playfield.Reversed.Toggle(); + verticalHitRenderer.Playfield.Reversed.Toggle(); + }); } private class TestHitRenderer : ScrollingHitRenderer { - public TestHitRenderer(WorkingBeatmap beatmap, bool isForCurrentRuleset) + private readonly Axes scrollingAxes; + + public TestHitRenderer(Axes scrollingAxes, WorkingBeatmap beatmap, bool isForCurrentRuleset) : base(beatmap, isForCurrentRuleset) { + this.scrollingAxes = scrollingAxes; } public new TestPlayfield Playfield => base.Playfield; @@ -69,9 +79,9 @@ namespace osu.Desktop.Tests.Visual protected override BeatmapConverter CreateBeatmapConverter() => new TestBeatmapConverter(); - protected override Playfield CreatePlayfield() => new TestPlayfield(); + protected override Playfield CreatePlayfield() => new TestPlayfield(scrollingAxes); - protected override DrawableHitObject GetVisualRepresentation(TestHitObject h) => new DrawableTestHitObject(h); + protected override DrawableHitObject GetVisualRepresentation(TestHitObject h) => new DrawableTestHitObject(scrollingAxes, h); } private class TestScoreProcessor : ScoreProcessor @@ -93,10 +103,14 @@ namespace osu.Desktop.Tests.Visual private class DrawableTestHitObject : DrawableScrollingHitObject { - public DrawableTestHitObject(TestHitObject hitObject) + public DrawableTestHitObject(Axes scrollingAxes, TestHitObject hitObject) : base(hitObject) { - Anchor = Anchor.CentreLeft; + if (scrollingAxes == Axes.Y) + Anchor = Anchor.TopCentre; + else + Anchor = Anchor.CentreLeft; + Origin = Anchor.Centre; AutoSizeAxes = Axes.Both; @@ -119,8 +133,8 @@ namespace osu.Desktop.Tests.Visual protected override Container Content => content; private readonly Container content; - public TestPlayfield() - : base(Axes.X) + public TestPlayfield(Axes scrollingAxes) + : base(scrollingAxes) { InternalChildren = new Drawable[] { From f70c00423a83fb89d5659c3fe3912bd074e34820 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:25:49 +0900 Subject: [PATCH 7/9] Missed one. --- osu.Game/Rulesets/Timing/ScrollingContainer.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Timing/ScrollingContainer.cs b/osu.Game/Rulesets/Timing/ScrollingContainer.cs index 1cb5e42251..843f307d0d 100644 --- a/osu.Game/Rulesets/Timing/ScrollingContainer.cs +++ b/osu.Game/Rulesets/Timing/ScrollingContainer.cs @@ -17,15 +17,10 @@ namespace osu.Game.Rulesets.Timing /// public abstract class ScrollingContainer : Container { - private readonly BindableDouble visibleTimeRange = new BindableDouble { Default = 1000 }; /// /// Gets or sets the range of time that is visible by the length of the scrolling axes. /// - public BindableDouble VisibleTimeRange - { - get { return visibleTimeRange; } - set { visibleTimeRange.BindTo(value); } - } + public readonly BindableDouble VisibleTimeRange = new BindableDouble { Default = 1000 }; /// /// The axes through which this scrolls. This is set by the . From 2715324a766e0cab8124b7326977b99992240014 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:50:52 +0900 Subject: [PATCH 8/9] Fix possible incorrect reversing behavior for horizontal playfields. --- osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs index e9640dba24..9d5f49e155 100644 --- a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs +++ b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs @@ -75,7 +75,7 @@ namespace osu.Game.Rulesets.Timing { RelativeChildSize = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)-VisibleTimeRange : 1, (ScrollingAxes & Axes.Y) > 0 ? (float)-VisibleTimeRange : 1); RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)VisibleTimeRange : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)VisibleTimeRange : 0); - Origin = Anchor = Anchor.BottomLeft; + Origin = Anchor = Anchor.BottomRight; } else { From e6c100da27a8cc51d08a8da026ccf5533a24efed Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Wed, 9 Aug 2017 14:51:00 +0900 Subject: [PATCH 9/9] Fix CI. --- osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs index 1dd55974e8..79a9fab91c 100644 --- a/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs +++ b/osu.Desktop.Tests/Visual/TestCaseScrollingPlayfield.cs @@ -106,11 +106,7 @@ namespace osu.Desktop.Tests.Visual public DrawableTestHitObject(Axes scrollingAxes, TestHitObject hitObject) : base(hitObject) { - if (scrollingAxes == Axes.Y) - Anchor = Anchor.TopCentre; - else - Anchor = Anchor.CentreLeft; - + Anchor = scrollingAxes == Axes.Y ? Anchor.TopCentre : Anchor.CentreLeft; Origin = Anchor.Centre; AutoSizeAxes = Axes.Both;