1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-19 08:42:55 +08:00
osu-lazer/osu.Game/Screens/Footer/ScreenFooter.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.8 KiB
C#
Raw Normal View History

2022-12-01 18:57:50 +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.
using System.Collections.Generic;
2022-12-01 18:57:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osuTK;
2022-12-01 18:57:50 +08:00
namespace osu.Game.Screens.Footer
2022-12-01 18:57:50 +08:00
{
public partial class ScreenFooter : InputBlockingContainer
2022-12-01 18:57:50 +08:00
{
2024-05-16 09:50:51 +08:00
private const int height = 60;
private const int padding = 60;
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
/// <param name="button">The button to be added.</param>
/// <param name="overlay">The <see cref="OverlayContainer"/> to be toggled by this button.</param>
public void AddButton(ScreenFooterButton button, OverlayContainer? overlay = null)
{
if (overlay != null)
{
overlays.Add(overlay);
button.Action = () => showOverlay(overlay);
button.OverlayState.BindTo(overlay.State);
}
buttons.Add(button);
}
private void showOverlay(OverlayContainer overlay)
{
foreach (var o in overlays)
{
if (o == overlay)
o.ToggleVisibility();
else
o.Hide();
}
}
private FillFlowContainer<ScreenFooterButton> buttons = null!;
2022-12-01 18:57:50 +08:00
public ScreenFooter()
2022-12-01 18:57:50 +08:00
{
RelativeSizeAxes = Axes.X;
Height = height;
2023-09-04 12:49:29 +08:00
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
2022-12-01 18:57:50 +08:00
InternalChildren = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5
},
buttons = new FillFlowContainer<ScreenFooterButton>
{
2024-05-16 09:50:51 +08:00
Position = new Vector2(ScreenBackButton.BUTTON_WIDTH + padding, 10),
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Direction = FillDirection.Horizontal,
2024-05-10 11:47:48 +08:00
Spacing = new Vector2(7, 0),
AutoSizeAxes = Axes.Both
2024-05-16 09:50:51 +08:00
},
new ScreenBackButton
{
Margin = new MarginPadding { Bottom = 10f, Left = 12f },
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = () => { },
},
2022-12-01 18:57:50 +08:00
};
}
}
}