mirror of
https://github.com/ppy/osu
synced 2025-03-29 14:47:04 +00:00
Fix incorrect sorting.
This commit is contained in:
parent
1da5d508fa
commit
d75bbb2b88
@ -35,11 +35,37 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
target.Add(hitObject);
|
target.Add(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IComparer<Drawable> DepthComparer => new TimingChangeReverseStartTimeComparer();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the most applicable timing change that can contain a hit object.
|
/// Finds the most applicable timing change that can contain a hit object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The hit object to contain.</param>
|
/// <param name="hitObject">The hit object to contain.</param>
|
||||||
/// <returns>The last timing change which can contain <paramref name="hitObject"/>.</returns>
|
/// <returns>The last timing change which can contain <paramref name="hitObject"/>. Null if no timing change can contain the hit object.</returns>
|
||||||
private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.LastOrDefault(c => c.CanContain(hitObject)) ?? Children.FirstOrDefault();
|
private DrawableTimingChange timingChangeFor(DrawableHitObject hitObject) => Children.FirstOrDefault(c => c.CanContain(hitObject));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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)
|
||||||
|
{
|
||||||
|
var timingChangeX = x as DrawableTimingChange;
|
||||||
|
var timingChangeY = y as DrawableTimingChange;
|
||||||
|
|
||||||
|
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||||
|
if (timingChangeX?.TimingChange == null || timingChangeY?.TimingChange == null)
|
||||||
|
return base.Compare(x, y);
|
||||||
|
|
||||||
|
// Compare by start time
|
||||||
|
int i = timingChangeY.TimingChange.Time.CompareTo(timingChangeX.TimingChange.Time);
|
||||||
|
if (i != 0)
|
||||||
|
return i;
|
||||||
|
|
||||||
|
return base.Compare(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user