2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-05-17 15:36:57 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-05-21 23:22:27 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-03-08 17:16:23 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-05-30 17:23:53 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-30 17:23:53 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2018-01-14 03:25:09 +08:00
|
|
|
|
using OpenTK;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
|
2018-01-14 03:25:09 +08:00
|
|
|
|
namespace osu.Game.Screens.Play.PlayerSettings
|
2017-05-17 15:36:57 +08:00
|
|
|
|
{
|
2018-01-16 01:52:52 +08:00
|
|
|
|
public abstract class PlayerSettingsGroup : Container
|
2017-05-17 15:36:57 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2017-05-30 17:23:53 +08:00
|
|
|
|
/// The title to be displayed in the header of this group.
|
2017-05-17 15:36:57 +08:00
|
|
|
|
/// </summary>
|
2017-05-28 05:56:11 +08:00
|
|
|
|
protected abstract string Title { get; }
|
2017-05-17 15:36:57 +08:00
|
|
|
|
|
2017-06-05 15:43:23 +08:00
|
|
|
|
private const float transition_duration = 250;
|
2017-05-21 23:22:27 +08:00
|
|
|
|
private const int container_width = 270;
|
2017-05-19 11:39:39 +08:00
|
|
|
|
private const int border_thickness = 2;
|
|
|
|
|
private const int header_height = 30;
|
|
|
|
|
private const int corner_radius = 5;
|
2017-05-19 01:21:58 +08:00
|
|
|
|
|
2017-05-30 17:23:53 +08:00
|
|
|
|
private readonly FillFlowContainer content;
|
|
|
|
|
private readonly IconButton button;
|
2017-06-05 15:43:23 +08:00
|
|
|
|
|
2018-01-27 03:20:24 +08:00
|
|
|
|
private bool expanded = true;
|
2017-05-17 20:39:26 +08:00
|
|
|
|
|
2018-02-16 10:17:28 +08:00
|
|
|
|
public bool Expanded
|
|
|
|
|
{
|
|
|
|
|
get { return expanded; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (expanded == value) return;
|
|
|
|
|
expanded = value;
|
|
|
|
|
|
|
|
|
|
content.ClearTransforms();
|
|
|
|
|
|
|
|
|
|
if (expanded)
|
|
|
|
|
content.AutoSizeAxes = Axes.Y;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
content.AutoSizeAxes = Axes.None;
|
|
|
|
|
content.ResizeHeightTo(0, transition_duration, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button.FadeColour(expanded ? buttonActiveColour : Color4.White, 200, Easing.OutQuint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-23 21:01:00 +08:00
|
|
|
|
private Color4 buttonActiveColour;
|
2017-05-21 23:22:27 +08:00
|
|
|
|
|
2018-01-16 01:52:52 +08:00
|
|
|
|
protected PlayerSettingsGroup()
|
2017-05-17 15:36:57 +08:00
|
|
|
|
{
|
2017-05-17 20:39:26 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
2017-05-19 11:39:39 +08:00
|
|
|
|
Width = container_width;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
Masking = true;
|
2017-05-19 11:39:39 +08:00
|
|
|
|
CornerRadius = corner_radius;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
BorderColour = Color4.Black;
|
2017-05-19 11:39:39 +08:00
|
|
|
|
BorderThickness = border_thickness;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
|
2017-05-30 00:00:29 +08:00
|
|
|
|
InternalChildren = new Drawable[]
|
2017-05-17 15:36:57 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black,
|
|
|
|
|
Alpha = 0.5f,
|
|
|
|
|
},
|
2017-05-17 20:39:26 +08:00
|
|
|
|
new FillFlowContainer
|
2017-05-17 15:36:57 +08:00
|
|
|
|
{
|
2017-05-17 20:39:26 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-17 22:14:09 +08:00
|
|
|
|
new Container
|
2017-05-17 20:39:26 +08:00
|
|
|
|
{
|
2017-05-21 23:22:27 +08:00
|
|
|
|
Name = @"Header",
|
2017-05-17 20:39:26 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-05-30 00:00:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = header_height,
|
2017-05-17 20:39:26 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
2017-05-28 05:56:11 +08:00
|
|
|
|
Text = Title.ToUpper(),
|
2017-05-17 20:39:26 +08:00
|
|
|
|
TextSize = 17,
|
|
|
|
|
Font = @"Exo2.0-Bold",
|
|
|
|
|
Margin = new MarginPadding { Left = 10 },
|
|
|
|
|
},
|
2017-05-30 17:23:53 +08:00
|
|
|
|
button = new IconButton
|
2017-05-17 20:39:26 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
2017-06-08 14:35:10 +08:00
|
|
|
|
Position = new Vector2(-15, 0),
|
2017-05-17 20:39:26 +08:00
|
|
|
|
Icon = FontAwesome.fa_bars,
|
2017-05-21 23:22:27 +08:00
|
|
|
|
Scale = new Vector2(0.75f),
|
2018-02-16 10:17:28 +08:00
|
|
|
|
Action = () => Expanded = !Expanded,
|
2017-05-17 20:39:26 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-05-19 01:21:58 +08:00
|
|
|
|
content = new FillFlowContainer
|
2017-05-17 20:39:26 +08:00
|
|
|
|
{
|
2017-05-21 23:22:27 +08:00
|
|
|
|
Name = @"Content",
|
2017-05-30 00:00:29 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-05-19 01:21:58 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-05-17 20:39:26 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-05-19 11:26:54 +08:00
|
|
|
|
AutoSizeDuration = transition_duration,
|
2017-07-23 02:50:25 +08:00
|
|
|
|
AutoSizeEasing = Easing.OutQuint,
|
2017-05-23 21:01:00 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-05-19 01:21:58 +08:00
|
|
|
|
Padding = new MarginPadding(15),
|
2017-05-21 23:22:27 +08:00
|
|
|
|
Spacing = new Vector2(0, 15),
|
2017-05-17 20:39:26 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-17 15:36:57 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
2017-05-18 12:09:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 17:23:53 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
button.Colour = buttonActiveColour = colours.Yellow;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-30 00:00:29 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
2018-03-08 17:16:23 +08:00
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state) => true;
|
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) => true;
|
2017-05-17 15:36:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|