mirror of
https://github.com/ppy/osu
synced 2024-12-14 19:06:07 +00:00
Merge pull request #12763 from peppy/skin-editor-default-placement-location
Give newly added skin components a centered location to make them easier to find
This commit is contained in:
commit
c519e4f558
@ -165,10 +165,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 ISkinnableDrawable component))
|
||||
throw new InvalidOperationException($"Attempted to instantiate a component for placement which was not an {typeof(ISkinnableDrawable)}.");
|
||||
|
||||
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);
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Skinning
|
||||
/// <summary>
|
||||
/// Denotes a container which can house <see cref="ISkinnableDrawable"/>s.
|
||||
/// </summary>
|
||||
public interface ISkinnableTarget
|
||||
public interface ISkinnableTarget : IDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The definition of this target.
|
||||
|
Loading…
Reference in New Issue
Block a user