mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Adjust backbutton animation
This commit is contained in:
parent
4ed14a295d
commit
5b294ba419
44
osu.Game.Tests/Visual/UserInterface/TestSceneBackButton.cs
Normal file
44
osu.Game.Tests/Visual/UserInterface/TestSceneBackButton.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// 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 osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
|
{
|
||||||
|
public class TestSceneBackButton : OsuTestScene
|
||||||
|
{
|
||||||
|
public TestSceneBackButton()
|
||||||
|
{
|
||||||
|
BackButton button;
|
||||||
|
|
||||||
|
Child = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(300),
|
||||||
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.SlateGray
|
||||||
|
},
|
||||||
|
button = new BackButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("show button", () => button.Show());
|
||||||
|
AddStep("hide button", () => button.Hide());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +1,40 @@
|
|||||||
// 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 System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
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()
|
public BackButton()
|
||||||
{
|
{
|
||||||
Text = @"back";
|
Size = TwoLayerButton.SIZE_EXTENDED;
|
||||||
Icon = OsuIcon.LeftCircle;
|
|
||||||
Anchor = Anchor.BottomLeft;
|
Child = button = new TwoLayerButton
|
||||||
Origin = Anchor.BottomLeft;
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Text = @"back",
|
||||||
|
Icon = OsuIcon.LeftCircle,
|
||||||
|
Action = () => Action?.Invoke()
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
BackgroundColour = colours.Pink;
|
button.BackgroundColour = colours.Pink;
|
||||||
HoverColour = colours.PinkDark;
|
button.HoverColour = colours.PinkDark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
@ -37,5 +49,17 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool OnReleased(GlobalAction action) => action == GlobalAction.Back;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,6 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Alpha = 0,
|
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
if ((screenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
|
if ((screenStack.CurrentScreen as IOsuScreen)?.AllowBackButton == true)
|
||||||
@ -809,7 +808,10 @@ namespace osu.Game
|
|||||||
else
|
else
|
||||||
Toolbar.Show();
|
Toolbar.Show();
|
||||||
|
|
||||||
backButton.Alpha = newOsuScreen.ShowBackButton ? 1 : 0;
|
if (newOsuScreen.ShowBackButton)
|
||||||
|
backButton.Show();
|
||||||
|
else
|
||||||
|
backButton.Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user