1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-21 00:29:39 +08:00

Move scroll direction to scrollinginfo

This commit is contained in:
smoogipoo 2018-11-06 15:46:36 +09:00
parent 48486895ba
commit ad45bc7666
19 changed files with 185 additions and 184 deletions

@ -22,11 +22,8 @@ namespace osu.Game.Rulesets.Catch.UI
protected override bool UserScrollSpeedAdjustment => false;
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
{
Direction.Value = ScrollingDirection.Down;
Container explodingFruitContainer;
Anchor = Anchor.TopCentre;

@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Catch.UI
public CatchRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
Direction.Value = ScrollingDirection.Down;
}
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);

@ -1,32 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.Tests
{
/// <summary>
/// A container which provides a <see cref="IScrollingInfo"/> to children.
/// </summary>
public class ScrollingTestContainer : Container
{
[Cached(Type = typeof(IScrollingInfo))]
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
public ScrollingTestContainer(ScrollingDirection direction)
{
scrollingInfo.Direction.Value = direction;
}
public void Flip() => scrollingInfo.Direction.Value = scrollingInfo.Direction.Value == ScrollingDirection.Up ? ScrollingDirection.Down : ScrollingDirection.Up;
}
public class TestScrollingInfo : IScrollingInfo
{
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
}
}

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Mania.UI.Components;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
using OpenTK;
using OpenTK.Graphics;

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Tests.Visual;
using OpenTK;
namespace osu.Game.Rulesets.Mania.Tests

@ -10,9 +10,8 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Objects.Drawables;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Framework.Configuration;
using osu.Game.Rulesets.Mania.Edit.Blueprints;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
@ -20,8 +19,6 @@ namespace osu.Game.Rulesets.Mania.Edit
{
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>
{
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
public ManiaHitObjectComposer(Ruleset ruleset)
: base(ruleset)
{
@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Edit
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
dependencies.CacheAs<IScrollingInfo>(new ScrollingInfo());
return dependencies;
}
@ -51,5 +48,10 @@ namespace osu.Game.Rulesets.Mania.Edit
return base.CreateBlueprintFor(hitObject);
}
private class ScrollingInfo : IScrollingInfo
{
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>();
}
}
}

@ -16,7 +16,7 @@ using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.UI
{
public class Column : ManiaScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
public class Column : ScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
{
private const float column_width = 45;
private const float special_column_width = 70;
@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Mania.UI
explosionContainer.Add(new HitExplosion(judgedObject)
{
Anchor = Direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre
Anchor = Direction.Value == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre
});
}

@ -10,11 +10,12 @@ using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK;
namespace osu.Game.Rulesets.Mania.UI
{
public class ManiaPlayfield : ManiaScrollingPlayfield
public class ManiaPlayfield : ScrollingPlayfield
{
private readonly List<ManiaStage> stages = new List<ManiaStage>();

@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Input;
@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Mania.UI
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
@ -70,18 +73,9 @@ namespace osu.Game.Rulesets.Mania.UI
private void load()
{
BarLines.ForEach(Playfield.Add);
}
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
if (dependencies.Get<ManiaScrollingInfo>() == null)
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
return dependencies;
Config.BindWith(ManiaSetting.ScrollDirection, configDirection);
configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v, true);
}
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)

@ -1,23 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Configuration;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.UI
{
public class ManiaScrollingInfo : IScrollingInfo
{
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
public ManiaScrollingInfo(ManiaConfigManager config)
{
config.BindWith(ManiaSetting.ScrollDirection, configDirection);
configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v, true);
}
}
}

@ -1,21 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.UI
{
public abstract class ManiaScrollingPlayfield : ScrollingPlayfield
{
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
[BackgroundDependencyLoader]
private void load(IScrollingInfo scrollingInfo)
{
direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(direction => Direction.Value = direction, true);
}
}
}

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.UI
/// <summary>
/// A collection of <see cref="Column"/>s.
/// </summary>
public class ManiaStage : ManiaScrollingPlayfield
public class ManiaStage : ScrollingPlayfield
{
public const float HIT_TARGET_POSITION = 50;

@ -56,8 +56,6 @@ namespace osu.Game.Rulesets.Taiko.UI
public TaikoPlayfield(ControlPointInfo controlPoints)
{
Direction.Value = ScrollingDirection.Left;
InternalChild = new PlayfieldAdjustmentContainer
{
Anchor = Anchor.CentreLeft,

@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public TaikoRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
: base(ruleset, beatmap)
{
Direction.Value = ScrollingDirection.Left;
}
[BackgroundDependencyLoader]

@ -4,20 +4,17 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Lists;
using osu.Game.Configuration;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Timing;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.UI.Scrolling.Algorithms;
namespace osu.Game.Tests.Visual
{
@ -26,6 +23,7 @@ namespace osu.Game.Tests.Visual
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
private readonly ScrollingTestContainer[] scrollContainers = new ScrollingTestContainer[4];
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
public TestCaseScrollingHitObjects()
@ -37,13 +35,29 @@ namespace osu.Game.Tests.Visual
{
new Drawable[]
{
playfields[0] = new TestPlayfield(ScrollingDirection.Up),
playfields[1] = new TestPlayfield(ScrollingDirection.Down)
scrollContainers[0] = new ScrollingTestContainer(ScrollingDirection.Up)
{
RelativeSizeAxes = Axes.Both,
Child = playfields[0] = new TestPlayfield()
},
scrollContainers[1] = new ScrollingTestContainer(ScrollingDirection.Up)
{
RelativeSizeAxes = Axes.Both,
Child = playfields[1] = new TestPlayfield()
},
},
new Drawable[]
{
playfields[2] = new TestPlayfield(ScrollingDirection.Left),
playfields[3] = new TestPlayfield(ScrollingDirection.Right)
scrollContainers[2] = new ScrollingTestContainer(ScrollingDirection.Up)
{
RelativeSizeAxes = Axes.Both,
Child = playfields[2] = new TestPlayfield()
},
scrollContainers[3] = new ScrollingTestContainer(ScrollingDirection.Up)
{
RelativeSizeAxes = Axes.Both,
Child = playfields[3] = new TestPlayfield()
}
}
}
});
@ -60,7 +74,7 @@ namespace osu.Game.Tests.Visual
{
base.LoadComplete();
playfields.ForEach(p => p.ControlPoints.Add(new MultiplierControlPoint(0)));
scrollContainers.ForEach(c => c.ControlPoints.Add(new MultiplierControlPoint(0)));
for (int i = 0; i <= 5000; i += 1000)
addHitObject(Time.Current + i);
@ -81,12 +95,15 @@ namespace osu.Game.Tests.Visual
private void addControlPoint(double time)
{
scrollContainers.ForEach(c =>
{
c.ControlPoints.Add(new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } });
c.ControlPoints.Add(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
c.ControlPoints.Add(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
});
playfields.ForEach(p =>
{
p.ControlPoints.Add(new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } });
p.ControlPoints.Add(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
p.ControlPoints.Add(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
TestDrawableControlPoint createDrawablePoint(double t)
{
var obj = new TestDrawableControlPoint(p.Direction, t);
@ -119,23 +136,14 @@ namespace osu.Game.Tests.Visual
}
}
private void setScrollAlgorithm(ScrollAlgorithm algorithm) => playfields.ForEach(p => p.ScrollAlgorithm = algorithm);
private void setScrollAlgorithm(ScrollAlgorithm algorithm) => scrollContainers.ForEach(c => c.ScrollAlgorithm = algorithm);
private class TestPlayfield : ScrollingPlayfield
{
public new ScrollingDirection Direction => base.Direction;
public new ScrollingDirection Direction => base.Direction.Value;
public SortedList<MultiplierControlPoint> ControlPoints => algorithm.ControlPoints;
public ScrollAlgorithm ScrollAlgorithm { set => algorithm.Algorithm = value; }
[Cached(Type = typeof(IScrollAlgorithm))]
private readonly TestScrollAlgorithm algorithm = new TestScrollAlgorithm();
public TestPlayfield(ScrollingDirection direction)
public TestPlayfield()
{
base.Direction.Value = direction;
Padding = new MarginPadding(2);
InternalChildren = new Drawable[]
@ -155,49 +163,6 @@ namespace osu.Game.Tests.Visual
}
}
private class TestScrollAlgorithm : IScrollAlgorithm
{
public readonly SortedList<MultiplierControlPoint> ControlPoints = new SortedList<MultiplierControlPoint>();
private IScrollAlgorithm implementation;
public TestScrollAlgorithm()
{
Algorithm = ScrollAlgorithm.Constant;
}
public ScrollAlgorithm Algorithm
{
set
{
switch (value)
{
case ScrollAlgorithm.Constant:
implementation = new ConstantScrollAlgorithm();
break;
case ScrollAlgorithm.Overlapping:
implementation = new OverlappingScrollAlgorithm(ControlPoints);
break;
case ScrollAlgorithm.Sequential:
implementation = new SequentialScrollAlgorithm(ControlPoints);
break;
}
}
}
public double GetDisplayStartTime(double time, double timeRange)
=> implementation.GetDisplayStartTime(time, timeRange);
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
=> implementation.GetLength(startTime, endTime, timeRange, scrollLength);
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
=> implementation.PositionAt(time, currentTime, timeRange, scrollLength);
public void Reset()
=> implementation.Reset();
}
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
{
public TestDrawableControlPoint(ScrollingDirection direction, double time)

@ -22,11 +22,14 @@ namespace osu.Game.Rulesets.UI.Scrolling
MaxValue = double.MaxValue
};
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
[Resolved]
private IScrollAlgorithm algorithm { get; set; }
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
private Cached initialStateCache = new Cached();
public ScrollingHitObjectContainer()
@ -34,7 +37,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
RelativeSizeAxes = Axes.Both;
TimeRange.ValueChanged += _ => initialStateCache.Invalidate();
Direction.ValueChanged += _ => initialStateCache.Invalidate();
direction.ValueChanged += _ => initialStateCache.Invalidate();
}
[BackgroundDependencyLoader]
private void load()
{
direction.BindTo(scrollingInfo.Direction);
}
public override void Add(DrawableHitObject hitObject)
@ -67,7 +76,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (!initialStateCache.IsValid)
{
switch (Direction.Value)
switch (direction.Value)
{
case ScrollingDirection.Up:
case ScrollingDirection.Down:
@ -92,7 +101,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (hitObject.HitObject is IHasEndTime endTime)
{
switch (Direction.Value)
switch (direction.Value)
{
case ScrollingDirection.Up:
case ScrollingDirection.Down:
@ -125,7 +134,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
private void updatePosition(DrawableHitObject hitObject, double currentTime)
{
switch (Direction.Value)
switch (direction.Value)
{
case ScrollingDirection.Up:
hitObject.Y = algorithm.PositionAt(hitObject.HitObject.StartTime, currentTime, TimeRange, scrollLength);

@ -52,19 +52,20 @@ namespace osu.Game.Rulesets.UI.Scrolling
/// </summary>
protected virtual bool UserScrollSpeedAdjustment => true;
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
/// <summary>
/// The container that contains the <see cref="DrawableHitObject"/>s.
/// </summary>
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)HitObjectContainer;
/// <summary>
/// The direction in which <see cref="DrawableHitObject"/>s in this <see cref="ScrollingPlayfield"/> should scroll.
/// </summary>
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
[BackgroundDependencyLoader]
private void load()
{
Direction.BindTo(scrollingInfo.Direction);
HitObjects.TimeRange.BindTo(VisibleTimeRange);
}
@ -88,11 +89,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
public bool OnReleased(GlobalAction action) => false;
protected sealed override HitObjectContainer CreateHitObjectContainer()
{
var container = new ScrollingHitObjectContainer();
container.Direction.BindTo(Direction);
return container;
}
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
}
}

@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Lists;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
@ -23,6 +24,10 @@ namespace osu.Game.Rulesets.UI.Scrolling
where TObject : HitObject
where TPlayfield : ScrollingPlayfield
{
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
protected virtual ScrollAlgorithm ScrollAlgorithm => ScrollAlgorithm.Sequential;
/// <summary>
/// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s
/// inside this <see cref="RulesetContainer{TPlayfield,TObject}"/>.
@ -30,7 +35,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
/// <returns></returns>
private readonly SortedList<MultiplierControlPoint> controlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default);
protected virtual ScrollAlgorithm ScrollAlgorithm => ScrollAlgorithm.Sequential;
private IScrollingInfo scrollingInfo;
[Cached(Type = typeof(IScrollAlgorithm))]
private readonly IScrollAlgorithm algorithm;
@ -55,6 +60,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
[BackgroundDependencyLoader]
private void load()
{
scrollingInfo.Direction.BindTo(Direction);
// Calculate default multiplier control points
var lastTimingPoint = new TimingControlPoint();
var lastDifficultyPoint = new DifficultyControlPoint();
@ -99,5 +106,22 @@ namespace osu.Game.Rulesets.UI.Scrolling
if (controlPoints.Count == 0)
controlPoints.Add(new MultiplierControlPoint { Velocity = Beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier });
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
if ((scrollingInfo = dependencies.Get<IScrollingInfo>()) == null)
dependencies.CacheAs(scrollingInfo = CreateScrollingInfo());
return dependencies;
}
protected virtual IScrollingInfo CreateScrollingInfo() => new ScrollingInfo();
private class ScrollingInfo : IScrollingInfo
{
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>();
}
}
}

@ -0,0 +1,87 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers;
using osu.Framework.Lists;
using osu.Game.Configuration;
using osu.Game.Rulesets.Timing;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Rulesets.UI.Scrolling.Algorithms;
namespace osu.Game.Tests.Visual
{
/// <summary>
/// A container which provides a <see cref="IScrollingInfo"/> to children.
/// This should only be used when testing
/// </summary>
public class ScrollingTestContainer : Container
{
public SortedList<MultiplierControlPoint> ControlPoints => scrollAlgorithm.ControlPoints;
public ScrollAlgorithm ScrollAlgorithm { set => scrollAlgorithm.Algorithm = value; }
[Cached(Type = typeof(IScrollingInfo))]
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
[Cached(Type = typeof(IScrollAlgorithm))]
private readonly TestScrollAlgorithm scrollAlgorithm = new TestScrollAlgorithm();
public ScrollingTestContainer(ScrollingDirection direction)
{
scrollingInfo.Direction.Value = direction;
}
public void Flip() => scrollingInfo.Direction.Value = scrollingInfo.Direction.Value == ScrollingDirection.Up ? ScrollingDirection.Down : ScrollingDirection.Up;
private class TestScrollingInfo : IScrollingInfo
{
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
}
private class TestScrollAlgorithm : IScrollAlgorithm
{
public readonly SortedList<MultiplierControlPoint> ControlPoints = new SortedList<MultiplierControlPoint>();
private IScrollAlgorithm implementation;
public TestScrollAlgorithm()
{
Algorithm = ScrollAlgorithm.Constant;
}
public ScrollAlgorithm Algorithm
{
set
{
switch (value)
{
case ScrollAlgorithm.Constant:
implementation = new ConstantScrollAlgorithm();
break;
case ScrollAlgorithm.Overlapping:
implementation = new OverlappingScrollAlgorithm(ControlPoints);
break;
case ScrollAlgorithm.Sequential:
implementation = new SequentialScrollAlgorithm(ControlPoints);
break;
}
}
}
public double GetDisplayStartTime(double time, double timeRange)
=> implementation.GetDisplayStartTime(time, timeRange);
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
=> implementation.GetLength(startTime, endTime, timeRange, scrollLength);
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
=> implementation.PositionAt(time, currentTime, timeRange, scrollLength);
public void Reset()
=> implementation.Reset();
}
}
}