2021-04-28 14:14:48 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-04-29 12:53:01 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-04-28 14:14:48 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-04-29 12:53:01 +08:00
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Game.Graphics;
|
2021-04-28 14:14:48 +08:00
|
|
|
using osu.Game.Graphics.Cursor;
|
|
|
|
|
|
|
|
namespace osu.Game.Skinning.Editor
|
|
|
|
{
|
2021-04-29 12:53:01 +08:00
|
|
|
public class SkinEditor : VisibilityContainer
|
2021-04-28 14:14:48 +08:00
|
|
|
{
|
|
|
|
private readonly Drawable target;
|
2021-04-29 12:53:01 +08:00
|
|
|
private Container border;
|
|
|
|
|
|
|
|
protected override bool StartHidden => true;
|
2021-04-28 14:14:48 +08:00
|
|
|
|
|
|
|
public SkinEditor(Drawable target)
|
|
|
|
{
|
|
|
|
this.target = target;
|
|
|
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
2021-04-29 12:53:01 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OsuColour colours)
|
2021-04-28 14:14:48 +08:00
|
|
|
{
|
|
|
|
InternalChild = new OsuContextMenuContainer
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2021-04-29 12:53:01 +08:00
|
|
|
Children = new Drawable[]
|
2021-04-28 14:14:48 +08:00
|
|
|
{
|
2021-04-29 12:53:01 +08:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2021-04-28 14:14:48 +08:00
|
|
|
new SkinBlueprintContainer(target),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2021-04-29 12:53:01 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private const double transition_duration = 500;
|
|
|
|
private const float visible_target_scale = 0.8f;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2021-04-28 14:14:48 +08:00
|
|
|
}
|
|
|
|
}
|