From e5d985838f55d95742003d829b6759904786a18d Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Tue, 22 Aug 2017 18:37:49 +0900 Subject: [PATCH] Set ScrollingAxes and RelativeChildOffset a bit more safely. --- .../Rulesets/Timing/LinearScrollingContainer.cs | 8 +++----- osu.Game/Rulesets/Timing/ScrollingContainer.cs | 2 ++ .../Rulesets/Timing/SpeedAdjustmentContainer.cs | 13 +++++++------ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/osu.Game/Rulesets/Timing/LinearScrollingContainer.cs b/osu.Game/Rulesets/Timing/LinearScrollingContainer.cs index db497b7664..f8e87bc022 100644 --- a/osu.Game/Rulesets/Timing/LinearScrollingContainer.cs +++ b/osu.Game/Rulesets/Timing/LinearScrollingContainer.cs @@ -10,12 +10,10 @@ namespace osu.Game.Rulesets.Timing /// internal class LinearScrollingContainer : ScrollingContainer { - private readonly Axes scrollingAxes; private readonly MultiplierControlPoint controlPoint; - public LinearScrollingContainer(Axes scrollingAxes, MultiplierControlPoint controlPoint) + public LinearScrollingContainer(MultiplierControlPoint controlPoint) { - this.scrollingAxes = scrollingAxes; this.controlPoint = controlPoint; } @@ -23,8 +21,8 @@ protected override void Update() { base.Update(); - if ((scrollingAxes & Axes.X) > 0) X = (float)(controlPoint.StartTime - Time.Current); - if ((scrollingAxes & Axes.Y) > 0) Y = (float)(controlPoint.StartTime - Time.Current); + if ((ScrollingAxes & Axes.X) > 0) X = (float)(controlPoint.StartTime - Time.Current); + if ((ScrollingAxes & Axes.Y) > 0) Y = (float)(controlPoint.StartTime - Time.Current); } } } diff --git a/osu.Game/Rulesets/Timing/ScrollingContainer.cs b/osu.Game/Rulesets/Timing/ScrollingContainer.cs index 9bb32ead77..ad5fc7c2f0 100644 --- a/osu.Game/Rulesets/Timing/ScrollingContainer.cs +++ b/osu.Game/Rulesets/Timing/ScrollingContainer.cs @@ -96,6 +96,8 @@ protected override void Update() { base.Update(); + RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)ControlPoint.StartTime : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)ControlPoint.StartTime : 0); + // We want our size and position-space along the scrolling axes to span our duration to completely enclose all the hit objects Size = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)Duration : Size.X, (ScrollingAxes & Axes.Y) > 0 ? (float)Duration : Size.Y); // And we need to make sure the hit object's position-space doesn't change due to our resizing diff --git a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs index df0abd28df..d3bd7685da 100644 --- a/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs +++ b/osu.Game/Rulesets/Timing/SpeedAdjustmentContainer.cs @@ -31,7 +31,11 @@ public class SpeedAdjustmentContainer : Container /// /// The axes which the content of this container will scroll through. /// - public Axes ScrollingAxes { get; internal set; } + public Axes ScrollingAxes + { + get { return scrollingContainer.ScrollingAxes; } + set { scrollingContainer.ScrollingAxes = value; } + } public override bool RemoveWhenNotAlive => false; @@ -52,11 +56,8 @@ public SpeedAdjustmentContainer(MultiplierControlPoint controlPoint) RelativeSizeAxes = Axes.Both; scrollingContainer = CreateScrollingContainer(); - - scrollingContainer.ScrollingAxes = ScrollingAxes; scrollingContainer.ControlPoint = ControlPoint; scrollingContainer.VisibleTimeRange.BindTo(VisibleTimeRange); - scrollingContainer.RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)ControlPoint.StartTime : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)ControlPoint.StartTime : 0); AddInternal(content = scrollingContainer); } @@ -107,6 +108,6 @@ public override void Add(DrawableHitObject drawable) /// Creates the which contains the scrolling s of this container. /// /// The . - protected virtual ScrollingContainer CreateScrollingContainer() => new LinearScrollingContainer(ScrollingAxes, ControlPoint); + protected virtual ScrollingContainer CreateScrollingContainer() => new LinearScrollingContainer(ControlPoint); } -} \ No newline at end of file +}