2017-05-09 00:30:00 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-12-06 17:56:20 +08:00
|
|
|
|
|
|
|
|
|
using OpenTK;
|
2016-11-03 12:45:16 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2017-01-13 12:49:05 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-11-03 12:45:16 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2016-11-08 07:04:49 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-09 00:30:00 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-08 02:35:57 +08:00
|
|
|
|
using System.Linq;
|
2016-11-03 12:45:16 +08:00
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Settings
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
2017-05-15 09:55:29 +08:00
|
|
|
|
public abstract class SettingsSection : Container, IHasFilterableChildren
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
2017-03-02 02:33:01 +08:00
|
|
|
|
protected FillFlowContainer FlowContent;
|
2017-02-07 15:15:45 +08:00
|
|
|
|
protected override Container<Drawable> Content => FlowContent;
|
2016-11-03 12:45:16 +08:00
|
|
|
|
|
2016-11-08 07:04:49 +08:00
|
|
|
|
public abstract FontAwesome Icon { get; }
|
2016-11-09 12:16:04 +08:00
|
|
|
|
public abstract string Header { get; }
|
2016-11-03 12:45:16 +08:00
|
|
|
|
|
2017-05-08 02:35:57 +08:00
|
|
|
|
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
|
|
|
|
public string[] FilterTerms => new[] { Header };
|
2017-08-14 13:40:48 +08:00
|
|
|
|
|
|
|
|
|
private const int header_size = 26;
|
|
|
|
|
private const int header_margin = 25;
|
|
|
|
|
private const int border_size = 2;
|
|
|
|
|
|
2017-05-30 15:33:26 +08:00
|
|
|
|
public bool MatchingFilter
|
2017-05-08 02:35:57 +08:00
|
|
|
|
{
|
2017-08-14 13:40:48 +08:00
|
|
|
|
set { this.FadeTo(value ? 1 : 0); }
|
2017-05-08 02:35:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
protected SettingsSection()
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
2016-11-15 15:55:23 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 20 };
|
2016-11-03 12:45:16 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2017-02-07 15:15:45 +08:00
|
|
|
|
|
2017-08-14 13:40:48 +08:00
|
|
|
|
FlowContent = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = header_size + header_margin
|
|
|
|
|
},
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 30),
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2017-07-11 21:58:06 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2016-11-15 15:55:23 +08:00
|
|
|
|
Colour = new Color4(0, 0, 0, 255),
|
2016-11-03 12:45:16 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-07 15:15:45 +08:00
|
|
|
|
Height = border_size,
|
2016-11-03 12:45:16 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
2017-02-07 15:15:45 +08:00
|
|
|
|
Top = 20 + border_size,
|
2017-05-15 09:55:29 +08:00
|
|
|
|
Left = SettingsOverlay.CONTENT_MARGINS,
|
|
|
|
|
Right = SettingsOverlay.CONTENT_MARGINS,
|
2016-11-03 12:45:16 +08:00
|
|
|
|
Bottom = 10,
|
|
|
|
|
},
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2017-08-14 13:40:48 +08:00
|
|
|
|
new OsuSpriteText
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
2017-02-07 15:15:45 +08:00
|
|
|
|
TextSize = header_size,
|
2016-11-04 11:01:11 +08:00
|
|
|
|
Text = Header,
|
2017-08-14 13:40:48 +08:00
|
|
|
|
Colour = colours.Yellow
|
2016-11-03 12:45:16 +08:00
|
|
|
|
},
|
2017-08-14 13:40:48 +08:00
|
|
|
|
FlowContent
|
2016-11-03 12:45:16 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-14 13:40:48 +08:00
|
|
|
|
}
|