mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 17:52:56 +08:00
SelectionMask -> SelectionBlueprint
This commit is contained in:
parent
ad2836a61e
commit
f2a5f28ea2
@ -38,14 +38,14 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
|
||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => Array.Empty<HitObjectCompositionTool>();
|
||||
|
||||
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject)
|
||||
public override SelectionBlueprint CreateMaskFor(DrawableHitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case DrawableNote note:
|
||||
return new NoteSelectionMask(note);
|
||||
return new NoteSelectionBlueprint(note);
|
||||
case DrawableHoldNote holdNote:
|
||||
return new HoldNoteSelectionMask(holdNote);
|
||||
return new HoldNoteSelectionBlueprint(holdNote);
|
||||
}
|
||||
|
||||
return base.CreateMaskFor(hitObject);
|
||||
|
@ -15,7 +15,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Edit.Masks
|
||||
{
|
||||
public class HoldNoteSelectionMask : SelectionMask
|
||||
public class HoldNoteSelectionBlueprint : SelectionBlueprint
|
||||
{
|
||||
public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject;
|
||||
|
||||
@ -23,13 +23,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
|
||||
|
||||
private readonly BodyPiece body;
|
||||
|
||||
public HoldNoteSelectionMask(DrawableHoldNote hold)
|
||||
public HoldNoteSelectionBlueprint(DrawableHoldNote hold)
|
||||
: base(hold)
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new HoldNoteNoteSelectionMask(hold.Head),
|
||||
new HoldNoteNoteSelectionMask(hold.Tail),
|
||||
new HoldNoteNoteSelectionBlueprint(hold.Head),
|
||||
new HoldNoteNoteSelectionBlueprint(hold.Tail),
|
||||
body = new BodyPiece
|
||||
{
|
||||
AccentColour = Color4.Transparent
|
||||
@ -59,9 +59,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks
|
||||
Y -= HitObject.Tail.DrawHeight;
|
||||
}
|
||||
|
||||
private class HoldNoteNoteSelectionMask : NoteSelectionMask
|
||||
private class HoldNoteNoteSelectionBlueprint : NoteSelectionBlueprint
|
||||
{
|
||||
public HoldNoteNoteSelectionMask(DrawableNote note)
|
||||
public HoldNoteNoteSelectionBlueprint(DrawableNote note)
|
||||
: base(note)
|
||||
{
|
||||
Select();
|
@ -9,9 +9,9 @@ using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||
|
||||
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)
|
||||
{
|
||||
Scale = note.Scale;
|
@ -24,6 +24,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Add(drawableObject = new DrawableHitCircle(hitCircle));
|
||||
}
|
||||
|
||||
protected override SelectionMask CreateMask() => new HitCircleSelectionMask(drawableObject);
|
||||
protected override SelectionBlueprint CreateMask() => new HitCircleSelectionBlueprint(drawableObject);
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(SliderSelectionMask),
|
||||
typeof(SliderCircleSelectionMask),
|
||||
typeof(SliderSelectionBlueprint),
|
||||
typeof(SliderCircleSelectionBlueprint),
|
||||
typeof(SliderBodyPiece),
|
||||
typeof(SliderCircle),
|
||||
typeof(PathControlPointVisualiser),
|
||||
@ -50,6 +50,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Add(drawableObject = new DrawableSlider(slider));
|
||||
}
|
||||
|
||||
protected override SelectionMask CreateMask() => new SliderSelectionMask(drawableObject);
|
||||
protected override SelectionBlueprint CreateMask() => new SliderSelectionBlueprint(drawableObject);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(SpinnerSelectionMask),
|
||||
typeof(SpinnerSelectionBlueprint),
|
||||
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) };
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
|
||||
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)
|
||||
{
|
||||
InternalChild = new HitCirclePiece((HitCircle)hitCircle.HitObject);
|
@ -8,9 +8,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||
|
||||
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)
|
||||
{
|
||||
InternalChild = new SliderCirclePiece(slider, position);
|
@ -10,11 +10,11 @@ using OpenTK;
|
||||
|
||||
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)
|
||||
{
|
||||
var sliderObject = (Slider)slider.HitObject;
|
||||
@ -22,12 +22,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks.SliderMasks
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new SliderBodyPiece(sliderObject),
|
||||
headMask = new SliderCircleSelectionMask(slider.HeadCircle, sliderObject, SliderPosition.Start),
|
||||
new SliderCircleSelectionMask(slider.TailCircle, sliderObject, SliderPosition.End),
|
||||
headBlueprint = new SliderCircleSelectionBlueprint(slider.HeadCircle, sliderObject, SliderPosition.Start),
|
||||
new SliderCircleSelectionBlueprint(slider.TailCircle, sliderObject, SliderPosition.End),
|
||||
new PathControlPointVisualiser(sliderObject),
|
||||
};
|
||||
}
|
||||
|
||||
public override Vector2 SelectionPoint => headMask.SelectionPoint;
|
||||
public override Vector2 SelectionPoint => headBlueprint.SelectionPoint;
|
||||
}
|
||||
}
|
@ -9,11 +9,11 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit.Masks.SpinnerMasks
|
||||
{
|
||||
public class SpinnerSelectionMask : SelectionMask
|
||||
public class SpinnerSelectionBlueprint : SelectionBlueprint
|
||||
{
|
||||
private readonly SpinnerPiece piece;
|
||||
|
||||
public SpinnerSelectionMask(DrawableSpinner spinner)
|
||||
public SpinnerSelectionBlueprint(DrawableSpinner spinner)
|
||||
: base(spinner)
|
||||
{
|
||||
InternalChild = piece = new SpinnerPiece((Spinner)spinner.HitObject);
|
@ -37,16 +37,16 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
protected override Container CreateLayerContainer() => new PlayfieldAdjustmentContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public override SelectionMask CreateMaskFor(DrawableHitObject hitObject)
|
||||
public override SelectionBlueprint CreateMaskFor(DrawableHitObject hitObject)
|
||||
{
|
||||
switch (hitObject)
|
||||
{
|
||||
case DrawableHitCircle circle:
|
||||
return new HitCircleSelectionMask(circle);
|
||||
return new HitCircleSelectionBlueprint(circle);
|
||||
case DrawableSlider slider:
|
||||
return new SliderSelectionMask(slider);
|
||||
return new SliderSelectionBlueprint(slider);
|
||||
case DrawableSpinner spinner:
|
||||
return new SpinnerSelectionMask(spinner);
|
||||
return new SpinnerSelectionBlueprint(spinner);
|
||||
}
|
||||
|
||||
return base.CreateMaskFor(hitObject);
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual
|
||||
typeof(BlueprintContainer),
|
||||
typeof(NotNullAttribute),
|
||||
typeof(HitCirclePiece),
|
||||
typeof(HitCircleSelectionMask),
|
||||
typeof(HitCircleSelectionBlueprint),
|
||||
typeof(HitCirclePlacementMask),
|
||||
};
|
||||
|
||||
|
@ -148,27 +148,27 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
|
||||
public void Add(HitObject hitObject)
|
||||
{
|
||||
blueprintContainer.AddMaskFor(rulesetContainer.Add(hitObject));
|
||||
blueprintContainer.AddBlueprintFor(rulesetContainer.Add(hitObject));
|
||||
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();
|
||||
|
||||
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="SelectionMask"/> for a specific <see cref="DrawableHitObject"/>.
|
||||
/// Creates a <see cref="SelectionBlueprint"/> for a specific <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <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>
|
||||
/// Creates a <see cref="SelectionBox"/> which outlines <see cref="DrawableHitObject"/>s
|
||||
/// and handles hitobject pattern adjustments.
|
||||
/// </summary>
|
||||
public virtual SelectionBox CreateMaskSelection() => new SelectionBox();
|
||||
public virtual SelectionBox CreateSelectionBox() => new SelectionBox();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="ScalableContainer"/> which provides a layer above or below the <see cref="Playfield"/>.
|
||||
|
@ -17,31 +17,31 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// A mask placed above a <see cref="DrawableHitObject"/> adding editing functionality.
|
||||
/// </summary>
|
||||
public class SelectionMask : CompositeDrawable, IStateful<SelectionState>
|
||||
public class SelectionBlueprint : CompositeDrawable, IStateful<SelectionState>
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="SelectionMask"/> has been selected.
|
||||
/// Invoked when this <see cref="SelectionBlueprint"/> has been selected.
|
||||
/// </summary>
|
||||
public event Action<SelectionMask> Selected;
|
||||
public event Action<SelectionBlueprint> Selected;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="SelectionMask"/> has been deselected.
|
||||
/// Invoked when this <see cref="SelectionBlueprint"/> has been deselected.
|
||||
/// </summary>
|
||||
public event Action<SelectionMask> Deselected;
|
||||
public event Action<SelectionBlueprint> Deselected;
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public event Action<SelectionMask, InputState> SelectionRequested;
|
||||
public event Action<SelectionBlueprint, InputState> SelectionRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="SelectionMask"/> has requested drag.
|
||||
/// Invoked when this <see cref="SelectionBlueprint"/> has requested drag.
|
||||
/// </summary>
|
||||
public event Action<SelectionMask, Vector2, InputState> DragRequested;
|
||||
public event Action<SelectionBlueprint, Vector2, InputState> DragRequested;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableHitObject"/> which this <see cref="SelectionMask"/> applies to.
|
||||
/// The <see cref="DrawableHitObject"/> which this <see cref="SelectionBlueprint"/> applies to.
|
||||
/// </summary>
|
||||
public readonly DrawableHitObject HitObject;
|
||||
|
||||
@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
public override bool HandlePositionalInput => ShouldBeAlive;
|
||||
public override bool RemoveWhenNotAlive => false;
|
||||
|
||||
public SelectionMask(DrawableHitObject hitObject)
|
||||
public SelectionBlueprint(DrawableHitObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
|
||||
@ -86,12 +86,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects this <see cref="SelectionMask"/>, causing it to become visible.
|
||||
/// Selects this <see cref="SelectionBlueprint"/>, causing it to become visible.
|
||||
/// </summary>
|
||||
public void Select() => State = SelectionState.Selected;
|
||||
|
||||
/// <summary>
|
||||
/// Deselects this <see cref="SelectionMask"/>, causing it to become invisible.
|
||||
/// Deselects this <see cref="SelectionBlueprint"/>, causing it to become invisible.
|
||||
/// </summary>
|
||||
public void Deselect() => State = SelectionState.NotSelected;
|
||||
|
||||
@ -135,12 +135,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre;
|
||||
|
||||
/// <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>
|
||||
public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad;
|
||||
}
|
@ -20,7 +20,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
private SelectionBlueprintContainer selectionBlueprints;
|
||||
private SelectionBox selectionBox;
|
||||
|
||||
private IEnumerable<SelectionMask> aliveMasks => selectionBlueprints.Children.Where(c => c.IsAlive);
|
||||
private IEnumerable<SelectionBlueprint> selections => selectionBlueprints.Children.Where(c => c.IsAlive);
|
||||
|
||||
[Resolved]
|
||||
private HitObjectComposer composer { get; set; }
|
||||
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
selectionBox = composer.CreateMaskSelection();
|
||||
selectionBox = composer.CreateSelectionBox();
|
||||
selectionBox.DeselectAll = deselectAll;
|
||||
|
||||
var dragBox = new DragBox(select);
|
||||
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
};
|
||||
|
||||
foreach (var obj in composer.HitObjects)
|
||||
AddMaskFor(obj);
|
||||
AddBlueprintFor(obj);
|
||||
}
|
||||
|
||||
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.
|
||||
/// </summary>
|
||||
/// <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);
|
||||
if (mask == null)
|
||||
return;
|
||||
|
||||
mask.Selected += onMaskSelected;
|
||||
mask.Deselected += onMaskDeselected;
|
||||
mask.Selected += onBlueprintSelected;
|
||||
mask.Deselected += onBlueprintDeselected;
|
||||
mask.SelectionRequested += onSelectionRequested;
|
||||
mask.DragRequested += onDragRequested;
|
||||
|
||||
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
/// Removes a mask for a <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <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);
|
||||
if (maskToRemove == null)
|
||||
@ -87,8 +87,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
maskToRemove.Deselect();
|
||||
|
||||
maskToRemove.Selected -= onMaskSelected;
|
||||
maskToRemove.Deselected -= onMaskDeselected;
|
||||
maskToRemove.Selected -= onBlueprintSelected;
|
||||
maskToRemove.Deselected -= onBlueprintDeselected;
|
||||
maskToRemove.SelectionRequested -= onSelectionRequested;
|
||||
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>
|
||||
private void select(RectangleF rect)
|
||||
{
|
||||
foreach (var mask in aliveMasks.ToList())
|
||||
foreach (var mask in selections.ToList())
|
||||
{
|
||||
if (mask.IsPresent && rect.Contains(mask.SelectionPoint))
|
||||
mask.Select();
|
||||
@ -111,38 +111,38 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects all selected <see cref="SelectionMask"/>s.
|
||||
/// Deselects all selected <see cref="SelectionBlueprint"/>s.
|
||||
/// </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);
|
||||
selectionBlueprints.ChangeChildDepth(mask, 1);
|
||||
selectionBox.HandleSelected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||
}
|
||||
|
||||
private void onMaskDeselected(SelectionMask mask)
|
||||
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
||||
{
|
||||
selectionBox.HandleDeselected(mask);
|
||||
selectionBlueprints.ChangeChildDepth(mask, 0);
|
||||
selectionBox.HandleDeselected(blueprint);
|
||||
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)
|
||||
{
|
||||
if (!(x is SelectionMask xMask) || !(y is SelectionMask yMask))
|
||||
if (!(x is SelectionBlueprint xBlueprint) || !(y is SelectionBlueprint yBlueprint))
|
||||
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);
|
||||
if (d != 0)
|
||||
return d;
|
||||
|
@ -19,13 +19,13 @@ using OpenTK.Input;
|
||||
namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
{
|
||||
/// <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>
|
||||
public class SelectionBox : CompositeDrawable
|
||||
{
|
||||
public const float BORDER_RADIUS = 2;
|
||||
|
||||
private readonly List<SelectionMask> selectedMasks;
|
||||
private readonly List<SelectionBlueprint> selectedMasks;
|
||||
|
||||
private Drawable outline;
|
||||
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
public SelectionBox()
|
||||
{
|
||||
selectedMasks = new List<SelectionMask>();
|
||||
selectedMasks = new List<SelectionBlueprint>();
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AlwaysPresent = true;
|
||||
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
|
||||
#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
|
||||
|
||||
@ -103,16 +103,16 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
/// <summary>
|
||||
/// Handle a mask becoming selected.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleSelected(SelectionMask mask) => selectedMasks.Add(mask);
|
||||
/// <param name="blueprint">The mask.</param>
|
||||
public void HandleSelected(SelectionBlueprint blueprint) => selectedMasks.Add(blueprint);
|
||||
|
||||
/// <summary>
|
||||
/// Handle a mask becoming deselected.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleDeselected(SelectionMask mask)
|
||||
/// <param name="blueprint">The mask.</param>
|
||||
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
|
||||
if (selectedMasks.Count == 0)
|
||||
@ -122,23 +122,23 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Layers
|
||||
/// <summary>
|
||||
/// Handle a mask requesting selection.
|
||||
/// </summary>
|
||||
/// <param name="mask">The mask.</param>
|
||||
public void HandleSelectionRequested(SelectionMask mask, InputState state)
|
||||
/// <param name="blueprint">The mask.</param>
|
||||
public void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
|
||||
{
|
||||
if (state.Keyboard.ControlPressed)
|
||||
{
|
||||
if (mask.IsSelected)
|
||||
mask.Deselect();
|
||||
if (blueprint.IsSelected)
|
||||
blueprint.Deselect();
|
||||
else
|
||||
mask.Select();
|
||||
blueprint.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mask.IsSelected)
|
||||
if (blueprint.IsSelected)
|
||||
return;
|
||||
|
||||
DeselectAll?.Invoke();
|
||||
mask.Select();
|
||||
blueprint.Select();
|
||||
}
|
||||
|
||||
UpdateVisibility();
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public abstract class HitObjectSelectionMaskTestCase : OsuTestCase
|
||||
{
|
||||
private SelectionMask mask;
|
||||
private SelectionBlueprint blueprint;
|
||||
|
||||
protected override Container<Drawable> Content => content ?? base.Content;
|
||||
private readonly Container content;
|
||||
@ -29,19 +29,19 @@ namespace osu.Game.Tests.Visual
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.Content.Add(mask = CreateMask());
|
||||
mask.SelectionRequested += (_, __) => mask.Select();
|
||||
base.Content.Add(blueprint = CreateMask());
|
||||
blueprint.SelectionRequested += (_, __) => blueprint.Select();
|
||||
|
||||
AddStep("Select", () => mask.Select());
|
||||
AddStep("Deselect", () => mask.Deselect());
|
||||
AddStep("Select", () => blueprint.Select());
|
||||
AddStep("Deselect", () => blueprint.Deselect());
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
mask.Deselect();
|
||||
blueprint.Deselect();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract SelectionMask CreateMask();
|
||||
protected abstract SelectionBlueprint CreateMask();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user