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-03 12:45:16 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
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-05-30 15:33:26 +08:00
|
|
|
|
public bool MatchingFilter
|
2017-05-08 02:35:57 +08:00
|
|
|
|
{
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
FadeTo(value ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly SpriteText headerLabel;
|
2017-01-13 12:49:05 +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
|
|
|
|
|
|
|
|
|
const int header_size = 26;
|
|
|
|
|
const int header_margin = 25;
|
|
|
|
|
const int border_size = 2;
|
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-01-31 17:53:52 +08:00
|
|
|
|
headerLabel = 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,
|
2016-11-03 12:45:16 +08:00
|
|
|
|
},
|
2017-03-02 02:33:01 +08:00
|
|
|
|
FlowContent = new FillFlowContainer
|
2016-11-03 12:45:16 +08:00
|
|
|
|
{
|
2017-02-07 15:15:45 +08:00
|
|
|
|
Margin = new MarginPadding { Top = header_size + header_margin },
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2017-03-02 02:33:01 +08:00
|
|
|
|
Spacing = new Vector2(0, 30),
|
2016-11-03 12:45:16 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-04-06 16:21:18 +08:00
|
|
|
|
|
2017-01-13 12:49:05 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
2017-01-31 18:58:22 +08:00
|
|
|
|
headerLabel.Colour = colours.Yellow;
|
2017-01-13 12:49:05 +08:00
|
|
|
|
}
|
2016-11-03 12:45:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|