mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 15:12:57 +08:00
Rename some methods for clarity
Methods which operate on a collection of `ISkinnableDrawable`s are now plural; ones which take a single item are singular. This also allows cutting down the name of `getClosestAnchorForDrawable` to just `getClosestAnchor`.
This commit is contained in:
parent
01da73daf2
commit
529a80871b
@ -165,11 +165,11 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
var drawable = (Drawable)item;
|
var drawable = (Drawable)item;
|
||||||
|
|
||||||
var closestAnchor = getClosestAnchorForDrawable(drawable);
|
var closestAnchor = getClosestAnchor(drawable);
|
||||||
|
|
||||||
if (closestAnchor == drawable.Anchor) return;
|
if (closestAnchor == drawable.Anchor) return;
|
||||||
|
|
||||||
updateDrawableAnchor(drawable, closestAnchor);
|
applyAnchor(drawable, closestAnchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSelectionChanged()
|
protected override void OnSelectionChanged()
|
||||||
@ -187,21 +187,21 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
|
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<ISkinnableDrawable>> selection)
|
||||||
{
|
{
|
||||||
var closestItem = new TernaryStateRadioMenuItem("Closest", MenuItemType.Standard, _ => applyClosestAnchor())
|
var closestItem = new TernaryStateRadioMenuItem("Closest", MenuItemType.Standard, _ => applyClosestAnchors())
|
||||||
{
|
{
|
||||||
State = { Value = GetStateFromSelection(selection, c => !c.Item.UsesFixedAnchor) }
|
State = { Value = GetStateFromSelection(selection, c => !c.Item.UsesFixedAnchor) }
|
||||||
};
|
};
|
||||||
|
|
||||||
yield return new OsuMenuItem("Anchor")
|
yield return new OsuMenuItem("Anchor")
|
||||||
{
|
{
|
||||||
Items = createAnchorItems((i, a) => i.UsesFixedAnchor && ((Drawable)i).Anchor == a, applyCustomAnchor)
|
Items = createAnchorItems((i, a) => i.UsesFixedAnchor && ((Drawable)i).Anchor == a, applyCustomAnchors)
|
||||||
.Prepend(closestItem)
|
.Prepend(closestItem)
|
||||||
.ToArray()
|
.ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
yield return new OsuMenuItem("Origin")
|
yield return new OsuMenuItem("Origin")
|
||||||
{
|
{
|
||||||
Items = createAnchorItems((i, o) => ((Drawable)i).Origin == o, applyOrigin).ToArray()
|
Items = createAnchorItems((i, o) => ((Drawable)i).Origin == o, applyOrigins).ToArray()
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||||
@ -237,7 +237,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
drawable.Parent.ToLocalSpace(screenSpacePosition) - drawable.AnchorPosition;
|
drawable.Parent.ToLocalSpace(screenSpacePosition) - drawable.AnchorPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyOrigin(Anchor anchor)
|
private void applyOrigins(Anchor anchor)
|
||||||
{
|
{
|
||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
@ -256,18 +256,18 @@ namespace osu.Game.Skinning.Editor
|
|||||||
private Quad getSelectionQuad() =>
|
private Quad getSelectionQuad() =>
|
||||||
GetSurroundingQuad(SelectedBlueprints.SelectMany(b => b.Item.ScreenSpaceDrawQuad.GetVertices().ToArray()));
|
GetSurroundingQuad(SelectedBlueprints.SelectMany(b => b.Item.ScreenSpaceDrawQuad.GetVertices().ToArray()));
|
||||||
|
|
||||||
private void applyCustomAnchor(Anchor anchor)
|
private void applyCustomAnchors(Anchor anchor)
|
||||||
{
|
{
|
||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
var drawable = (Drawable)item;
|
var drawable = (Drawable)item;
|
||||||
|
|
||||||
item.UsesFixedAnchor = true;
|
item.UsesFixedAnchor = true;
|
||||||
updateDrawableAnchor(drawable, anchor);
|
applyAnchor(drawable, anchor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyClosestAnchor()
|
private void applyClosestAnchors()
|
||||||
{
|
{
|
||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
@ -276,7 +276,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Anchor getClosestAnchorForDrawable(Drawable drawable)
|
private static Anchor getClosestAnchor(Drawable drawable)
|
||||||
{
|
{
|
||||||
var parent = drawable.Parent;
|
var parent = drawable.Parent;
|
||||||
|
|
||||||
@ -323,7 +323,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
return tier0;
|
return tier0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateDrawableAnchor(Drawable drawable, Anchor anchor)
|
private static void applyAnchor(Drawable drawable, Anchor anchor)
|
||||||
{
|
{
|
||||||
var previousAnchor = drawable.AnchorPosition;
|
var previousAnchor = drawable.AnchorPosition;
|
||||||
drawable.Anchor = anchor;
|
drawable.Anchor = anchor;
|
||||||
|
Loading…
Reference in New Issue
Block a user