1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Extract drawable.ScreenSpaceDrawQuad to a variable

This commit is contained in:
Robin Avery 2021-06-11 07:06:22 -04:00
parent a6774eb5b5
commit 0c8851f4b7
No known key found for this signature in database
GPG Key ID: 0496DF10CEF7E226

View File

@ -281,19 +281,22 @@ namespace osu.Game.Skinning.Editor
if (parent == null)
return drawable.Anchor;
var screenPosition = drawable.ScreenSpaceDrawQuad.TopLeft;
Vector2 screenPosition;
{
var quad = drawable.ScreenSpaceDrawQuad;
var origin = drawable.Origin;
screenPosition = quad.TopLeft;
if (origin.HasFlagFast(Anchor.x2))
screenPosition.X += drawable.ScreenSpaceDrawQuad.Width;
screenPosition.X += quad.Width;
else if (origin.HasFlagFast(Anchor.x1))
screenPosition.X += drawable.ScreenSpaceDrawQuad.Width / 2f;
screenPosition.X += quad.Width / 2f;
if (origin.HasFlagFast(Anchor.y2))
screenPosition.Y += drawable.ScreenSpaceDrawQuad.Height;
screenPosition.Y += quad.Height;
else if (origin.HasFlagFast(Anchor.y1))
screenPosition.Y += drawable.ScreenSpaceDrawQuad.Height / 2f;
screenPosition.Y += quad.Height / 2f;
}
var absolutePosition = parent.ToLocalSpace(screenPosition);