Set ScrollingAxes and RelativeChildOffset a bit more safely.

This commit is contained in:
smoogipooo 2017-08-22 18:37:49 +09:00
parent 137964b792
commit e5d985838f
3 changed files with 12 additions and 11 deletions

View File

@ -10,12 +10,10 @@ namespace osu.Game.Rulesets.Timing
/// </summary>
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);
}
}
}

View File

@ -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

View File

@ -31,7 +31,11 @@ public class SpeedAdjustmentContainer : Container<DrawableHitObject>
/// <summary>
/// The axes which the content of this container will scroll through.
/// </summary>
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 <see cref="ScrollingContainer"/> which contains the scrolling <see cref="DrawableHitObject"/>s of this container.
/// </summary>
/// <returns>The <see cref="ScrollingContainer"/>.</returns>
protected virtual ScrollingContainer CreateScrollingContainer() => new LinearScrollingContainer(ScrollingAxes, ControlPoint);
protected virtual ScrollingContainer CreateScrollingContainer() => new LinearScrollingContainer(ControlPoint);
}
}
}