mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Rewrite/add comments.
This commit is contained in:
@ -7,8 +7,7 @@ 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"/>.
|
||||
/// A <see cref="ScrollingContainer"/> which scrolls linearly relative to the <see cref="MultiplierControlPoint"/> start time.
|
||||
/// </summary>
|
||||
internal class LinearScrollingContainer : ScrollingContainer
|
||||
{
|
||||
|
@ -13,29 +13,13 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of hit objects which scrolls within a <see cref="SpeedAdjustmentContainer"/>.
|
||||
///
|
||||
/// <para>
|
||||
/// This container handles the conversion between time and position through <see cref="Container{T}.RelativeChildSize"/> and
|
||||
/// <see cref="Container{T}.RelativeChildOffset"/> such that hit objects added to this container should have time values set as their
|
||||
/// positions/sizes to make proper use of this container.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This container will auto-size to the total duration of the contained hit objects along the desired auto-sizing axes such that the resulting size
|
||||
/// of this container will be a value representing the total duration of all contained hit objects.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// This container is and must always be relatively-sized and positioned to its such that the parent can utilise <see cref="Container{T}.RelativeChildSize"/>
|
||||
/// and <see cref="Container{T}.RelativeChildOffset"/> to apply further time offsets to this collection of hit objects.
|
||||
/// </para>
|
||||
/// A container that scrolls relative to the current time. Will autosize to the total duration of all contained hit objects along the scrolling axes.
|
||||
/// </summary>
|
||||
public abstract class ScrollingContainer : Container<DrawableHitObject>
|
||||
{
|
||||
private readonly BindableDouble visibleTimeRange = new BindableDouble { Default = 1000 };
|
||||
/// <summary>
|
||||
/// Gets or sets the range of time that is visible by the length of this container.
|
||||
/// Gets or sets the range of time that is visible by the length of the scrolling axes.
|
||||
/// </summary>
|
||||
public BindableDouble VisibleTimeRange
|
||||
{
|
||||
@ -44,34 +28,17 @@ namespace osu.Game.Rulesets.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Axes through which this timing section scrolls. This is set by the <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// The axes through which this <see cref="ScrollingContainer"/> scrolls. This is set by the <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// </summary>
|
||||
internal Axes ScrollingAxes;
|
||||
|
||||
/// <summary>
|
||||
/// The control point that provides the speed adjustments for this container. This is set by the <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// The control point that defines the speed adjustments for this container. This is set by the <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// </summary>
|
||||
internal MultiplierControlPoint ControlPoint;
|
||||
|
||||
private Cached<double> durationBacking;
|
||||
|
||||
protected override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var xHitObject = x as DrawableHitObject;
|
||||
var yHitObject = y as DrawableHitObject;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (xHitObject?.HitObject == null || yHitObject?.HitObject == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = yHitObject.HitObject.StartTime.CompareTo(xHitObject.HitObject.StartTime);
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
return base.Compare(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ScrollingContainer"/>.
|
||||
/// </summary>
|
||||
@ -106,13 +73,8 @@ namespace osu.Game.Rulesets.Timing
|
||||
if (baseDuration == 0)
|
||||
baseDuration = 1;
|
||||
|
||||
// Scrolling ruleset hit objects typically have anchors+origins set to the hit object's start time, but if the hit object doesn't implement IHasEndTime and lies on the control point
|
||||
// then the baseDuration above will be 0. This will cause problems with masking when it is further set as the value for Size in Update(). We _want_ the timing section bounds to
|
||||
// completely enclose the hit object to avoid the masking optimisations.
|
||||
//
|
||||
// To do this we need to find a duration that corresponds to the absolute size of the element that extrudes beyond the timing section's bounds and add that to baseDuration.
|
||||
// We can utilize the fact that the Size and RelativeChildSpace are 1:1, meaning that an change in duration for the timing section has no change to the hit object's positioning
|
||||
// and simply find the largest absolutely-sized element in this timing section. This introduces a little bit of error, but will never under-estimate the duration.
|
||||
// This container needs to resize such that it completely encloses the hit objects to avoid masking optimisations. This is done by converting the largest
|
||||
// absolutely-sized element along the scrolling axes and adding a corresponding duration value. This introduces a bit of error, but will never under-estimate.ion.
|
||||
|
||||
// Find the largest element that is absolutely-sized along ScrollingAxes
|
||||
float maxAbsoluteSize = Children.Where(c => (c.RelativeSizeAxes & ScrollingAxes) == 0)
|
||||
@ -129,7 +91,7 @@ namespace osu.Game.Rulesets.Timing
|
||||
|
||||
/// <summary>
|
||||
/// 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"/>.
|
||||
/// duration of all hit objects relative to this <see cref="ScrollingContainer"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
|
||||
/// </summary>
|
||||
public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration());
|
||||
|
||||
@ -137,7 +99,7 @@ namespace osu.Game.Rulesets.Timing
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// We want our size and position-space along ScrollingAxes to span our duration to completely enclose all the hit objects
|
||||
// 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
|
||||
RelativeChildSize = Size;
|
||||
|
@ -11,19 +11,14 @@ using OpenTK;
|
||||
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="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>
|
||||
/// A container that provides the speed adjustments defined by <see cref="MultiplierControlPoint"/>s to affect the scroll speed
|
||||
/// of container <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
public class SpeedAdjustmentContainer : Container<DrawableHitObject>
|
||||
{
|
||||
private readonly Bindable<double> visibleTimeRange = new Bindable<double> { Default = 1000 };
|
||||
/// <summary>
|
||||
/// Gets or sets the range of time that is visible by the length of this container.
|
||||
/// Gets or sets the range of time that is visible by the length of the scrolling axes.
|
||||
/// </summary>
|
||||
public Bindable<double> VisibleTimeRange
|
||||
{
|
||||
@ -35,10 +30,13 @@ namespace osu.Game.Rulesets.Timing
|
||||
private Container<DrawableHitObject> content;
|
||||
|
||||
/// <summary>
|
||||
/// Axes which the content of this container will scroll through.
|
||||
/// The axes which the content of this container will scroll through.
|
||||
/// </summary>
|
||||
public Axes ScrollingAxes { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="MultiplierControlPoint"/> that defines the speed adjustments.
|
||||
/// </summary>
|
||||
public readonly MultiplierControlPoint ControlPoint;
|
||||
|
||||
private ScrollingContainer scrollingContainer;
|
||||
@ -46,11 +44,10 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="SpeedAdjustmentContainer"/>.
|
||||
/// </summary>
|
||||
/// <param name="controlPoint">The <see cref="MultiplierControlPoint"/> which provides the speed adjustments for this container.</param>
|
||||
/// <param name="controlPoint">The <see cref="MultiplierControlPoint"/> that defines the speed adjustments.</param>
|
||||
public SpeedAdjustmentContainer(MultiplierControlPoint controlPoint)
|
||||
{
|
||||
ControlPoint = controlPoint;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -93,17 +90,17 @@ namespace osu.Game.Rulesets.Timing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this speed adjustment can contain a hit object. This is true if the hit object occurs after this speed adjustment with respect to time.
|
||||
/// Whether a <see cref="DrawableHitObject"/> falls within this <see cref="SpeedAdjustmentContainer"/>s affecting timespan.
|
||||
/// </summary>
|
||||
public bool CanContain(DrawableHitObject hitObject) => CanContain(hitObject.HitObject.StartTime);
|
||||
|
||||
/// <summary>
|
||||
/// Whether this speed adjustment can contain an object placed at a time value. This is true if the time occurs after this speed adjustment.
|
||||
/// Whether a point in time falls within this <see cref="SpeedAdjustmentContainer"/>s affecting timespan.
|
||||
/// </summary>
|
||||
public bool CanContain(double startTime) => ControlPoint.StartTime <= startTime;
|
||||
|
||||
/// <summary>
|
||||
/// Creates the container which contains a collection of hit objects and scrolls through this SpeedAdjustmentContainer.
|
||||
/// 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);
|
||||
|
Reference in New Issue
Block a user