1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Refactor updateDrawableAnchorIfUsingClosest

This commit is contained in:
Robin Avery 2021-06-08 09:25:49 -04:00
parent 6b127f50f2
commit 01da73daf2
No known key found for this signature in database
GPG Key ID: 0496DF10CEF7E226

View File

@ -149,21 +149,29 @@ namespace osu.Game.Skinning.Editor
{
foreach (var c in SelectedBlueprints)
{
Drawable drawable = (Drawable)c.Item;
var skinnableDrawable = c.Item;
Drawable drawable = (Drawable)skinnableDrawable;
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
if (c.Item.UsesFixedAnchor) continue;
var closestAnchor = getClosestAnchorForDrawable(drawable);
if (closestAnchor == drawable.Anchor) continue;
updateDrawableAnchor(drawable, closestAnchor);
checkAndApplyClosestAnchor(skinnableDrawable);
}
return true;
}
private static void checkAndApplyClosestAnchor(ISkinnableDrawable item)
{
if (item.UsesFixedAnchor) return;
var drawable = (Drawable)item;
var closestAnchor = getClosestAnchorForDrawable(drawable);
if (closestAnchor == drawable.Anchor) return;
updateDrawableAnchor(drawable, closestAnchor);
}
protected override void OnSelectionChanged()
{
base.OnSelectionChanged();
@ -263,10 +271,8 @@ namespace osu.Game.Skinning.Editor
{
foreach (var item in SelectedItems)
{
var drawable = (Drawable)item;
item.UsesFixedAnchor = false;
updateDrawableAnchor(drawable, getClosestAnchorForDrawable(drawable));
checkAndApplyClosestAnchor(item);
}
}