More cleanup + xmldoc changes.

This commit is contained in:
smoogipooo 2017-06-09 03:36:15 +09:00
parent 8de6bdf340
commit a9c3234eb5
4 changed files with 49 additions and 34 deletions

View File

@ -57,14 +57,13 @@ protected override void Update()
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
// By doing this the scroll speed of the hit objects is changed by a factor of Size / RelativeChildSize
// The application of speed changes happens by modifying our size while maintaining the parent's time span as our relative child size
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);
}
/// <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>
public bool CanContain(DrawableHitObject hitObject) => TimingSection.Time <= hitObject.HitObject.StartTime;

View File

@ -9,6 +9,7 @@
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using OpenTK;
namespace osu.Game.Rulesets.Timing.Drawables
@ -23,8 +24,8 @@ namespace osu.Game.Rulesets.Timing.Drawables
/// </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
/// will also be a time value if hit objects added to this container have time values as their positions/sizes.
/// This container will auto-size to the total size of its children along the desired auto-sizing axes such that the reasulting size
/// of this container will also be a time value.
/// </para>
///
/// <para>
@ -92,7 +93,15 @@ protected override void UpdateAfterChildren()
if (!Children.Any())
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
// 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 height = Children.Select(child => child.Y + child.Height).Max() - RelativeChildOffset.Y;

View File

@ -6,7 +6,7 @@ namespace osu.Game.Rulesets.Timing
public class TimingSection
{
/// <summary>
/// The time at which this timing change happened.
/// The time at which this timing section starts.
/// </summary>
public double Time;

View File

@ -11,59 +11,66 @@
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>
{
/// <summary>
/// The length of time which is visualized
/// The length of time visible throughout the span of this container.
/// </summary>
public double TimeSpan { get; set; }
public double TimeSpan;
/// <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>
/// <param name="hitObject">The hit object to add.</param>
public void Add(DrawableHitObject hitObject)
{
var target = timingChangeFor(hitObject);
var target = timingSectionFor(hitObject);
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);
}
protected override IComparer<Drawable> DepthComparer => new TimingChangeReverseStartTimeComparer();
protected override IComparer<Drawable> DepthComparer => new TimingSectionReverseStartTimeComparer();
/// <summary>
/// Finds the most applicable timing change 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.
/// Finds the most applicable timing section that can contain a hit object. If the hit object occurs before the first (time-wise)
/// timing section, then the timing section returned is the first (time-wise) timing section.
/// </summary>
/// <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>
private DrawableTimingSection timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
}
/// <returns>The last (time-wise) timing section which can contain <paramref name="hitObject"/>. Null if no timing section exists.</returns>
private DrawableTimingSection timingSectionFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject)) ?? Children.LastOrDefault();
/// <summary>
/// Compares two timing changes 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.
/// </summary>
public class TimingChangeReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer
{
public override int Compare(Drawable x, Drawable y)
/// <summary>
/// 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 sections in reverse order.
/// </summary>
private class TimingSectionReverseStartTimeComparer : ReverseCreationOrderDepthComparer
{
var timingChangeX = x as DrawableTimingSection;
var timingChangeY = y as DrawableTimingSection;
public override int Compare(Drawable x, Drawable y)
{
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 (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null)
return base.Compare(x, y);
// If either of the two drawables are not hit objects, fall back to the base comparer
if (timingChangeX?.TimingSection == null || timingChangeY?.TimingSection == null)
return base.Compare(x, y);
// Compare by start time
int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time);
if (i != 0)
return i;
// Compare by start time
int i = timingChangeY.TimingSection.Time.CompareTo(timingChangeX.TimingSection.Time);
return base.Compare(x, y);
return i != 0 ? i : base.Compare(x, y);
}
}
}
}