mirror of
https://github.com/osukey/osukey.git
synced 2025-06-25 05:07:59 +09: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);
|
placeComponent(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void placeComponent(ISkinnableDrawable component)
|
private void placeComponent(ISkinnableDrawable component, bool applyDefaults = true)
|
||||||
{
|
{
|
||||||
var targetContainer = getFirstTarget();
|
var targetContainer = getFirstTarget();
|
||||||
|
|
||||||
@ -263,10 +263,13 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
var drawableComponent = (Drawable)component;
|
var drawableComponent = (Drawable)component;
|
||||||
|
|
||||||
// give newly added components a sane starting location.
|
if (applyDefaults)
|
||||||
drawableComponent.Origin = Anchor.TopCentre;
|
{
|
||||||
drawableComponent.Anchor = Anchor.TopCentre;
|
// give newly added components a sane starting location.
|
||||||
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
drawableComponent.Origin = Anchor.TopCentre;
|
||||||
|
drawableComponent.Anchor = Anchor.TopCentre;
|
||||||
|
drawableComponent.Y = targetContainer.DrawSize.Y / 2;
|
||||||
|
}
|
||||||
|
|
||||||
targetContainer.Add(component);
|
targetContainer.Add(component);
|
||||||
|
|
||||||
@ -356,10 +359,16 @@ namespace osu.Game.Skinning.Editor
|
|||||||
realm.Run(r => r.Refresh());
|
realm.Run(r => r.Refresh());
|
||||||
|
|
||||||
// place component
|
// 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;
|
return Task.CompletedTask;
|
||||||
|
@ -157,13 +157,13 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
if (item.UsesFixedAnchor) continue;
|
if (item.UsesFixedAnchor) continue;
|
||||||
|
|
||||||
applyClosestAnchor(drawable);
|
ApplyClosestAnchor(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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()
|
protected override void OnSelectionChanged()
|
||||||
{
|
{
|
||||||
@ -252,7 +252,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
if (item.UsesFixedAnchor) continue;
|
if (item.UsesFixedAnchor) continue;
|
||||||
|
|
||||||
applyClosestAnchor(drawable);
|
ApplyClosestAnchor(drawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
foreach (var item in SelectedItems)
|
foreach (var item in SelectedItems)
|
||||||
{
|
{
|
||||||
item.UsesFixedAnchor = false;
|
item.UsesFixedAnchor = false;
|
||||||
applyClosestAnchor((Drawable)item);
|
ApplyClosestAnchor((Drawable)item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user