Add the skin editor to the game

This commit is contained in:
Dean Herbert
2021-04-29 17:20:22 +09:00
parent 141d3af302
commit b936043956
4 changed files with 110 additions and 41 deletions

View File

@ -4,16 +4,16 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Cursor;
namespace osu.Game.Skinning.Editor
{
public class SkinEditor : VisibilityContainer
public class SkinEditor : FocusedOverlayContainer
{
public const double TRANSITION_DURATION = 500;
private readonly Drawable target;
private Container border;
protected override bool StartHidden => true;
@ -25,32 +25,13 @@ namespace osu.Game.Skinning.Editor
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
InternalChild = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
border = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderColour = colours.Yellow,
BorderThickness = 5,
CornerRadius = 5,
Children = new Drawable[]
{
new Box
{
AlwaysPresent = true,
Alpha = 0,
RelativeSizeAxes = Axes.Both,
},
}
},
new SkinBlueprintContainer(target),
}
};
@ -62,29 +43,18 @@ namespace osu.Game.Skinning.Editor
Show();
}
private const double transition_duration = 500;
private const float visible_target_scale = 0.8f;
protected override bool OnHover(HoverEvent e) => true;
protected override bool OnMouseDown(MouseDownEvent e) => true;
protected override void PopIn()
{
if (IsLoaded)
{
target.ScaleTo(visible_target_scale, transition_duration, Easing.OutQuint);
border.ScaleTo(visible_target_scale, transition_duration, Easing.OutQuint);
}
this.FadeIn(transition_duration);
this.FadeIn(TRANSITION_DURATION, Easing.OutQuint);
}
protected override void PopOut()
{
if (IsLoaded)
{
target.ScaleTo(1, transition_duration, Easing.OutQuint);
border.ScaleTo(1, transition_duration, Easing.OutQuint);
}
this.FadeOut(transition_duration, Easing.OutQuint);
this.FadeOut(TRANSITION_DURATION, Easing.OutQuint);
}
}
}