mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Place new skin components at the centre of the screen by default
This commit is contained in:
@ -166,10 +166,22 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
private void placeComponent(Type type)
|
||||
{
|
||||
var targetContainer = getTarget(SkinnableTarget.MainHUDComponents);
|
||||
|
||||
if (targetContainer == null)
|
||||
return;
|
||||
|
||||
if (!(Activator.CreateInstance(type) is ISkinnableComponent component))
|
||||
throw new InvalidOperationException("Attempted to instantiate a component for placement which was not an {typeof(ISkinnableComponent)}.");
|
||||
|
||||
getTarget(SkinnableTarget.MainHUDComponents)?.Add(component);
|
||||
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;
|
||||
|
||||
targetContainer.Add(component);
|
||||
|
||||
SelectedComponents.Clear();
|
||||
SelectedComponents.Add(component);
|
||||
|
Reference in New Issue
Block a user