1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 12:35:34 +08:00

make getClosestAnchor work with rotated drawable

This commit is contained in:
Wleter 2023-08-31 20:24:26 +02:00
parent 00c87c782b
commit 47160f7744

View File

@ -291,7 +291,7 @@ namespace osu.Game.Overlays.SkinEditor
if (parent == null) if (parent == null)
return drawable.Anchor; return drawable.Anchor;
var screenPosition = getScreenPosition(); var screenPosition = drawable.ToScreenSpace(drawable.OriginPosition);
var absolutePosition = parent.ToLocalSpace(screenPosition); var absolutePosition = parent.ToLocalSpace(screenPosition);
var factor = parent.RelativeToAbsoluteFactor; var factor = parent.RelativeToAbsoluteFactor;
@ -313,26 +313,6 @@ namespace osu.Game.Overlays.SkinEditor
result |= getAnchorFromPosition(absolutePosition.Y / factor.Y, Anchor.y0, Anchor.y1, Anchor.y2); result |= getAnchorFromPosition(absolutePosition.Y / factor.Y, Anchor.y0, Anchor.y1, Anchor.y2);
return result; return result;
Vector2 getScreenPosition()
{
var quad = drawable.ScreenSpaceDrawQuad;
var origin = drawable.Origin;
var pos = quad.TopLeft;
if (origin.HasFlagFast(Anchor.x2))
pos.X += quad.Width;
else if (origin.HasFlagFast(Anchor.x1))
pos.X += quad.Width / 2f;
if (origin.HasFlagFast(Anchor.y2))
pos.Y += quad.Height;
else if (origin.HasFlagFast(Anchor.y1))
pos.Y += quad.Height / 2f;
return pos;
}
} }
private static void applyAnchor(Drawable drawable, Anchor anchor) private static void applyAnchor(Drawable drawable, Anchor anchor)