1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00

Make sealed and cleanup comparator

This commit is contained in:
smoogipoo 2020-11-18 13:33:22 +09:00
parent 58c8184ad7
commit 783c172b5d
3 changed files with 9 additions and 13 deletions

View File

@ -118,8 +118,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
}
protected virtual SelectionBlueprintContainer CreateSelectionBlueprintContainer() =>
new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
protected virtual Container<SelectionBlueprint> CreateSelectionBlueprintContainer() => new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both };
/// <summary>
/// Creates a <see cref="Components.SelectionHandler"/> which outlines <see cref="DrawableHitObject"/>s and handles movement of selections.

View File

@ -9,14 +9,12 @@ using osu.Game.Rulesets.Edit;
namespace osu.Game.Screens.Edit.Compose.Components
{
public class SelectionBlueprintContainer : Container<SelectionBlueprint>
public sealed class HitObjectOrderedSelectionContainer : Container<SelectionBlueprint>
{
public override void Add(SelectionBlueprint drawable)
{
base.Add(drawable);
if (Content == this)
bindStartTime(drawable);
bindStartTime(drawable);
}
public override bool Remove(SelectionBlueprint drawable)
@ -24,8 +22,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (!base.Remove(drawable))
return false;
if (Content == this)
unbindStartTime(drawable);
unbindStartTime(drawable);
return true;
}
@ -65,8 +62,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override int Compare(Drawable x, Drawable y)
{
if (!(x is SelectionBlueprint xObj) || !(y is SelectionBlueprint yObj))
return base.Compare(x, y);
var xObj = (SelectionBlueprint)x;
var yObj = (SelectionBlueprint)y;
// Put earlier blueprints towards the end of the list, so they handle input first
int i = yObj.HitObject.StartTime.CompareTo(xObj.HitObject.StartTime);

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
}
}
protected override SelectionBlueprintContainer CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
protected override Container<SelectionBlueprint> CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
protected override void OnDrag(DragEvent e)
{
@ -195,13 +195,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
}
}
protected class TimelineSelectionBlueprintContainer : SelectionBlueprintContainer
protected class TimelineSelectionBlueprintContainer : Container<SelectionBlueprint>
{
protected override Container<SelectionBlueprint> Content { get; }
public TimelineSelectionBlueprintContainer()
{
AddInternal(new TimelinePart<SelectionBlueprint>(Content = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both }) { RelativeSizeAxes = Axes.Both });
AddInternal(new TimelinePart<SelectionBlueprint>(Content = new HitObjectOrderedSelectionContainer { RelativeSizeAxes = Axes.Both }) { RelativeSizeAxes = Axes.Both });
}
}
}