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

Simplify applyClosestAnchor to one line by moving another guard clause

This commit is contained in:
Robin Avery 2021-06-08 10:08:02 -04:00
parent f22cc981d1
commit 2c88e6df8d
No known key found for this signature in database
GPG Key ID: 0496DF10CEF7E226

View File

@ -149,24 +149,20 @@ namespace osu.Game.Skinning.Editor
{ {
foreach (var c in SelectedBlueprints) foreach (var c in SelectedBlueprints)
{ {
var skinnableDrawable = c.Item; var item = c.Item;
Drawable drawable = (Drawable)skinnableDrawable; Drawable drawable = (Drawable)item;
drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta); drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta);
checkAndApplyClosestAnchor(skinnableDrawable); if (item.UsesFixedAnchor) continue;
applyClosestAnchor(drawable);
} }
return true; return true;
} }
private static void checkAndApplyClosestAnchor(ISkinnableDrawable item) private static void applyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable));
{
if (item.UsesFixedAnchor) return;
var drawable = (Drawable)item;
applyAnchor(drawable, getClosestAnchor(drawable));
}
protected override void OnSelectionChanged() protected override void OnSelectionChanged()
{ {
@ -268,7 +264,7 @@ namespace osu.Game.Skinning.Editor
foreach (var item in SelectedItems) foreach (var item in SelectedItems)
{ {
item.UsesFixedAnchor = false; item.UsesFixedAnchor = false;
checkAndApplyClosestAnchor(item); applyClosestAnchor((Drawable)item);
} }
} }