mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Import new skin editor sprites to the cursor location
This commit is contained in:
parent
6afed5e865
commit
f0821ce1fc
@ -254,7 +254,7 @@ namespace osu.Game.Skinning.Editor
|
||||
placeComponent(component);
|
||||
}
|
||||
|
||||
private void placeComponent(ISkinnableDrawable component)
|
||||
private void placeComponent(ISkinnableDrawable component, bool applyDefaults = true)
|
||||
{
|
||||
var targetContainer = getFirstTarget();
|
||||
|
||||
@ -263,10 +263,13 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
var drawableComponent = (Drawable)component;
|
||||
|
||||
// give newly added components a sane starting location.
|
||||
drawableComponent.Origin = Anchor.TopCentre;
|
||||
drawableComponent.Anchor = Anchor.TopCentre;
|
||||
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
||||
if (applyDefaults)
|
||||
{
|
||||
// give newly added components a sane starting location.
|
||||
drawableComponent.Origin = Anchor.TopCentre;
|
||||
drawableComponent.Anchor = Anchor.TopCentre;
|
||||
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
||||
}
|
||||
|
||||
targetContainer.Add(component);
|
||||
|
||||
@ -356,10 +359,16 @@ namespace osu.Game.Skinning.Editor
|
||||
realm.Run(r => r.Refresh());
|
||||
|
||||
// place component
|
||||
placeComponent(new SkinnableSprite
|
||||
var sprite = new SkinnableSprite
|
||||
{
|
||||
SpriteName = { Value = file.Name }
|
||||
});
|
||||
SpriteName = { Value = file.Name },
|
||||
Origin = Anchor.Centre,
|
||||
Position = getFirstTarget().ToLocalSpace(GetContainingInputManager().CurrentState.Mouse.Position),
|
||||
};
|
||||
|
||||
placeComponent(sprite, false);
|
||||
|
||||
SkinSelectionHandler.ApplyClosestAnchor(sprite);
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
@ -157,13 +157,13 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
if (item.UsesFixedAnchor) continue;
|
||||
|
||||
applyClosestAnchor(drawable);
|
||||
ApplyClosestAnchor(drawable);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void applyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable));
|
||||
public static void ApplyClosestAnchor(Drawable drawable) => applyAnchor(drawable, getClosestAnchor(drawable));
|
||||
|
||||
protected override void OnSelectionChanged()
|
||||
{
|
||||
@ -252,7 +252,7 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
if (item.UsesFixedAnchor) continue;
|
||||
|
||||
applyClosestAnchor(drawable);
|
||||
ApplyClosestAnchor(drawable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -279,7 +279,7 @@ namespace osu.Game.Skinning.Editor
|
||||
foreach (var item in SelectedItems)
|
||||
{
|
||||
item.UsesFixedAnchor = false;
|
||||
applyClosestAnchor((Drawable)item);
|
||||
ApplyClosestAnchor((Drawable)item);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user