2021-04-28 14:14:48 +08:00
|
|
|
// 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.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Rulesets.Edit;
|
|
|
|
using osu.Game.Screens.Play.HUD;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning.Editor
|
|
|
|
{
|
2021-04-28 17:34:34 +08:00
|
|
|
public class SkinBlueprint : SelectionBlueprint<ISkinnableComponent>
|
2021-04-28 14:14:48 +08:00
|
|
|
{
|
|
|
|
private Container box;
|
2021-04-28 17:34:34 +08:00
|
|
|
|
2021-05-03 14:18:18 +08:00
|
|
|
private Drawable drawable => (Drawable)Item;
|
2021-04-28 14:14:48 +08:00
|
|
|
|
|
|
|
/// <summary>
|
2021-05-03 14:18:18 +08:00
|
|
|
/// Whether the blueprint should be shown even when the <see cref="SelectionBlueprint{T}.Item"/> is not alive.
|
2021-04-28 14:14:48 +08:00
|
|
|
/// </summary>
|
|
|
|
protected virtual bool AlwaysShowWhenSelected => false;
|
|
|
|
|
2021-05-03 14:18:18 +08:00
|
|
|
protected override bool ShouldBeAlive => (drawable.IsAlive && Item.IsPresent) || (AlwaysShowWhenSelected && State == SelectionState.Selected);
|
2021-04-28 14:14:48 +08:00
|
|
|
|
2021-04-28 17:34:34 +08:00
|
|
|
public SkinBlueprint(ISkinnableComponent component)
|
2021-04-28 14:14:48 +08:00
|
|
|
: base(component)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
{
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
box = new Container
|
|
|
|
{
|
|
|
|
Colour = colours.Yellow,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Alpha = 0.2f,
|
|
|
|
AlwaysPresent = true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private Quad drawableQuad;
|
|
|
|
|
|
|
|
public override Quad ScreenSpaceDrawQuad => drawableQuad;
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
drawableQuad = drawable.ScreenSpaceDrawQuad;
|
|
|
|
var quad = ToLocalSpace(drawable.ScreenSpaceDrawQuad);
|
|
|
|
|
|
|
|
box.Position = quad.TopLeft;
|
|
|
|
box.Size = quad.Size;
|
2021-04-28 17:34:34 +08:00
|
|
|
box.Rotation = drawable.Rotation;
|
2021-04-28 14:14:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => drawable.ReceivePositionalInputAt(screenSpacePos);
|
|
|
|
|
2021-04-29 14:29:25 +08:00
|
|
|
public override Vector2 ScreenSpaceSelectionPoint => drawable.ScreenSpaceDrawQuad.Centre;
|
2021-04-28 14:14:48 +08:00
|
|
|
|
|
|
|
public override Quad SelectionQuad => drawable.ScreenSpaceDrawQuad;
|
|
|
|
}
|
|
|
|
}
|