mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Adjust backbutton animation
This commit is contained in:
@ -1,28 +1,40 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class BackButton : TwoLayerButton, IKeyBindingHandler<GlobalAction>
|
||||
public class BackButton : VisibilityContainer, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public Action Action;
|
||||
|
||||
private readonly TwoLayerButton button;
|
||||
|
||||
public BackButton()
|
||||
{
|
||||
Text = @"back";
|
||||
Icon = OsuIcon.LeftCircle;
|
||||
Anchor = Anchor.BottomLeft;
|
||||
Origin = Anchor.BottomLeft;
|
||||
Size = TwoLayerButton.SIZE_EXTENDED;
|
||||
|
||||
Child = button = new TwoLayerButton
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = @"back",
|
||||
Icon = OsuIcon.LeftCircle,
|
||||
Action = () => Action?.Invoke()
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BackgroundColour = colours.Pink;
|
||||
HoverColour = colours.PinkDark;
|
||||
button.BackgroundColour = colours.Pink;
|
||||
button.HoverColour = colours.PinkDark;
|
||||
}
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
@ -37,5 +49,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
button.MoveToX(0, 400, Easing.OutQuint);
|
||||
button.FadeIn(150, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
button.MoveToX(-TwoLayerButton.SIZE_EXTENDED.X / 2, 400);
|
||||
button.FadeOut(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user