2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-03-14 08:58:34 +00:00
|
|
|
|
using OpenTK.Input;
|
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;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2017-05-20 20:13:23 +00:00
|
|
|
|
using osu.Framework.Input;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Screens.Menu;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class Footer : Container
|
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Box modeLight;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
|
|
|
|
private const float play_song_select_button_width = 100;
|
|
|
|
|
private const float play_song_select_button_height = 50;
|
|
|
|
|
|
2017-03-23 10:32:58 +00:00
|
|
|
|
public const float HEIGHT = 50;
|
|
|
|
|
|
2017-01-26 14:07:49 +00:00
|
|
|
|
public const int TRANSITION_LENGTH = 300;
|
|
|
|
|
|
|
|
|
|
private const float padding = 80;
|
|
|
|
|
|
|
|
|
|
public Action OnBack;
|
|
|
|
|
public Action OnStart;
|
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly FillFlowContainer buttons;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
|
2017-02-22 12:43:29 +00:00
|
|
|
|
public OsuLogo StartButton;
|
2017-05-20 20:16:05 +00:00
|
|
|
|
|
2017-03-14 13:20:38 +00:00
|
|
|
|
/// <param name="text">Text on the button.</param>
|
|
|
|
|
/// <param name="colour">Colour of the button.</param>
|
|
|
|
|
/// <param name="hotkey">Hotkey of the button.</param>
|
|
|
|
|
/// <param name="action">Action the button does.</param>
|
2017-03-14 12:18:14 +00:00
|
|
|
|
/// <param name="depth">
|
|
|
|
|
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
|
|
|
|
|
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
|
|
|
|
|
/// </param>
|
|
|
|
|
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
|
2017-01-26 14:07:49 +00:00
|
|
|
|
{
|
|
|
|
|
var button = new FooterButton
|
|
|
|
|
{
|
|
|
|
|
Text = text,
|
|
|
|
|
Height = play_song_select_button_height,
|
|
|
|
|
Width = play_song_select_button_width,
|
2017-03-14 12:18:14 +00:00
|
|
|
|
Depth = depth,
|
2017-01-26 14:07:49 +00:00
|
|
|
|
SelectedColour = colour,
|
|
|
|
|
DeselectedColour = colour.Opacity(0.5f),
|
2017-03-14 08:58:34 +00:00
|
|
|
|
Hotkey = hotkey,
|
2017-01-26 14:07:49 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
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-02-22 12:43:29 +00:00
|
|
|
|
StartButton = new OsuLogo
|
2017-01-26 14:07:49 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Scale = new Vector2(0.4f),
|
|
|
|
|
Position = new Vector2(-70, -25),
|
|
|
|
|
Action = () => OnStart?.Invoke()
|
|
|
|
|
},
|
|
|
|
|
new BackButton
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
2017-03-14 08:58:34 +00:00
|
|
|
|
Action = () => OnBack?.Invoke()
|
2017-01-26 14:07:49 +00:00
|
|
|
|
},
|
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-03-01 18:33:01 +00:00
|
|
|
|
buttons = new FillFlowContainer
|
2017-01-26 14:07:49 +00:00
|
|
|
|
{
|
2017-03-04 10:00:17 +00:00
|
|
|
|
Direction = FillDirection.Horizontal,
|
2017-03-01 18:33:01 +00:00
|
|
|
|
Spacing = new Vector2(0.2f, 0),
|
2017-01-26 14:07:49 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateModeLight();
|
|
|
|
|
}
|
2017-05-20 20:23:49 +00:00
|
|
|
|
|
2017-05-20 20:13:23 +00:00
|
|
|
|
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || StartButton.Contains(screenSpacePos);
|
2017-05-20 20:23:49 +00:00
|
|
|
|
|
2017-05-20 20:13:23 +00:00
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnClick(InputState state) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnDragStart(InputState state) => true;
|
2017-01-26 14:07:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|