Split out scrolling algorithm

This commit is contained in:
smoogipoo
2018-01-07 12:47:09 +09:00
parent 2d345b2f80
commit 117ab8a26d
9 changed files with 205 additions and 107 deletions

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
/// <summary>
/// A type of <see cref="Playfield"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
/// </summary>
public class ScrollingPlayfield : Playfield
public abstract class ScrollingPlayfield : Playfield
{
/// <summary>
/// The default span of time visible by the length of the scrolling axes.
@ -49,7 +49,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
/// <summary>
/// The container that contains the <see cref="SpeedAdjustmentContainer"/>s and <see cref="DrawableHitObject"/>s.
/// </summary>
public new readonly ScrollingHitObjectContainer HitObjects;
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)base.HitObjects;
private readonly ScrollingDirection direction;
/// <summary>
/// Creates a new <see cref="ScrollingPlayfield"/>.
@ -59,7 +61,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
protected ScrollingPlayfield(ScrollingDirection direction, float? customWidth = null)
: base(customWidth)
{
base.HitObjects = HitObjects = new ScrollingHitObjectContainer(direction) { RelativeSizeAxes = Axes.Both };
this.direction = direction;
HitObjects.TimeRange.BindTo(VisibleTimeRange);
}
@ -105,6 +107,14 @@ namespace osu.Game.Rulesets.UI.Scrolling
this.TransformTo(this.PopulateTransform(new TransformVisibleTimeRange(), newTimeRange, duration, easing));
}
protected sealed override HitObjectContainer CreateHitObjectContainer() => CreateScrollingHitObjectContainer();
/// <summary>
/// Creates the <see cref="ScrollingHitObjectContainer"/> that will handle the scrolling of the <see cref="DrawableHitObject"/>s.
/// </summary>
/// <returns></returns>
protected virtual ScrollingHitObjectContainer CreateScrollingHitObjectContainer() => new GlobalScrollingHitObjectContainer(direction);
private class TransformVisibleTimeRange : Transform<double, ScrollingPlayfield>
{
private double valueAt(double time)