2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-11-30 08:57:25 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
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;
|
2020-11-30 08:57:25 +00:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings
|
|
|
|
|
{
|
|
|
|
|
public abstract class SettingsSection : Container, IHasFilterableChildren
|
|
|
|
|
{
|
|
|
|
|
protected FillFlowContainer FlowContent;
|
|
|
|
|
protected override Container<Drawable> Content => FlowContent;
|
|
|
|
|
|
2020-04-25 18:35:46 +00:00
|
|
|
|
public abstract Drawable CreateIcon();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public abstract string Header { get; }
|
|
|
|
|
|
|
|
|
|
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
2019-11-20 21:26:39 +00:00
|
|
|
|
public virtual IEnumerable<string> FilterTerms => new[] { Header };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
private const int header_size = 26;
|
2020-11-30 08:43:53 +00:00
|
|
|
|
private const int margin = 20;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private const int border_size = 2;
|
|
|
|
|
|
|
|
|
|
public bool MatchingFilter
|
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
set => this.FadeTo(value ? 1 : 0);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-28 15:29:07 +00:00
|
|
|
|
public bool FilteringActive { get; set; }
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
protected SettingsSection()
|
|
|
|
|
{
|
2020-11-30 08:43:53 +00:00
|
|
|
|
Margin = new MarginPadding { Top = margin };
|
2018-04-13 09:19:50 +00:00
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
|
|
|
|
|
FlowContent = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
2020-11-30 08:43:53 +00:00
|
|
|
|
Top = header_size
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
Colour = new Color4(0, 0, 0, 255),
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = border_size,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
2020-11-30 08:43:53 +00:00
|
|
|
|
Top = margin + border_size,
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Bottom = 10,
|
|
|
|
|
},
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2018-09-05 05:59:37 +00:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2019-02-12 04:04:46 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: header_size),
|
2018-04-13 09:19:50 +00:00
|
|
|
|
Text = Header,
|
|
|
|
|
Colour = colours.Yellow,
|
2020-11-30 08:43:53 +00:00
|
|
|
|
Margin = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Left = SettingsPanel.CONTENT_MARGINS,
|
|
|
|
|
Right = SettingsPanel.CONTENT_MARGINS
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
},
|
|
|
|
|
FlowContent
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|