mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:33:21 +08:00
More cleanup + xmldoc changes.
This commit is contained in:
parent
8de6bdf340
commit
a9c3234eb5
@ -57,14 +57,13 @@ namespace osu.Game.Rulesets.Timing.Drawables
|
|||||||
|
|
||||||
float speedAdjustedSize = (float)(1000 / TimingSection.BeatLength / TimingSection.SpeedMultiplier);
|
float speedAdjustedSize = (float)(1000 / TimingSection.BeatLength / TimingSection.SpeedMultiplier);
|
||||||
|
|
||||||
// The application of speed changes happens by modifying our size while maintaining the parent's relative child size as our own
|
// The application of speed changes happens by modifying our size while maintaining the parent's time span as our relative child size
|
||||||
// By doing this the scroll speed of the hit objects is changed by a factor of Size / RelativeChildSize
|
|
||||||
Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1);
|
Size = new Vector2((scrollingAxes & Axes.X) > 0 ? speedAdjustedSize : 1, (scrollingAxes & Axes.Y) > 0 ? speedAdjustedSize : 1);
|
||||||
RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)parent.TimeSpan : 1, (scrollingAxes & Axes.Y) > 0 ? (float)parent.TimeSpan : 1);
|
RelativeChildSize = new Vector2((scrollingAxes & Axes.X) > 0 ? (float)parent.TimeSpan : 1, (scrollingAxes & Axes.Y) > 0 ? (float)parent.TimeSpan : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this timing change can contain a hit object. This is true if the hit object occurs after this timing change with respect to time.
|
/// Whether this timing section can contain a hit object. This is true if the hit object occurs after this timing section with respect to time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool CanContain(DrawableHitObject hitObject) => TimingSection.Time <= hitObject.HitObject.StartTime;
|
public bool CanContain(DrawableHitObject hitObject) => TimingSection.Time <= hitObject.HitObject.StartTime;
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Timing.Drawables
|
namespace osu.Game.Rulesets.Timing.Drawables
|
||||||
@ -23,8 +24,8 @@ namespace osu.Game.Rulesets.Timing.Drawables
|
|||||||
/// </para>
|
/// </para>
|
||||||
///
|
///
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This container will auto-size to the total size of its children along the desired auto-sizing axes such that the size of this container
|
/// This container will auto-size to the total size of its children along the desired auto-sizing axes such that the reasulting size
|
||||||
/// will also be a time value if hit objects added to this container have time values as their positions/sizes.
|
/// of this container will also be a time value.
|
||||||
/// </para>
|
/// </para>
|
||||||
///
|
///
|
||||||
/// <para>
|
/// <para>
|
||||||
@ -92,7 +93,15 @@ namespace osu.Game.Rulesets.Timing.Drawables
|
|||||||
if (!Children.Any())
|
if (!Children.Any())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//double maxDuration = Children.Select(c => (c.HitObject as IHasEndTime)?.EndTime ?? c.HitObject.StartTime).Max();
|
||||||
|
//float width = (float)maxDuration - RelativeChildOffset.X;
|
||||||
|
//float height = (float)maxDuration - RelativeChildOffset.Y;
|
||||||
|
|
||||||
|
|
||||||
// Auto-size to the total size of our children
|
// Auto-size to the total size of our children
|
||||||
|
// This ends up being the total duration of our children, however for now this is a more sure-fire way to calculate this
|
||||||
|
// than the above due to some undesired masking optimisations causing some hit objects to be culled...
|
||||||
|
// Todo: When this is investigated more we should use the above method as it is a little more exact
|
||||||
float width = Children.Select(child => child.X + child.Width).Max() - RelativeChildOffset.X;
|
float width = Children.Select(child => child.X + child.Width).Max() - RelativeChildOffset.X;
|
||||||
float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y;
|
float height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ namespace osu.Game.Rulesets.Timing
|
|||||||
public class TimingSection
|
public class TimingSection
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time at which this timing change happened.
|
/// The time at which this timing section starts.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double Time;
|
public double Time;
|
||||||
|
|
||||||
|
@ -11,59 +11,66 @@ using osu.Game.Rulesets.Timing.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Timing
|
namespace osu.Game.Rulesets.Timing
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A collection of timing sections which contain hit objects.
|
||||||
|
///
|
||||||
|
/// <para>
|
||||||
|
/// This container provides <see cref="TimeSpan"/> for the timing sections. This is a value that indicates the amount of time
|
||||||
|
/// that is visible throughout the span of this container.
|
||||||
|
/// For example, only hit objects with start time less than or equal to 1000 will be visible with <see cref="TimeSpan"/> = 1000.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
public class TimingSectionCollection : Container<DrawableTimingSection>
|
public class TimingSectionCollection : Container<DrawableTimingSection>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The length of time which is visualized
|
/// The length of time visible throughout the span of this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double TimeSpan { get; set; }
|
public double TimeSpan;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds a hit object to the most applicable timing change in this container.
|
/// Adds a hit object to the most applicable timing section in this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The hit object to add.</param>
|
/// <param name="hitObject">The hit object to add.</param>
|
||||||
public void Add(DrawableHitObject hitObject)
|
public void Add(DrawableHitObject hitObject)
|
||||||
{
|
{
|
||||||
var target = timingChangeFor(hitObject);
|
var target = timingSectionFor(hitObject);
|
||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
throw new ArgumentException("No timing change could be found that can contain the hit object.", nameof(hitObject));
|
throw new ArgumentException("No timing section could be found that can contain the hit object.", nameof(hitObject));
|
||||||
|
|
||||||
target.Add(hitObject);
|
target.Add(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IComparer<Drawable> DepthComparer => new TimingChangeReverseStartTimeComparer();
|
protected override IComparer<Drawable> DepthComparer => new TimingSectionReverseStartTimeComparer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the most applicable timing change that can contain a hit object. If the hit object occurs before the first (time-wise)
|
/// Finds the most applicable timing section that can contain a hit object. If the hit object occurs before the first (time-wise)
|
||||||
/// timing change, then the timing change returned is the first (time-wise) timing change.
|
/// timing section, then the timing section returned is the first (time-wise) timing section.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The hit object to contain.</param>
|
/// <param name="hitObject">The hit object to contain.</param>
|
||||||
/// <returns>The last (time-wise) timing change which can contain <paramref name="hitObject"/>. Null if no timing change exists.</returns>
|
/// <returns>The last (time-wise) timing section which can contain <paramref name="hitObject"/>. Null if no timing section exists.</returns>
|
||||||
private DrawableTimingSection timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
|
private DrawableTimingSection timingSectionFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Compares two timing changes by their start time, falling back to creation order if their start time is equal.
|
/// Compares two timing sections by their start time, falling back to creation order if their start time is equal.
|
||||||
/// This will compare the two timing changes in reverse order.
|
/// This will compare the two timing sections in reverse order.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TimingChangeReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer
|
private class TimingSectionReverseStartTimeComparer : ReverseCreationOrderDepthComparer
|
||||||
{
|
|
||||||
public override int Compare(Drawable x, Drawable y)
|
|
||||||
{
|
{
|
||||||
var timingChangeX = x as DrawableTimingSection;
|
public override int Compare(Drawable x, Drawable y)
|
||||||
var timingChangeY = y as DrawableTimingSection;
|
{
|
||||||
|
var timingChangeX = x as DrawableTimingSection;
|
||||||
|
var timingChangeY = y as DrawableTimingSection;
|
||||||
|
|
||||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||||
if (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null)
|
if (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null)
|
||||||
return base.Compare(x, y);
|
return base.Compare(x, y);
|
||||||
|
|
||||||
// Compare by start time
|
// Compare by start time
|
||||||
int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time);
|
int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time);
|
||||||
if (i != 0)
|
|
||||||
return i;
|
|
||||||
|
|
||||||
return base.Compare(x, y);
|
return i != 0 ? i : base.Compare(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user