2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-06-25 17:30:43 +08:00
|
|
|
|
using System;
|
2016-12-05 20:09:41 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-11-27 09:21:12 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-06-25 17:30:43 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2024-05-16 11:59:58 +08:00
|
|
|
|
using osu.Game.Screens.Footer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-11-27 09:21:12 +08:00
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
|
{
|
2024-05-16 11:59:58 +08:00
|
|
|
|
// todo: remove this once all screens migrate to display the new game footer and back button.
|
2019-07-29 17:45:16 +08:00
|
|
|
|
public partial class BackButton : VisibilityContainer
|
2016-11-27 09:21:12 +08:00
|
|
|
|
{
|
2019-06-25 17:30:43 +08:00
|
|
|
|
public Action Action;
|
|
|
|
|
|
|
|
|
|
private readonly TwoLayerButton button;
|
|
|
|
|
|
2024-05-16 11:59:58 +08:00
|
|
|
|
public BackButton(ScreenFooter.BackReceptor receptor = null)
|
2016-11-27 09:21:12 +08:00
|
|
|
|
{
|
2019-06-25 17:30:43 +08:00
|
|
|
|
Size = TwoLayerButton.SIZE_EXTENDED;
|
|
|
|
|
|
2022-06-01 20:00:14 +08:00
|
|
|
|
Child = button = new TwoLayerButton
|
2019-06-25 17:30:43 +08:00
|
|
|
|
{
|
2019-08-06 11:43:30 +08:00
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
2019-06-25 17:30:43 +08:00
|
|
|
|
Text = @"back",
|
|
|
|
|
Icon = OsuIcon.LeftCircle,
|
|
|
|
|
Action = () => Action?.Invoke()
|
|
|
|
|
};
|
2020-05-17 16:35:10 +08:00
|
|
|
|
|
2020-05-17 16:35:18 +08:00
|
|
|
|
if (receptor == null)
|
|
|
|
|
{
|
|
|
|
|
// if a receptor wasn't provided, create our own locally.
|
2024-05-16 11:59:58 +08:00
|
|
|
|
Add(receptor = new ScreenFooter.BackReceptor());
|
2020-05-17 16:35:18 +08:00
|
|
|
|
}
|
2020-05-17 16:35:10 +08:00
|
|
|
|
|
2021-08-04 16:27:44 +08:00
|
|
|
|
receptor.OnBackPressed = () => button.TriggerClick();
|
2016-11-27 10:48:31 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-12-05 20:09:41 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-06-30 03:05:37 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2016-12-05 20:09:41 +08:00
|
|
|
|
{
|
2019-06-25 17:30:43 +08:00
|
|
|
|
button.BackgroundColour = colours.Pink;
|
|
|
|
|
button.HoverColour = colours.PinkDark;
|
2016-11-27 09:21:12 +08:00
|
|
|
|
}
|
2019-06-25 16:17:29 +08:00
|
|
|
|
|
2019-06-25 17:30:43 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
button.MoveToX(0, 400, Easing.OutQuint);
|
|
|
|
|
button.FadeIn(150, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2019-06-25 19:23:34 +08:00
|
|
|
|
button.MoveToX(-TwoLayerButton.SIZE_EXTENDED.X / 2, 400, Easing.OutQuint);
|
|
|
|
|
button.FadeOut(400, Easing.OutQuint);
|
2019-06-25 17:30:43 +08:00
|
|
|
|
}
|
2016-11-27 09:21:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|