1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 19:27:31 +08:00
osu-lazer/osu.Game/Screens/Select/Footer.cs

120 lines
4.0 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2017-02-25 20:12:39 +08:00
using osu.Framework.Graphics.Transforms;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Menu;
namespace osu.Game.Screens.Select
{
public class Footer : Container
{
private Box modeLight;
private const float play_song_select_button_width = 100;
private const float play_song_select_button_height = 50;
public const int TRANSITION_LENGTH = 300;
private const float padding = 80;
public override bool Contains(Vector2 screenSpacePos) => true;
public Action OnBack;
public Action OnStart;
2017-03-02 02:33:01 +08:00
private FillFlowContainer buttons;
2017-02-22 20:43:29 +08:00
public OsuLogo StartButton;
public void AddButton(string text, Color4 colour, Action action)
{
var button = new FooterButton
{
Text = text,
Height = play_song_select_button_height,
Width = play_song_select_button_width,
SelectedColour = colour,
DeselectedColour = colour.Opacity(0.5f),
};
button.Hovered = () => updateModeLight(button);
button.HoverLost = () => updateModeLight();
button.Action = action;
buttons.Add(button);
}
private void updateModeLight(FooterButton button = null)
{
modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
}
public Footer()
{
2017-02-07 15:15:45 +08:00
const float bottom_tool_height = 50;
RelativeSizeAxes = Axes.X;
2017-02-07 15:15:45 +08:00
Height = bottom_tool_height;
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-02-22 20:43:29 +08:00
StartButton = new OsuLogo
{
Anchor = Anchor.BottomRight,
Scale = new Vector2(0.4f),
Position = new Vector2(-70, -25),
Action = () => OnStart?.Invoke()
},
new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = () => OnBack?.Invoke(),
},
2017-03-02 02:33:01 +08:00
new FillFlowContainer
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Position = new Vector2(BackButton.SIZE_EXTENDED.X + padding, 0),
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),
Children = new Drawable[]
{
2017-03-02 02:33:01 +08:00
buttons = new FillFlowContainer
{
2017-03-04 18:00:17 +08:00
Direction = FillDirection.Horizontal,
2017-03-02 02:33:01 +08:00
Spacing = new Vector2(0.2f, 0),
AutoSizeAxes = Axes.Both,
}
}
}
};
updateModeLight();
}
}
}