Rename *ScrollingDrawableTimingSection -> *ScrollingContainer, move LinearScrollingContainer to osu.Game, make SpeedAdjustmentContainer non-abstract.

This commit is contained in:
smoogipooo 2017-08-04 20:52:53 +09:30
parent d42faa02df
commit 54503eef71
9 changed files with 66 additions and 61 deletions

View File

@ -18,7 +18,7 @@ namespace osu.Desktop.Tests.Visual
{
public class TestCaseScrollingHitObjects : OsuTestCase
{
public override string Description => "SpeedAdjustmentContainer/DrawableTimingSection";
public override string Description => "SpeedAdjustmentContainer/ScrollingContainer";
private readonly BindableDouble timeRangeBindable;
private readonly OsuSpriteText bottomLabel;
@ -131,13 +131,13 @@ namespace osu.Desktop.Tests.Visual
{
}
protected override DrawableTimingSection CreateTimingSection() => new TestDrawableTimingSection(ControlPoint);
protected override ScrollingContainer CreateScrollingContainer() => new TestScrollingContainer(ControlPoint);
private class TestDrawableTimingSection : DrawableTimingSection
private class TestScrollingContainer : ScrollingContainer
{
private readonly MultiplierControlPoint controlPoint;
public TestDrawableTimingSection(MultiplierControlPoint controlPoint)
public TestScrollingContainer(MultiplierControlPoint controlPoint)
{
this.controlPoint = controlPoint;
}

View File

@ -1,27 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Mania.Timing
{
/// <summary>
/// A <see cref="DrawableTimingSection"/> which scrolls relative to the control point start time.
/// </summary>
internal class BasicScrollingDrawableTimingSection : DrawableTimingSection
{
private readonly MultiplierControlPoint controlPoint;
public BasicScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
{
this.controlPoint = controlPoint;
}
protected override void Update()
{
base.Update();
Y = (float)(controlPoint.StartTime - Time.Current);
}
}
}

View File

@ -1,18 +1,19 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Mania.Timing
{
/// <summary>
/// A <see cref="DrawableTimingSection"/> that emulates a form of gravity where hit objects speed up over time.
/// A <see cref="ScrollingContainer"/> that emulates a form of gravity where hit objects speed up over time.
/// </summary>
internal class GravityScrollingDrawableTimingSection : DrawableTimingSection
internal class GravityScrollingContainer : ScrollingContainer
{
private readonly MultiplierControlPoint controlPoint;
public GravityScrollingDrawableTimingSection(MultiplierControlPoint controlPoint)
public GravityScrollingContainer(MultiplierControlPoint controlPoint)
{
this.controlPoint = controlPoint;
}
@ -51,10 +52,10 @@ namespace osu.Game.Rulesets.Mania.Timing
private double acceleration => 1 / VisibleTimeRange;
/// <summary>
/// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="DrawableTimingSection.VisibleTimeRange"/>.
/// Computes the current time relative to <paramref name="time"/>, accounting for <see cref="ScrollingContainer.VisibleTimeRange"/>.
/// </summary>
/// <param name="time">The non-offset time.</param>
/// <returns>The current time relative to <paramref name="time"/> - <see cref="DrawableTimingSection.VisibleTimeRange"/>. </returns>
/// <returns>The current time relative to <paramref name="time"/> - <see cref="ScrollingContainer.VisibleTimeRange"/>. </returns>
private double relativeTimeAt(double time) => Time.Current - time + VisibleTimeRange;
}
}

View File

@ -15,15 +15,14 @@ namespace osu.Game.Rulesets.Mania.Timing
this.scrollingAlgorithm = scrollingAlgorithm;
}
protected override DrawableTimingSection CreateTimingSection()
protected override ScrollingContainer CreateScrollingContainer()
{
switch (scrollingAlgorithm)
{
default:
case ScrollingAlgorithm.Basic:
return new BasicScrollingDrawableTimingSection(ControlPoint);
return base.CreateScrollingContainer();
case ScrollingAlgorithm.Gravity:
return new GravityScrollingDrawableTimingSection(ControlPoint);
return new GravityScrollingContainer(ControlPoint);
}
}
}

View File

@ -79,8 +79,7 @@
<Compile Include="Objects\ManiaHitObject.cs" />
<Compile Include="Objects\Note.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Timing\BasicScrollingDrawableTimingSection.cs" />
<Compile Include="Timing\GravityScrollingDrawableTimingSection.cs" />
<Compile Include="Timing\GravityScrollingContainer.cs" />
<Compile Include="Timing\ScrollingAlgorithm.cs" />
<Compile Include="UI\Column.cs" />
<Compile Include="UI\ManiaHitRenderer.cs" />

View File

@ -0,0 +1,32 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Timing
{
/// <summary>
/// A <see cref="ScrollingContainer"/> which scrolls relative to the control point start time.
/// This is the default <see cref="ScrollingContainer"/> returned by the base <see cref="SpeedAdjustmentContainer"/>.
/// </summary>
internal class LinearScrollingContainer : ScrollingContainer
{
private readonly Axes scrollingAxes;
private readonly MultiplierControlPoint controlPoint;
public LinearScrollingContainer(Axes scrollingAxes, MultiplierControlPoint controlPoint)
{
this.scrollingAxes = scrollingAxes;
this.controlPoint = controlPoint;
}
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);
}
}
}

View File

@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Timing
/// and <see cref="Container{T}.RelativeChildOffset"/> to apply further time offsets to this collection of hit objects.
/// </para>
/// </summary>
public abstract class DrawableTimingSection : Container<DrawableHitObject>
public abstract class ScrollingContainer : Container<DrawableHitObject>
{
private readonly BindableDouble visibleTimeRange = new BindableDouble();
/// <summary>
@ -71,9 +71,9 @@ namespace osu.Game.Rulesets.Timing
}
/// <summary>
/// Creates a new <see cref="DrawableTimingSection"/>.
/// Creates a new <see cref="ScrollingContainer"/>.
/// </summary>
protected DrawableTimingSection()
protected ScrollingContainer()
{
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
@ -128,8 +128,8 @@ namespace osu.Game.Rulesets.Timing
}
/// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// The maximum duration of any one hit object inside this <see cref="ScrollingContainer"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="ScrollingContainer"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary>
public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration());

View File

@ -12,14 +12,14 @@ namespace osu.Game.Rulesets.Timing
{
/// <summary>
/// A container for hit objects which applies applies the speed adjustments defined by the properties of a <see cref="Timing.MultiplierControlPoint"/>
/// to affect the scroll speed of the contained <see cref="DrawableTimingSection"/>.
/// to affect the scroll speed of the contained <see cref="ScrollingContainer"/>.
///
/// <para>
/// This container must always be relatively-sized to its parent to provide the speed adjustments. This container will provide the speed adjustments
/// by modifying its size while maintaining a constant <see cref="Container{T}.RelativeChildSize"/> for its children
/// </para>
/// </summary>
public abstract class SpeedAdjustmentContainer : Container<DrawableHitObject>
public class SpeedAdjustmentContainer : Container<DrawableHitObject>
{
private readonly Bindable<double> visibleTimeRange = new Bindable<double>();
/// <summary>
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Timing
public readonly MultiplierControlPoint ControlPoint;
private DrawableTimingSection timingSection;
private ScrollingContainer scrollingContainer;
/// <summary>
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
@ -58,14 +58,14 @@ namespace osu.Game.Rulesets.Timing
[BackgroundDependencyLoader]
private void load()
{
timingSection = CreateTimingSection();
scrollingContainer = CreateScrollingContainer();
timingSection.ScrollingAxes = ScrollingAxes;
timingSection.ControlPoint = ControlPoint;
timingSection.VisibleTimeRange.BindTo(VisibleTimeRange);
timingSection.RelativeChildOffset = new Vector2((ScrollingAxes & Axes.X) > 0 ? (float)ControlPoint.StartTime : 0, (ScrollingAxes & Axes.Y) > 0 ? (float)ControlPoint.StartTime : 0);
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 = timingSection);
AddInternal(content = scrollingContainer);
}
protected override void Update()
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Timing
}
public override double LifetimeStart => ControlPoint.StartTime - VisibleTimeRange;
public override double LifetimeEnd => ControlPoint.StartTime + timingSection.Duration + VisibleTimeRange;
public override double LifetimeEnd => ControlPoint.StartTime + scrollingContainer.Duration + VisibleTimeRange;
public override void Add(DrawableHitObject drawable)
{
@ -99,9 +99,9 @@ namespace osu.Game.Rulesets.Timing
public bool CanContain(double startTime) => ControlPoint.StartTime <= startTime;
/// <summary>
/// Creates the container which handles the movement of a collection of hit objects.
/// Creates the container which contains a collection of hit objects and scrolls through this SpeedAdjustmentContainer.
/// </summary>
/// <returns>The <see cref="DrawableTimingSection"/>.</returns>
protected abstract DrawableTimingSection CreateTimingSection();
/// <returns>The <see cref="ScrollingContainer"/>.</returns>
protected virtual ScrollingContainer CreateScrollingContainer() => new LinearScrollingContainer(ScrollingAxes, ControlPoint);
}
}

View File

@ -227,7 +227,8 @@
<Compile Include="Rulesets\Scoring\Score.cs" />
<Compile Include="Rulesets\Scoring\ScoreProcessor.cs" />
<Compile Include="Rulesets\Timing\SpeedAdjustmentContainer.cs" />
<Compile Include="Rulesets\Timing\DrawableTimingSection.cs" />
<Compile Include="Rulesets\Timing\LinearScrollingContainer.cs" />
<Compile Include="Rulesets\Timing\ScrollingContainer.cs" />
<Compile Include="Rulesets\Timing\MultiplierControlPoint.cs" />
<Compile Include="Rulesets\Timing\SpeedAdjustmentCollection.cs" />
<Compile Include="Screens\Menu\MenuSideFlashes.cs" />