mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Merge remote-tracking branch 'upstream/master' into ruleset-settings
This commit is contained in:
@ -1,55 +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.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares two hit objects by their start time, falling back to creation order if their start time is equal.
|
||||
/// </summary>
|
||||
public class HitObjectStartTimeComparer : Drawable.CreationOrderDepthComparer
|
||||
{
|
||||
public override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var hitObjectX = x as DrawableHitObject;
|
||||
var hitObjectY = y as DrawableHitObject;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = hitObjectX.HitObject.StartTime.CompareTo(hitObjectY.HitObject.StartTime);
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
return base.Compare(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two hit objects by their start time, falling back to creation order if their start time is equal.
|
||||
/// This will compare the two hit objects in reverse order.
|
||||
/// </summary>
|
||||
public class HitObjectReverseStartTimeComparer : Drawable.ReverseCreationOrderDepthComparer
|
||||
{
|
||||
public override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var hitObjectX = x as DrawableHitObject;
|
||||
var hitObjectY = y as DrawableHitObject;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (hitObjectX?.HitObject == null || hitObjectY?.HitObject == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = hitObjectY.HitObject.StartTime.CompareTo(hitObjectX.HitObject.StartTime);
|
||||
if (i != 0)
|
||||
return i;
|
||||
|
||||
return base.Compare(x, y);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using OpenTK;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
@ -55,7 +53,22 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// </summary>
|
||||
internal MultiplierControlPoint ControlPoint;
|
||||
|
||||
protected override IComparer<Drawable> DepthComparer => new HitObjectReverseStartTimeComparer();
|
||||
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="DrawableTimingSection"/>.
|
||||
|
@ -33,7 +33,20 @@ namespace osu.Game.Rulesets.Timing
|
||||
set { visibleTimeRange.BindTo(value); }
|
||||
}
|
||||
|
||||
protected override IComparer<Drawable> DepthComparer => new SpeedAdjustmentContainerReverseStartTimeComparer();
|
||||
protected override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var xSpeedAdjust = x as SpeedAdjustmentContainer;
|
||||
var ySpeedAdjust = y as SpeedAdjustmentContainer;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (xSpeedAdjust?.ControlPoint == null || ySpeedAdjust?.ControlPoint == null)
|
||||
return CompareReverseChildID(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = ySpeedAdjust.ControlPoint.StartTime.CompareTo(xSpeedAdjust.ControlPoint.StartTime);
|
||||
|
||||
return i != 0 ? i : CompareReverseChildID(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hit objects that are to be re-processed on the next update.
|
||||
@ -116,27 +129,5 @@ namespace osu.Game.Rulesets.Timing
|
||||
/// <param name="time">The time to find the active <see cref="SpeedAdjustmentContainer"/> at.</param>
|
||||
/// <returns>The <see cref="SpeedAdjustmentContainer"/> active at <paramref name="time"/>. Null if there are no speed adjustments.</returns>
|
||||
private SpeedAdjustmentContainer adjustmentContainerAt(double time) => Children.FirstOrDefault(c => c.CanContain(time)) ?? Children.LastOrDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Compares two speed adjustment containers by their control point start time, falling back to creation order
|
||||
// if their control point start time is equal. This will compare the two speed adjustment containers in reverse order.
|
||||
/// </summary>
|
||||
private class SpeedAdjustmentContainerReverseStartTimeComparer : ReverseCreationOrderDepthComparer
|
||||
{
|
||||
public override int Compare(Drawable x, Drawable y)
|
||||
{
|
||||
var speedAdjustmentX = x as SpeedAdjustmentContainer;
|
||||
var speedAdjustmentY = y as SpeedAdjustmentContainer;
|
||||
|
||||
// If either of the two drawables are not hit objects, fall back to the base comparer
|
||||
if (speedAdjustmentX?.ControlPoint == null || speedAdjustmentY?.ControlPoint == null)
|
||||
return base.Compare(x, y);
|
||||
|
||||
// Compare by start time
|
||||
int i = speedAdjustmentY.ControlPoint.StartTime.CompareTo(speedAdjustmentX.ControlPoint.StartTime);
|
||||
|
||||
return i != 0 ? i : base.Compare(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user