mirror of
https://github.com/ppy/osu.git
synced 2025-01-22 10:33:13 +08:00
Merge pull request #12765 from peppy/skin-blueprint-anchor-origin
This commit is contained in:
commit
879ef46354
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -21,6 +22,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
private Container outlineBox;
|
private Container outlineBox;
|
||||||
|
|
||||||
|
private AnchorOriginVisualiser anchorOriginVisualiser;
|
||||||
|
|
||||||
private Drawable drawable => (Drawable)Item;
|
private Drawable drawable => (Drawable)Item;
|
||||||
|
|
||||||
protected override bool ShouldBeAlive => drawable.IsAlive && Item.IsPresent;
|
protected override bool ShouldBeAlive => drawable.IsAlive && Item.IsPresent;
|
||||||
@ -64,9 +67,13 @@ namespace osu.Game.Skinning.Editor
|
|||||||
Font = OsuFont.Default.With(size: 10, weight: FontWeight.Bold),
|
Font = OsuFont.Default.With(size: 10, weight: FontWeight.Bold),
|
||||||
Anchor = Anchor.BottomRight,
|
Anchor = Anchor.BottomRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
anchorOriginVisualiser = new AnchorOriginVisualiser(drawable)
|
||||||
|
{
|
||||||
|
Alpha = 0,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +82,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
updateSelectedState();
|
updateSelectedState();
|
||||||
box.FadeInFromZero(200, Easing.OutQuint);
|
this.FadeInFromZero(200, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSelected()
|
protected override void OnSelected()
|
||||||
@ -94,6 +101,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
outlineBox.FadeColour(colours.Pink.Opacity(IsSelected ? 1 : 0.5f), 200, Easing.OutQuint);
|
outlineBox.FadeColour(colours.Pink.Opacity(IsSelected ? 1 : 0.5f), 200, Easing.OutQuint);
|
||||||
outlineBox.Child.FadeTo(IsSelected ? 0.2f : 0, 200, Easing.OutQuint);
|
outlineBox.Child.FadeTo(IsSelected ? 0.2f : 0, 200, Easing.OutQuint);
|
||||||
|
|
||||||
|
anchorOriginVisualiser.FadeTo(IsSelected ? 1 : 0, 200, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Quad drawableQuad;
|
private Quad drawableQuad;
|
||||||
@ -118,4 +127,58 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
public override Quad SelectionQuad => drawable.ScreenSpaceDrawQuad;
|
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