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
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-07-28 14:32:29 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2024-11-11 16:54:43 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class Footer : Container
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly Box modeLight;
|
|
|
|
|
|
|
|
|
|
public const float HEIGHT = 50;
|
|
|
|
|
|
|
|
|
|
public const int TRANSITION_LENGTH = 300;
|
|
|
|
|
|
|
|
|
|
private const float padding = 80;
|
|
|
|
|
|
|
|
|
|
private readonly FillFlowContainer<FooterButton> buttons;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
buttons.Add(button);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-08 18:03:26 +08:00
|
|
|
|
private void showOverlay(OverlayContainer overlay)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-08 18:03:26 +08:00
|
|
|
|
foreach (var o in overlays)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-08 18:03:26 +08:00
|
|
|
|
if (o == overlay)
|
|
|
|
|
o.ToggleVisibility();
|
|
|
|
|
else
|
|
|
|
|
o.Hide();
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-17 08:57:27 +08:00
|
|
|
|
private void updateModeLight()
|
|
|
|
|
{
|
|
|
|
|
var selectedButton = buttons.FirstOrDefault(b => b.Enabled.Value && b.IsHovered);
|
|
|
|
|
|
|
|
|
|
if (selectedButton != null)
|
|
|
|
|
{
|
|
|
|
|
modeLight.FadeIn(TRANSITION_LENGTH, Easing.OutQuint);
|
|
|
|
|
modeLight.FadeColour(selectedButton.SelectedColour, TRANSITION_LENGTH, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
modeLight.FadeOut(TRANSITION_LENGTH, Easing.OutQuint);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public Footer()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = HEIGHT;
|
|
|
|
|
Anchor = Anchor.BottomCentre;
|
|
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Size = Vector2.One,
|
2024-11-11 16:54:43 +08:00
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
|
|
|
|
Alpha = 0.96f,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
modeLight = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 3,
|
|
|
|
|
Position = new Vector2(0, -3),
|
2024-11-11 16:54:43 +08:00
|
|
|
|
Colour = OsuColour.Gray(0.1f),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Position = new Vector2(TwoLayerButton.SIZE_EXTENDED.X + padding, 0),
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(padding, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
buttons = new FillFlowContainer<FooterButton>
|
|
|
|
|
{
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
2019-08-06 08:57:04 +08:00
|
|
|
|
Spacing = new Vector2(-FooterButton.SHEAR_WIDTH, 0),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|