1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 17:32:54 +08:00

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 class TestCaseScrollingHitObjects : OsuTestCase
{ {
public override string Description => "SpeedAdjustmentContainer/DrawableTimingSection"; public override string Description => "SpeedAdjustmentContainer/ScrollingContainer";
private readonly BindableDouble timeRangeBindable; private readonly BindableDouble timeRangeBindable;
private readonly OsuSpriteText bottomLabel; 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; private readonly MultiplierControlPoint controlPoint;
public TestDrawableTimingSection(MultiplierControlPoint controlPoint) public TestScrollingContainer(MultiplierControlPoint controlPoint)
{ {
this.controlPoint = 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>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.Mania.Timing namespace osu.Game.Rulesets.Mania.Timing
{ {
/// <summary> /// <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> /// </summary>
internal class GravityScrollingDrawableTimingSection : DrawableTimingSection internal class GravityScrollingContainer : ScrollingContainer
{ {
private readonly MultiplierControlPoint controlPoint; private readonly MultiplierControlPoint controlPoint;
public GravityScrollingDrawableTimingSection(MultiplierControlPoint controlPoint) public GravityScrollingContainer(MultiplierControlPoint controlPoint)
{ {
this.controlPoint = controlPoint; this.controlPoint = controlPoint;
} }
@ -51,10 +52,10 @@ namespace osu.Game.Rulesets.Mania.Timing
private double acceleration => 1 / VisibleTimeRange; private double acceleration => 1 / VisibleTimeRange;
/// <summary> /// <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> /// </summary>
/// <param name="time">The non-offset time.</param> /// <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; private double relativeTimeAt(double time) => Time.Current - time + VisibleTimeRange;
} }
} }

View File

@ -15,15 +15,14 @@ namespace osu.Game.Rulesets.Mania.Timing
this.scrollingAlgorithm = scrollingAlgorithm; this.scrollingAlgorithm = scrollingAlgorithm;
} }
protected override DrawableTimingSection CreateTimingSection() protected override ScrollingContainer CreateScrollingContainer()
{ {
switch (scrollingAlgorithm) switch (scrollingAlgorithm)
{ {
default: default:
case ScrollingAlgorithm.Basic: return base.CreateScrollingContainer();
return new BasicScrollingDrawableTimingSection(ControlPoint);
case ScrollingAlgorithm.Gravity: 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\ManiaHitObject.cs" />
<Compile Include="Objects\Note.cs" /> <Compile Include="Objects\Note.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Timing\BasicScrollingDrawableTimingSection.cs" /> <Compile Include="Timing\GravityScrollingContainer.cs" />
<Compile Include="Timing\GravityScrollingDrawableTimingSection.cs" />
<Compile Include="Timing\ScrollingAlgorithm.cs" /> <Compile Include="Timing\ScrollingAlgorithm.cs" />
<Compile Include="UI\Column.cs" /> <Compile Include="UI\Column.cs" />
<Compile Include="UI\ManiaHitRenderer.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. /// and <see cref="Container{T}.RelativeChildOffset"/> to apply further time offsets to this collection of hit objects.
/// </para> /// </para>
/// </summary> /// </summary>
public abstract class DrawableTimingSection : Container<DrawableHitObject> public abstract class ScrollingContainer : Container<DrawableHitObject>
{ {
private readonly BindableDouble visibleTimeRange = new BindableDouble(); private readonly BindableDouble visibleTimeRange = new BindableDouble();
/// <summary> /// <summary>
@ -71,9 +71,9 @@ namespace osu.Game.Rulesets.Timing
} }
/// <summary> /// <summary>
/// Creates a new <see cref="DrawableTimingSection"/>. /// Creates a new <see cref="ScrollingContainer"/>.
/// </summary> /// </summary>
protected DrawableTimingSection() protected ScrollingContainer()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both; RelativePositionAxes = Axes.Both;
@ -128,8 +128,8 @@ namespace osu.Game.Rulesets.Timing
} }
/// <summary> /// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum /// 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="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>. /// end time between all hit objects relative to this <see cref="ScrollingContainer"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary> /// </summary>
public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration()); public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration());

View File

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

View File

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