mirror of
https://github.com/osukey/osukey.git
synced 2025-05-16 11:07:35 +09:00
67 lines
2.4 KiB
C#
67 lines
2.4 KiB
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Rulesets.Objects;
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Rulesets.Edit
|
|
{
|
|
public abstract class HitObjectSelectionBlueprint : SelectionBlueprint<HitObject>
|
|
{
|
|
/// <summary>
|
|
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectSelectionBlueprint"/> applies to.
|
|
/// </summary>
|
|
public virtual DrawableHitObject DrawableObject { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Whether the blueprint should be shown even when the <see cref="DrawableObject"/> is not alive.
|
|
/// </summary>
|
|
protected virtual bool AlwaysShowWhenSelected => false;
|
|
|
|
protected override bool ShouldBeAlive => (DrawableObject.IsAlive && DrawableObject.IsPresent) || (AlwaysShowWhenSelected && State == SelectionState.Selected);
|
|
|
|
protected HitObjectSelectionBlueprint(HitObject hitObject)
|
|
: base(hitObject)
|
|
{
|
|
}
|
|
|
|
protected override void LoadAsyncComplete()
|
|
{
|
|
// Must be done before base.LoadAsyncComplete() as this may affect children.
|
|
Apply(DrawableObject);
|
|
|
|
base.LoadAsyncComplete();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Applies a <see cref="DrawableHitObject"/> to this <see cref="HitObjectSelectionBlueprint"/>.
|
|
/// The represented <see cref="HitObject"/> model does not change.
|
|
/// </summary>
|
|
/// <param name="drawableObject">The new <see cref="DrawableHitObject"/>.</param>
|
|
public virtual void Apply(DrawableHitObject drawableObject)
|
|
{
|
|
DrawableObject = drawableObject;
|
|
}
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
|
|
|
|
public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;
|
|
|
|
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)
|
|
{
|
|
}
|
|
}
|
|
}
|