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