mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Place new skin components at the centre of the screen by default
This commit is contained in:
parent
96d4011de2
commit
42e6795251
@ -166,10 +166,22 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
private void placeComponent(Type type)
|
private void placeComponent(Type type)
|
||||||
{
|
{
|
||||||
|
var targetContainer = getTarget(SkinnableTarget.MainHUDComponents);
|
||||||
|
|
||||||
|
if (targetContainer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!(Activator.CreateInstance(type) is ISkinnableComponent component))
|
if (!(Activator.CreateInstance(type) is ISkinnableComponent component))
|
||||||
throw new InvalidOperationException("Attempted to instantiate a component for placement which was not an {typeof(ISkinnableComponent)}.");
|
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.Clear();
|
||||||
SelectedComponents.Add(component);
|
SelectedComponents.Add(component);
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Skinning
|
namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Denotes a container which can house <see cref="ISkinnableComponent"/>s.
|
/// Denotes a container which can house <see cref="ISkinnableComponent"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISkinnableTarget
|
public interface ISkinnableTarget : IDrawable
|
||||||
{
|
{
|
||||||
public SkinnableTarget Target { get; }
|
public SkinnableTarget Target { get; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user