mirror of
https://github.com/ppy/osu
synced 2025-01-26 07:43:08 +00:00
Set ScrollingAxes and RelativeChildOffset a bit more safely.
This commit is contained in:
parent
137964b792
commit
e5d985838f
@ -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 @@ namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,8 @@ namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
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
|
||||
|
@ -31,7 +31,11 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// <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 @@ namespace osu.Game.Rulesets.Timing
|
||||
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 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user