1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 14:02:55 +08:00
osu-lazer/osu.Game/Overlays/Settings/SettingsSection.cs

92 lines
3.0 KiB
C#
Raw Normal View History

2017-05-09 00:30:00 +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
2016-12-06 17:56:20 +08:00
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2017-05-09 00:30:00 +08:00
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Overlays.Settings
{
public abstract class SettingsSection : Container, IHasFilterableChildren
{
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;
public abstract FontAwesome Icon { get; }
2016-11-09 12:16:04 +08:00
public abstract string Header { get; }
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
public IEnumerable<string> FilterTerms => new[] { Header };
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
{
set { this.FadeTo(value ? 1 : 0); }
}
protected SettingsSection()
{
2016-11-15 15:55:23 +08:00
Margin = new MarginPadding { Top = 20 };
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
2017-02-07 15:15:45 +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[]
{
new Box
{
2016-11-15 15:55:23 +08:00
Colour = new Color4(0, 0, 0, 255),
RelativeSizeAxes = Axes.X,
2017-02-07 15:15:45 +08:00
Height = border_size,
},
new Container
{
Padding = new MarginPadding
{
2017-02-07 15:15:45 +08:00
Top = 20 + border_size,
Bottom = 10,
},
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new[]
{
new OsuSpriteText
{
2017-02-07 15:15:45 +08:00
TextSize = header_size,
Text = Header,
Colour = colours.Yellow,
Margin = new MarginPadding { Left = SettingsOverlay.CONTENT_MARGINS, Right = SettingsOverlay.CONTENT_MARGINS }
},
FlowContent
}
},
});
}
}
}