Merge pull request #12782 from smoogipoo/rework-hitobject-blueprints

Rename hitobject blueprints and tie them to HitObjects
This commit is contained in:
Dean Herbert
2021-05-18 16:30:58 +09:00
committed by GitHub
26 changed files with 115 additions and 122 deletions

View File

@ -9,12 +9,12 @@ using osuTK;
namespace osu.Game.Rulesets.Edit
{
public abstract class OverlaySelectionBlueprint : SelectionBlueprint<HitObject>
public abstract class HitObjectSelectionBlueprint : SelectionBlueprint<HitObject>
{
/// <summary>
/// The <see cref="DrawableHitObject"/> which this <see cref="OverlaySelectionBlueprint"/> applies to.
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectSelectionBlueprint"/> applies to.
/// </summary>
public readonly DrawableHitObject DrawableObject;
public DrawableHitObject DrawableObject { get; internal set; }
/// <summary>
/// Whether the blueprint should be shown even when the <see cref="DrawableObject"/> is not alive.
@ -23,10 +23,9 @@ namespace osu.Game.Rulesets.Edit
protected override bool ShouldBeAlive => (DrawableObject.IsAlive && DrawableObject.IsPresent) || (AlwaysShowWhenSelected && State == SelectionState.Selected);
protected OverlaySelectionBlueprint(DrawableHitObject drawableObject)
: base(drawableObject.HitObject)
protected HitObjectSelectionBlueprint(HitObject hitObject)
: base(hitObject)
{
DrawableObject = drawableObject;
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
@ -35,4 +34,15 @@ namespace osu.Game.Rulesets.Edit
public override Quad SelectionQuad => DrawableObject.ScreenSpaceDrawQuad;
}
public abstract class HitObjectSelectionBlueprint<T> : HitObjectSelectionBlueprint
where T : HitObject
{
public T HitObject => (T)Item;
protected HitObjectSelectionBlueprint(T item)
: base(item)
{
}
}
}

View File

@ -105,34 +105,34 @@ namespace osu.Game.Rulesets.Edit
protected override bool ShouldBeConsideredForInput(Drawable child) => State == SelectionState.Selected;
/// <summary>
/// Selects this <see cref="OverlaySelectionBlueprint"/>, causing it to become visible.
/// Selects this <see cref="SelectionBlueprint{T}"/>, causing it to become visible.
/// </summary>
public void Select() => State = SelectionState.Selected;
/// <summary>
/// Deselects this <see cref="OverlaySelectionBlueprint"/>, causing it to become invisible.
/// Deselects this <see cref="HitObjectSelectionBlueprint"/>, causing it to become invisible.
/// </summary>
public void Deselect() => State = SelectionState.NotSelected;
/// <summary>
/// Toggles the selection state of this <see cref="OverlaySelectionBlueprint"/>.
/// Toggles the selection state of this <see cref="HitObjectSelectionBlueprint"/>.
/// </summary>
public void ToggleSelection() => State = IsSelected ? SelectionState.NotSelected : SelectionState.Selected;
public bool IsSelected => State == SelectionState.Selected;
/// <summary>
/// The <see cref="MenuItem"/>s to be displayed in the context menu for this <see cref="OverlaySelectionBlueprint"/>.
/// The <see cref="MenuItem"/>s to be displayed in the context menu for this <see cref="HitObjectSelectionBlueprint"/>.
/// </summary>
public virtual MenuItem[] ContextMenuItems => Array.Empty<MenuItem>();
/// <summary>
/// The screen-space point that causes this <see cref="OverlaySelectionBlueprint"/> to be selected via a drag.
/// The screen-space point that causes this <see cref="HitObjectSelectionBlueprint"/> to be selected via a drag.
/// </summary>
public virtual Vector2 ScreenSpaceSelectionPoint => ScreenSpaceDrawQuad.Centre;
/// <summary>
/// The screen-space quad that outlines this <see cref="OverlaySelectionBlueprint"/> for selections.
/// The screen-space quad that outlines this <see cref="HitObjectSelectionBlueprint"/> for selections.
/// </summary>
public virtual Quad SelectionQuad => ScreenSpaceDrawQuad;