mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 20:27:52 +08:00
9c62c90cfc
Until now, the implementation of the overrides in `SelectionBlueprint` have been confusing to the point where I would just implement by trial-and-error (or copying from an existing implementation). This was due to a combination of using "object" space coordinates (ie. the thing the `Blueprint` is operating on) and screen-space coordinates. This change switches all event related coordinates to screen-space, which is how we already handle rotation/scale operations. With the introduction of other editor types where the related objects are drawables, this also makes a lot more sense.
39 lines
1.5 KiB
C#
39 lines
1.5 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 OverlaySelectionBlueprint : SelectionBlueprint<HitObject>
|
|
{
|
|
/// <summary>
|
|
/// The <see cref="DrawableHitObject"/> which this <see cref="OverlaySelectionBlueprint"/> applies to.
|
|
/// </summary>
|
|
public readonly DrawableHitObject DrawableObject;
|
|
|
|
/// <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 OverlaySelectionBlueprint(DrawableHitObject drawableObject)
|
|
: base(drawableObject.HitObject)
|
|
{
|
|
DrawableObject = drawableObject;
|
|
}
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
|
|
|
|
public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;
|
|
|
|
public override Quad SelectionQuad => DrawableObject.ScreenSpaceDrawQuad;
|
|
}
|
|
}
|