1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:42:56 +08:00

SelectionMask -> SelectionBlueprint

This commit is contained in:
smoogipoo 2018-11-06 17:56:04 +09:00
parent ad2836a61e
commit f2a5f28ea2
17 changed files with 102 additions and 102 deletions

View File

@ -38,14 +38,14 @@ namespace osu.Game.Rulesets.Mania.Edit
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => Array.Empty<HitObjectCompositionTool>(); protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => Array.Empty<HitObjectCompositionTool>();
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject) public override SelectionBlueprint CreateMaskFor(DrawableHitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {
case DrawableNote note: case DrawableNote note:
return new NoteSelectionMask(note); return new NoteSelectionBlueprint(note);
case DrawableHoldNote holdNote: case DrawableHoldNote holdNote:
return new HoldNoteSelectionMask(holdNote); return new HoldNoteSelectionBlueprint(holdNote);
} }
return base.CreateMaskFor(hitObject); return base.CreateMaskFor(hitObject);

View File

@ -15,7 +15,7 @@ using OpenTK.Graphics;
namespace osu.Game.Rulesets.Mania.Edit.Masks namespace osu.Game.Rulesets.Mania.Edit.Masks
{ {
public class HoldNoteSelectionMask : SelectionMask public class HoldNoteSelectionBlueprint : SelectionBlueprint
{ {
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject; public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
@ -23,13 +23,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
private readonly BodyPiece body; private readonly BodyPiece body;
public HoldNoteSelectionMask(DrawableHoldNote hold) public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
: base(hold) : base(hold)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new HoldNoteNoteSelectionMask(hold.Head), new HoldNoteNoteSelectionBlueprint(hold.Head),
new HoldNoteNoteSelectionMask(hold.Tail), new HoldNoteNoteSelectionBlueprint(hold.Tail),
body = new BodyPiece body = new BodyPiece
{ {
AccentColour = Color4.Transparent AccentColour = Color4.Transparent
@ -59,9 +59,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
Y -= HitObject.Tail.DrawHeight; Y -= HitObject.Tail.DrawHeight;
} }
private class HoldNoteNoteSelectionMask : NoteSelectionMask private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
{ {
public HoldNoteNoteSelectionMask(DrawableNote note) public HoldNoteNoteSelectionBlueprint(DrawableNote note)
: base(note) : base(note)
{ {
Select(); Select();

View File

@ -9,9 +9,9 @@ using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
namespace osu.Game.Rulesets.Mania.Edit.Masks namespace osu.Game.Rulesets.Mania.Edit.Masks
{ {
public class NoteSelectionMask : SelectionMask public class NoteSelectionBlueprint : SelectionBlueprint
{ {
public NoteSelectionMask(DrawableNote note) public NoteSelectionBlueprint(DrawableNote note)
: base(note) : base(note)
{ {
Scale = note.Scale; Scale = note.Scale;

View File

@ -24,6 +24,6 @@ namespace osu.Game.Rulesets.Osu.Tests
Add(drawableObject = new DrawableHitCircle(hitCircle)); Add(drawableObject = new DrawableHitCircle(hitCircle));
} }
protected override SelectionMask CreateMask() => new HitCircleSelectionMask(drawableObject); protected override SelectionBlueprint CreateMask() => new HitCircleSelectionBlueprint(drawableObject);
} }
} }

View File

@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(SliderSelectionMask), typeof(SliderSelectionBlueprint),
typeof(SliderCircleSelectionMask), typeof(SliderCircleSelectionBlueprint),
typeof(SliderBodyPiece), typeof(SliderBodyPiece),
typeof(SliderCircle), typeof(SliderCircle),
typeof(PathControlPointVisualiser), typeof(PathControlPointVisualiser),
@ -50,6 +50,6 @@ namespace osu.Game.Rulesets.Osu.Tests
Add(drawableObject = new DrawableSlider(slider)); Add(drawableObject = new DrawableSlider(slider));
} }
protected override SelectionMask CreateMask() => new SliderSelectionMask(drawableObject); protected override SelectionBlueprint CreateMask() => new SliderSelectionBlueprint(drawableObject);
} }
} }

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
public override IReadOnlyList<Type> RequiredTypes => new[] public override IReadOnlyList<Type> RequiredTypes => new[]
{ {
typeof(SpinnerSelectionMask), typeof(SpinnerSelectionBlueprint),
typeof(SpinnerPiece) typeof(SpinnerPiece)
}; };
@ -45,6 +45,6 @@ namespace osu.Game.Rulesets.Osu.Tests
}); });
} }
protected override SelectionMask CreateMask() => new SpinnerSelectionMask(drawableSpinner) { Size = new Vector2(0.5f) }; protected override SelectionBlueprint CreateMask() => new SpinnerSelectionBlueprint(drawableSpinner) { Size = new Vector2(0.5f) };
} }
} }

View File

@ -8,9 +8,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks namespace osu.Game.Rulesets.Osu.Edit.Masks.HitCircleMasks
{ {
public class HitCircleSelectionMask : SelectionMask public class HitCircleSelectionBlueprint : SelectionBlueprint
{ {
public HitCircleSelectionMask(DrawableHitCircle hitCircle) public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle)
: base(hitCircle) : base(hitCircle)
{ {
InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject); InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject);

View File

@ -8,9 +8,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{ {
public class SliderCircleSelectionMask : SelectionMask public class SliderCircleSelectionBlueprint : SelectionBlueprint
{ {
public SliderCircleSelectionMask(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position) public SliderCircleSelectionBlueprint(DrawableOsuHitObject hitObject, Slider slider, SliderPosition position)
: base(hitObject) : base(hitObject)
{ {
InternalChild = new SliderCirclePiece(slider, position); InternalChild = new SliderCirclePiece(slider, position);

View File

@ -10,11 +10,11 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
{ {
public class SliderSelectionMask : SelectionMask public class SliderSelectionBlueprint : SelectionBlueprint
{ {
private readonly SliderCircleSelectionMask headMask; private readonly SliderCircleSelectionBlueprint headBlueprint;
public SliderSelectionMask(DrawableSlider slider) public SliderSelectionBlueprint(DrawableSlider slider)
: base(slider) : base(slider)
{ {
var sliderObject = (Slider)slider.HitObject; var sliderObject = (Slider)slider.HitObject;
@ -22,12 +22,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new SliderBodyPiece(sliderObject), new SliderBodyPiece(sliderObject),
headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start), headBlueprint = new SliderCircleSelectionBlueprint(slider.HeadCircle, sliderObject, SliderPosition.Start),
new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End), new SliderCircleSelectionBlueprint(slider.TailCircle, sliderObject, SliderPosition.End),
new PathControlPointVisualiser(sliderObject), new PathControlPointVisualiser(sliderObject),
}; };
} }
public override Vector2 SelectionPoint => headMask.SelectionPoint; public override Vector2 SelectionPoint => headBlueprint.SelectionPoint;
} }
} }

View File

@ -9,11 +9,11 @@ using OpenTK;
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks
{ {
public class SpinnerSelectionMask : SelectionMask public class SpinnerSelectionBlueprint : SelectionBlueprint
{ {
private readonly SpinnerPiece piece; private readonly SpinnerPiece piece;
public SpinnerSelectionMask(DrawableSpinner spinner) public SpinnerSelectionBlueprint(DrawableSpinner spinner)
: base(spinner) : base(spinner)
{ {
InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject); InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject);

View File

@ -37,16 +37,16 @@ namespace osu.Game.Rulesets.Osu.Edit
protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both }; protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both };
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject) public override SelectionBlueprint CreateMaskFor(DrawableHitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {
case DrawableHitCircle circle: case DrawableHitCircle circle:
return new HitCircleSelectionMask(circle); return new HitCircleSelectionBlueprint(circle);
case DrawableSlider slider: case DrawableSlider slider:
return new SliderSelectionMask(slider); return new SliderSelectionBlueprint(slider);
case DrawableSpinner spinner: case DrawableSpinner spinner:
return new SpinnerSelectionMask(spinner); return new SpinnerSelectionBlueprint(spinner);
} }
return base.CreateMaskFor(hitObject); return base.CreateMaskFor(hitObject);

View File

@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual
typeof(BlueprintContainer), typeof(BlueprintContainer),
typeof(NotNullAttribute), typeof(NotNullAttribute),
typeof(HitCirclePiece), typeof(HitCirclePiece),
typeof(HitCircleSelectionMask), typeof(HitCircleSelectionBlueprint),
typeof(HitCirclePlacementMask), typeof(HitCirclePlacementMask),
}; };

View File

@ -148,27 +148,27 @@ namespace osu.Game.Rulesets.Edit
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param> /// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
public void Add(HitObject hitObject) public void Add(HitObject hitObject)
{ {
blueprintContainer.AddMaskFor(rulesetContainer.Add(hitObject)); blueprintContainer.AddBlueprintFor(rulesetContainer.Add(hitObject));
placementContainer.Refresh(); placementContainer.Refresh();
} }
public void Remove(HitObject hitObject) => blueprintContainer.RemoveMaskFor(rulesetContainer.Remove(hitObject)); public void Remove(HitObject hitObject) => blueprintContainer.RemoveBlueprintFor(rulesetContainer.Remove(hitObject));
internal abstract EditRulesetContainer CreateRulesetContainer(); internal abstract EditRulesetContainer CreateRulesetContainer();
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; } protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
/// <summary> /// <summary>
/// Creates a <see cref="SelectionMask"/> for a specific <see cref="DrawableHitObject"/>. /// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param> /// <param name="hitObject">The <see cref="DrawableHitObject"/> to create the overlay for.</param>
public virtual SelectionMask CreateMaskFor(DrawableHitObject hitObject) => null; public virtual SelectionBlueprint CreateMaskFor(DrawableHitObject hitObject) => null;
/// <summary> /// <summary>
/// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s /// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s
/// and handles hitobject pattern adjustments. /// and handles hitobject pattern adjustments.
/// </summary> /// </summary>
public virtual SelectionBox CreateMaskSelection() => new SelectionBox(); public virtual SelectionBox CreateSelectionBox() => new SelectionBox();
/// <summary> /// <summary>
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>. /// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.

View File

@ -17,31 +17,31 @@ namespace osu.Game.Rulesets.Edit
/// <summary> /// <summary>
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality. /// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality.
/// </summary> /// </summary>
public class SelectionMask : CompositeDrawable, IStateful<SelectionState> public class SelectionBlueprint : CompositeDrawable, IStateful<SelectionState>
{ {
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has been selected. /// Invoked when this <see cref="SelectionBlueprint"/> has been selected.
/// </summary> /// </summary>
public event Action<SelectionMask> Selected; public event Action<SelectionBlueprint> Selected;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has been deselected. /// Invoked when this <see cref="SelectionBlueprint"/> has been deselected.
/// </summary> /// </summary>
public event Action<SelectionMask> Deselected; public event Action<SelectionBlueprint> Deselected;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has requested selection. /// Invoked when this <see cref="SelectionBlueprint"/> has requested selection.
/// Will fire even if already selected. Does not actually perform selection. /// Will fire even if already selected. Does not actually perform selection.
/// </summary> /// </summary>
public event Action<SelectionMask, InputState> SelectionRequested; public event Action<SelectionBlueprint, InputState> SelectionRequested;
/// <summary> /// <summary>
/// Invoked when this <see cref="SelectionMask"/> has requested drag. /// Invoked when this <see cref="SelectionBlueprint"/> has requested drag.
/// </summary> /// </summary>
public event Action<SelectionMask, Vector2, InputState> DragRequested; public event Action<SelectionBlueprint, Vector2, InputState> DragRequested;
/// <summary> /// <summary>
/// The <see cref="DrawableHitObject"/> which this <see cref="SelectionMask"/> applies to. /// The <see cref="DrawableHitObject"/> which this <see cref="SelectionBlueprint"/> applies to.
/// </summary> /// </summary>
public readonly DrawableHitObject HitObject; public readonly DrawableHitObject HitObject;
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Edit
public override bool HandlePositionalInput => ShouldBeAlive; public override bool HandlePositionalInput => ShouldBeAlive;
public override bool RemoveWhenNotAlive => false; public override bool RemoveWhenNotAlive => false;
public SelectionMask(DrawableHitObject hitObject) public SelectionBlueprint(DrawableHitObject hitObject)
{ {
HitObject = hitObject; HitObject = hitObject;
@ -86,12 +86,12 @@ namespace osu.Game.Rulesets.Edit
} }
/// <summary> /// <summary>
/// Selects this <see cref="SelectionMask"/>, causing it to become visible. /// Selects this <see cref="SelectionBlueprint"/>, causing it to become visible.
/// </summary> /// </summary>
public void Select() => State = SelectionState.Selected; public void Select() => State = SelectionState.Selected;
/// <summary> /// <summary>
/// Deselects this <see cref="SelectionMask"/>, causing it to become invisible. /// Deselects this <see cref="SelectionBlueprint"/>, causing it to become invisible.
/// </summary> /// </summary>
public void Deselect() => State = SelectionState.NotSelected; public void Deselect() => State = SelectionState.NotSelected;
@ -135,12 +135,12 @@ namespace osu.Game.Rulesets.Edit
} }
/// <summary> /// <summary>
/// The screen-space point that causes this <see cref="SelectionMask"/> to be selected. /// The screen-space point that causes this <see cref="SelectionBlueprint"/> to be selected.
/// </summary> /// </summary>
public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre; public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre;
/// <summary> /// <summary>
/// The screen-space quad that outlines this <see cref="SelectionMask"/> for selections. /// The screen-space quad that outlines this <see cref="SelectionBlueprint"/> for selections.
/// </summary> /// </summary>
public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad; public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad;
} }

View File

@ -20,7 +20,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
private SelectionBlueprintContainer selectionBlueprints; private SelectionBlueprintContainer selectionBlueprints;
private SelectionBox selectionBox; private SelectionBox selectionBox;
private IEnumerable<SelectionMask> aliveMasks => selectionBlueprints.Children.Where(c => c.IsAlive); private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
[Resolved] [Resolved]
private HitObjectComposer composer { get; set; } private HitObjectComposer composer { get; set; }
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
selectionBox = composer.CreateMaskSelection(); selectionBox = composer.CreateSelectionBox();
selectionBox.DeselectAll = deselectAll; selectionBox.DeselectAll = deselectAll;
var dragBox = new DragBox(select); var dragBox = new DragBox(select);
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
}; };
foreach (var obj in composer.HitObjects) foreach (var obj in composer.HitObjects)
AddMaskFor(obj); AddBlueprintFor(obj);
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
@ -61,14 +61,14 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// Adds a mask for a <see cref="DrawableHitObject"/> which adds movement support. /// Adds a mask for a <see cref="DrawableHitObject"/> which adds movement support.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> to create a mask for.</param> /// <param name="hitObject">The <see cref="DrawableHitObject"/> to create a mask for.</param>
public void AddMaskFor(DrawableHitObject hitObject) public void AddBlueprintFor(DrawableHitObject hitObject)
{ {
var mask = composer.CreateMaskFor(hitObject); var mask = composer.CreateMaskFor(hitObject);
if (mask == null) if (mask == null)
return; return;
mask.Selected += onMaskSelected; mask.Selected += onBlueprintSelected;
mask.Deselected += onMaskDeselected; mask.Deselected += onBlueprintDeselected;
mask.SelectionRequested += onSelectionRequested; mask.SelectionRequested += onSelectionRequested;
mask.DragRequested += onDragRequested; mask.DragRequested += onDragRequested;
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// Removes a mask for a <see cref="DrawableHitObject"/>. /// Removes a mask for a <see cref="DrawableHitObject"/>.
/// </summary> /// </summary>
/// <param name="hitObject">The <see cref="DrawableHitObject"/> for which to remove the mask.</param> /// <param name="hitObject">The <see cref="DrawableHitObject"/> for which to remove the mask.</param>
public void RemoveMaskFor(DrawableHitObject hitObject) public void RemoveBlueprintFor(DrawableHitObject hitObject)
{ {
var maskToRemove = selectionBlueprints.Single(m => m.HitObject == hitObject); var maskToRemove = selectionBlueprints.Single(m => m.HitObject == hitObject);
if (maskToRemove == null) if (maskToRemove == null)
@ -87,8 +87,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
maskToRemove.Deselect(); maskToRemove.Deselect();
maskToRemove.Selected -= onMaskSelected; maskToRemove.Selected -= onBlueprintSelected;
maskToRemove.Deselected -= onMaskDeselected; maskToRemove.Deselected -= onBlueprintDeselected;
maskToRemove.SelectionRequested -= onSelectionRequested; maskToRemove.SelectionRequested -= onSelectionRequested;
maskToRemove.DragRequested -= onDragRequested; maskToRemove.DragRequested -= onDragRequested;
@ -101,7 +101,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param> /// <param name="rect">The rectangle to perform a selection on in screen-space coordinates.</param>
private void select(RectangleF rect) private void select(RectangleF rect)
{ {
foreach (var mask in aliveMasks.ToList()) foreach (var mask in selections.ToList())
{ {
if (mask.IsPresent && rect.Contains(mask.SelectionPoint)) if (mask.IsPresent && rect.Contains(mask.SelectionPoint))
mask.Select(); mask.Select();
@ -111,38 +111,38 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
} }
/// <summary> /// <summary>
/// Deselects all selected <see cref="SelectionMask"/>s. /// Deselects all selected <see cref="SelectionBlueprint"/>s.
/// </summary> /// </summary>
private void deselectAll() => aliveMasks.ToList().ForEach(m => m.Deselect()); private void deselectAll() => selections.ToList().ForEach(m => m.Deselect());
private void onMaskSelected(SelectionMask mask) private void onBlueprintSelected(SelectionBlueprint blueprint)
{ {
selectionBox.HandleSelected(mask); selectionBox.HandleSelected(blueprint);
selectionBlueprints.ChangeChildDepth(mask, 1); selectionBlueprints.ChangeChildDepth(blueprint, 1);
} }
private void onMaskDeselected(SelectionMask mask) private void onBlueprintDeselected(SelectionBlueprint blueprint)
{ {
selectionBox.HandleDeselected(mask); selectionBox.HandleDeselected(blueprint);
selectionBlueprints.ChangeChildDepth(mask, 0); selectionBlueprints.ChangeChildDepth(blueprint, 0);
} }
private void onSelectionRequested(SelectionMask mask, InputState state) => selectionBox.HandleSelectionRequested(mask, state); private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionBox.HandleSelectionRequested(blueprint, state);
private void onDragRequested(SelectionMask mask, Vector2 delta, InputState state) => selectionBox.HandleDrag(mask, delta, state); private void onDragRequested(SelectionBlueprint blueprint, Vector2 delta, InputState state) => selectionBox.HandleDrag(blueprint, delta, state);
private class SelectionBlueprintContainer : Container<SelectionMask> private class SelectionBlueprintContainer : Container<SelectionBlueprint>
{ {
protected override int Compare(Drawable x, Drawable y) protected override int Compare(Drawable x, Drawable y)
{ {
if (!(x is SelectionMask xMask) || !(y is SelectionMask yMask)) if (!(x is SelectionBlueprint xBlueprint) || !(y is SelectionBlueprint yBlueprint))
return base.Compare(x, y); return base.Compare(x, y);
return Compare(xMask, yMask); return Compare(xBlueprint, yBlueprint);
} }
public int Compare(SelectionMask x, SelectionMask y) public int Compare(SelectionBlueprint x, SelectionBlueprint y)
{ {
// dpeth is used to denote selected status (we always want selected masks to handle input first). // dpeth is used to denote selected status (we always want selected blueprints to handle input first).
int d = x.Depth.CompareTo(y.Depth); int d = x.Depth.CompareTo(y.Depth);
if (d != 0) if (d != 0)
return d; return d;

View File

@ -19,13 +19,13 @@ using OpenTK.Input;
namespace osu.Game.Screens.Edit.Screens.Compose.Layers namespace osu.Game.Screens.Edit.Screens.Compose.Layers
{ {
/// <summary> /// <summary>
/// A box which surrounds <see cref="SelectionMask"/>s and provides interactive handles, context menus etc. /// A box which surrounds <see cref="SelectionBlueprint"/>s and provides interactive handles, context menus etc.
/// </summary> /// </summary>
public class SelectionBox : CompositeDrawable public class SelectionBox : CompositeDrawable
{ {
public const float BORDER_RADIUS = 2; public const float BORDER_RADIUS = 2;
private readonly List<SelectionMask> selectedMasks; private readonly List<SelectionBlueprint> selectedMasks;
private Drawable outline; private Drawable outline;
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
public SelectionBox() public SelectionBox()
{ {
selectedMasks = new List<SelectionMask>(); selectedMasks = new List<SelectionBlueprint>();
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AlwaysPresent = true; AlwaysPresent = true;
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
#region User Input Handling #region User Input Handling
public void HandleDrag(SelectionMask m, Vector2 delta, InputState state) public void HandleDrag(SelectionBlueprint m, Vector2 delta, InputState state)
{ {
// Todo: Various forms of snapping // Todo: Various forms of snapping
@ -103,16 +103,16 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// <summary> /// <summary>
/// Handle a mask becoming selected. /// Handle a mask becoming selected.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The mask.</param>
public void HandleSelected(SelectionMask mask) => selectedMasks.Add(mask); public void HandleSelected(SelectionBlueprint blueprint) => selectedMasks.Add(blueprint);
/// <summary> /// <summary>
/// Handle a mask becoming deselected. /// Handle a mask becoming deselected.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The mask.</param>
public void HandleDeselected(SelectionMask mask) public void HandleDeselected(SelectionBlueprint blueprint)
{ {
selectedMasks.Remove(mask); selectedMasks.Remove(blueprint);
// We don't want to update visibility if > 0, since we may be deselecting masks during drag-selection // We don't want to update visibility if > 0, since we may be deselecting masks during drag-selection
if (selectedMasks.Count == 0) if (selectedMasks.Count == 0)
@ -122,23 +122,23 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
/// <summary> /// <summary>
/// Handle a mask requesting selection. /// Handle a mask requesting selection.
/// </summary> /// </summary>
/// <param name="mask">The mask.</param> /// <param name="blueprint">The mask.</param>
public void HandleSelectionRequested(SelectionMask mask, InputState state) public void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{ {
if (state.Keyboard.ControlPressed) if (state.Keyboard.ControlPressed)
{ {
if (mask.IsSelected) if (blueprint.IsSelected)
mask.Deselect(); blueprint.Deselect();
else else
mask.Select(); blueprint.Select();
} }
else else
{ {
if (mask.IsSelected) if (blueprint.IsSelected)
return; return;
DeselectAll?.Invoke(); DeselectAll?.Invoke();
mask.Select(); blueprint.Select();
} }
UpdateVisibility(); UpdateVisibility();

View File

@ -12,7 +12,7 @@ namespace osu.Game.Tests.Visual
{ {
public abstract class HitObjectSelectionMaskTestCase : OsuTestCase public abstract class HitObjectSelectionMaskTestCase : OsuTestCase
{ {
private SelectionMask mask; private SelectionBlueprint blueprint;
protected override Container<Drawable> Content => content ?? base.Content; protected override Container<Drawable> Content => content ?? base.Content;
private readonly Container content; private readonly Container content;
@ -29,19 +29,19 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
base.Content.Add(mask = CreateMask()); base.Content.Add(blueprint = CreateMask());
mask.SelectionRequested += (_, __) => mask.Select(); blueprint.SelectionRequested += (_, __) => blueprint.Select();
AddStep("Select", () => mask.Select()); AddStep("Select", () => blueprint.Select());
AddStep("Deselect", () => mask.Deselect()); AddStep("Deselect", () => blueprint.Deselect());
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
mask.Deselect(); blueprint.Deselect();
return true; return true;
} }
protected abstract SelectionMask CreateMask(); protected abstract SelectionBlueprint CreateMask();
} }
} }