From 2c88e6df8de34ac1bc5e637bc4d1564d48699dd1 Mon Sep 17 00:00:00 2001 From: Robin Avery Date: Tue, 8 Jun 2021 10:08:02 -0400 Subject: [PATCH] Simplify `applyClosestAnchor` to one line by moving another guard clause --- .../Skinning/Editor/SkinSelectionHandler.cs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs index a9b985fda2..500020ca46 100644 --- a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs +++ b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs @@ -149,24 +149,20 @@ namespace osu.Game.Skinning.Editor { foreach (var c in SelectedBlueprints) { - var skinnableDrawable = c.Item; - Drawable drawable = (Drawable)skinnableDrawable; + var item = c.Item; + Drawable drawable = (Drawable)item; + drawable.Position += drawable.ScreenSpaceDeltaToParentSpace(moveEvent.ScreenSpaceDelta); - checkAndApplyClosestAnchor(skinnableDrawable); + if (item.UsesFixedAnchor) continue; + + applyClosestAnchor(drawable); } return true; } - private static void checkAndApplyClosestAnchor(ISkinnableDrawable item) - { - if (item.UsesFixedAnchor) return; - - var drawable = (Drawable)item; - - applyAnchor(drawable, getClosestAnchor(drawable)); - } + private static void applyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable)); protected override void OnSelectionChanged() { @@ -268,7 +264,7 @@ namespace osu.Game.Skinning.Editor foreach (var item in SelectedItems) { item.UsesFixedAnchor = false; - checkAndApplyClosestAnchor(item); + applyClosestAnchor((Drawable)item); } }