1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:07:52 +08:00

Merge pull request #24698 from Wleter/skin-editor-closest-anchor

Fix closest anchor for rotated/flipped selections in skin editor
This commit is contained in:
Bartłomiej Dach 2023-09-04 10:29:05 +02:00 committed by GitHub
commit a200d043be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,7 +309,7 @@ namespace osu.Game.Overlays.SkinEditor
if (parent == null)
return drawable.Anchor;
var screenPosition = getScreenPosition();
var screenPosition = drawable.ToScreenSpace(drawable.OriginPosition);
var absolutePosition = parent.ToLocalSpace(screenPosition);
var factor = parent.RelativeToAbsoluteFactor;
@ -331,26 +331,6 @@ namespace osu.Game.Overlays.SkinEditor
result |= getAnchorFromPosition(absolutePosition.Y / factor.Y, Anchor.y0, Anchor.y1, Anchor.y2);
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)