mirror of
https://github.com/ppy/osu
synced 2024-12-28 18:02:53 +00:00
Merge branch 'master' into skin-blueprint-aspect-lock
This commit is contained in:
commit
6a64a705b8
@ -22,6 +22,8 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
private Container outlineBox;
|
||||
|
||||
private AnchorOriginVisualiser anchorOriginVisualiser;
|
||||
|
||||
private Drawable drawable => (Drawable)Item;
|
||||
|
||||
protected override bool ShouldBeAlive => drawable.IsAlive && Item.IsPresent;
|
||||
@ -65,9 +67,13 @@ namespace osu.Game.Skinning.Editor
|
||||
Font = OsuFont.Default.With(size: 10, weight: FontWeight.Bold),
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.TopRight,
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
anchorOriginVisualiser = new AnchorOriginVisualiser(drawable)
|
||||
{
|
||||
Alpha = 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -76,7 +82,7 @@ namespace osu.Game.Skinning.Editor
|
||||
base.LoadComplete();
|
||||
|
||||
updateSelectedState();
|
||||
box.FadeInFromZero(200, Easing.OutQuint);
|
||||
this.FadeInFromZero(200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void OnSelected()
|
||||
@ -95,6 +101,8 @@ namespace osu.Game.Skinning.Editor
|
||||
{
|
||||
outlineBox.FadeColour(colours.Pink.Opacity(IsSelected ? 1 : 0.5f), 200, Easing.OutQuint);
|
||||
outlineBox.Child.FadeTo(IsSelected ? 0.2f : 0, 200, Easing.OutQuint);
|
||||
|
||||
anchorOriginVisualiser.FadeTo(IsSelected ? 1 : 0, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private Quad drawableQuad;
|
||||
@ -120,4 +128,58 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
public override Quad SelectionQuad => drawable.ScreenSpaceDrawQuad;
|
||||
}
|
||||
|
||||
internal class AnchorOriginVisualiser : CompositeDrawable
|
||||
{
|
||||
private readonly Drawable drawable;
|
||||
|
||||
private readonly Box originBox;
|
||||
|
||||
private readonly Box anchorBox;
|
||||
private readonly Box anchorLine;
|
||||
|
||||
public AnchorOriginVisualiser(Drawable drawable)
|
||||
{
|
||||
this.drawable = drawable;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
anchorLine = new Box
|
||||
{
|
||||
Colour = Color4.Yellow,
|
||||
Height = 2,
|
||||
},
|
||||
originBox = new Box
|
||||
{
|
||||
Colour = Color4.Red,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
},
|
||||
anchorBox = new Box
|
||||
{
|
||||
Colour = Color4.Red,
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (drawable.Parent == null)
|
||||
return;
|
||||
|
||||
originBox.Position = drawable.ToSpaceOfOtherDrawable(drawable.OriginPosition, this);
|
||||
anchorBox.Position = drawable.Parent.ToSpaceOfOtherDrawable(drawable.AnchorPosition, this);
|
||||
|
||||
var point1 = ToLocalSpace(anchorBox.ScreenSpaceDrawQuad.Centre);
|
||||
var point2 = ToLocalSpace(originBox.ScreenSpaceDrawQuad.Centre);
|
||||
|
||||
anchorLine.Position = point1;
|
||||
anchorLine.Width = (point2 - point1).Length;
|
||||
anchorLine.Rotation = MathHelper.RadiansToDegrees(MathF.Atan2(point2.Y - point1.Y, point2.X - point1.X));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user