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
|
|
|
|
|
|
2017-09-20 13:31:17 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-07-20 17:07:51 +08:00
|
|
|
|
using System.Linq;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2017-03-05 02:42:37 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-01-26 22:07:49 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-07-28 14:32:29 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2017-01-26 22:07:49 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-01-26 22:07:49 +08:00
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class Footer : Container
|
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Box modeLight;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-23 18:32:58 +08:00
|
|
|
|
public const float HEIGHT = 50;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-01-26 22:07:49 +08:00
|
|
|
|
public const int TRANSITION_LENGTH = 300;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-01-26 22:07:49 +08:00
|
|
|
|
private const float padding = 80;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-20 17:07:51 +08:00
|
|
|
|
private readonly FillFlowContainer<FooterButton> buttons;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-08 18:03:26 +08:00
|
|
|
|
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
|
|
|
|
|
|
2021-01-27 21:15:53 +08:00
|
|
|
|
/// <param name="button">The button to be added.</param>
|
2019-05-08 18:03:26 +08:00
|
|
|
|
/// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param>
|
2019-05-08 18:29:43 +08:00
|
|
|
|
public void AddButton(FooterButton button, OverlayContainer overlay)
|
2019-05-08 18:03:26 +08:00
|
|
|
|
{
|
2021-01-27 21:15:53 +08:00
|
|
|
|
if (overlay != null)
|
|
|
|
|
{
|
|
|
|
|
overlays.Add(overlay);
|
|
|
|
|
button.Action = () => showOverlay(overlay);
|
|
|
|
|
}
|
2019-05-08 18:03:26 +08:00
|
|
|
|
|
2019-04-10 21:53:13 +08:00
|
|
|
|
button.Hovered = updateModeLight;
|
|
|
|
|
button.HoverLost = updateModeLight;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-03-06 16:20:58 +08:00
|
|
|
|
buttons.Add(button);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-08 18:03:26 +08:00
|
|
|
|
private void showOverlay(OverlayContainer overlay)
|
2017-09-20 13:31:17 +08:00
|
|
|
|
{
|
2019-05-08 18:03:26 +08:00
|
|
|
|
foreach (var o in overlays)
|
2017-09-20 13:31:17 +08:00
|
|
|
|
{
|
2019-05-08 18:03:26 +08:00
|
|
|
|
if (o == overlay)
|
|
|
|
|
o.ToggleVisibility();
|
|
|
|
|
else
|
|
|
|
|
o.Hide();
|
|
|
|
|
}
|
2017-09-20 13:31:17 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-07-23 02:50:25 +08:00
|
|
|
|
private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-01-26 22:07:49 +08:00
|
|
|
|
public Footer()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-03-23 18:32:58 +08:00
|
|
|
|
Height = HEIGHT;
|
2017-01-26 22:07:49 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = Vector2.One,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
|
|
|
|
},
|
|
|
|
|
modeLight = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 3,
|
|
|
|
|
Position = new Vector2(0, -3),
|
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
new FillFlowContainer
|
2017-01-26 22:07:49 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
2017-03-09 13:24:16 +08:00
|
|
|
|
Position = new Vector2(TwoLayerButton.SIZE_EXTENDED.X + padding, 0),
|
2017-01-26 22:07:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2017-03-02 02:33:01 +08:00
|
|
|
|
Spacing = new Vector2(padding, 0),
|
2017-01-26 22:07:49 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-07-20 17:07:51 +08:00
|
|
|
|
buttons = new FillFlowContainer<FooterButton>
|
2017-01-26 22:07:49 +08:00
|
|
|
|
{
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-08-06 08:57:04 +08:00
|
|
|
|
Spacing = new Vector2(-FooterButton.SHEAR_WIDTH, 0),
|
2017-01-26 22:07:49 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-01-26 22:07:49 +08:00
|
|
|
|
updateModeLight();
|
|
|
|
|
}
|
2019-07-28 14:32:29 +08:00
|
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e) => true;
|
2020-03-24 07:03:33 +08:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(HoverEvent e) => true;
|
2017-01-26 22:07:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|