1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 00:07:32 +08:00
osu-lazer/osu.Game/Screens/Select/Options/BeatmapOptionsOverlay.cs

113 lines
4.2 KiB
C#
Raw Normal View History

2017-03-02 20:40:55 +08:00
// 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 osu.Framework.Extensions.Color4Extensions;
2017-03-02 20:40:55 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Input;
using osu.Game.Graphics.Containers;
2017-03-02 20:40:55 +08:00
namespace osu.Game.Screens.Select.Options
2017-03-02 20:40:55 +08:00
{
public class BeatmapOptionsOverlay : OsuFocusedOverlayContainer
2017-03-02 20:40:55 +08:00
{
private const float transition_duration = 500;
private const float x_position = 0.2f;
private const float x_movement = 0.8f;
2017-03-02 20:40:55 +08:00
private const float height = 100;
private readonly Box holder;
private readonly FillFlowContainer<BeatmapOptionsButton> buttonsContainer;
2017-03-02 20:40:55 +08:00
protected override void PopIn()
{
base.PopIn();
FadeIn(transition_duration, EasingTypes.OutQuint);
2017-03-02 20:40:55 +08:00
if (buttonsContainer.Position.X == 1 || Alpha == 0)
buttonsContainer.MoveToX(x_position - x_movement);
2017-03-02 20:40:55 +08:00
holder.ScaleTo(new Vector2(1, 1), transition_duration / 2, EasingTypes.OutQuint);
2017-03-02 20:40:55 +08:00
buttonsContainer.MoveToX(x_position, transition_duration, EasingTypes.OutQuint);
buttonsContainer.TransformSpacingTo(Vector2.Zero, transition_duration, EasingTypes.OutQuint);
}
protected override void PopOut()
{
base.PopOut();
holder.ScaleTo(new Vector2(1, 0), transition_duration / 2, EasingTypes.InSine);
buttonsContainer.MoveToX(x_position + x_movement, transition_duration, EasingTypes.InSine);
2017-03-02 20:40:55 +08:00
buttonsContainer.TransformSpacingTo(new Vector2(200f, 0f), transition_duration, EasingTypes.InSine);
FadeOut(transition_duration, EasingTypes.InQuint);
2017-03-02 20:40:55 +08:00
}
public BeatmapOptionsOverlay()
{
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
2017-03-02 20:40:55 +08:00
Children = new Drawable[]
{
holder = new Box
2017-03-02 20:40:55 +08:00
{
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
2017-03-02 20:40:55 +08:00
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Scale = new Vector2(1, 0),
Colour = Color4.Black.Opacity(0.5f),
2017-03-02 20:40:55 +08:00
},
buttonsContainer = new ReverseChildIDFillFlowContainer<BeatmapOptionsButton>
2017-03-02 20:40:55 +08:00
{
Height = height,
RelativePositionAxes = Axes.X,
2017-03-03 12:53:17 +08:00
AutoSizeAxes = Axes.X,
2017-03-02 20:40:55 +08:00
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
};
}
2017-03-14 21:20:38 +08:00
/// <param name="firstLine">Text in the first line.</param>
/// <param name="secondLine">Text in the second line.</param>
/// <param name="colour">Colour of the button.</param>
/// <param name="icon">Icon of the button.</param>
/// <param name="hotkey">Hotkey of the button.</param>
/// <param name="action">Action the button does.</param>
2017-03-14 20:18:14 +08:00
/// <param name="depth">
/// <para>Lower depth to be put on the left, and higher to be put on the right.</para>
/// <para>Notice this is different to <see cref="Footer"/>!</para>
/// </param>
2017-03-14 21:20:38 +08:00
public void AddButton(string firstLine, string secondLine, FontAwesome icon, Color4 colour, Action action, Key? hotkey = null, float depth = 0)
{
buttonsContainer.Add(new BeatmapOptionsButton
{
FirstLineText = firstLine,
2017-03-14 21:20:38 +08:00
SecondLineText = secondLine,
Icon = icon,
ButtonColour = colour,
2017-03-14 20:18:14 +08:00
Depth = depth,
Action = () =>
{
Hide();
action?.Invoke();
},
HotKey = hotkey
});
}
2017-03-02 20:40:55 +08:00
}
}