2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-08 02:35:57 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2017-08-23 11:48:53 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-07-15 11:50:34 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-03-16 14:57:06 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2019-02-12 12:04:46 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Settings
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
2021-03-16 14:57:06 +08:00
|
|
|
|
[ExcludeFromDynamicCompile]
|
2017-05-15 09:55:29 +08:00
|
|
|
|
public abstract class SettingsSubsection : FillFlowContainer, IHasFilterableChildren
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
2017-08-23 11:48:53 +08:00
|
|
|
|
protected override Container<Drawable> Content => FlowContent;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-23 11:48:53 +08:00
|
|
|
|
protected readonly FillFlowContainer FlowContent;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-07-15 11:50:34 +08:00
|
|
|
|
protected abstract LocalisableString Header { get; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-08 02:35:57 +08:00
|
|
|
|
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
|
2021-08-14 21:52:09 +08:00
|
|
|
|
|
2022-05-16 13:09:37 +08:00
|
|
|
|
public virtual IEnumerable<LocalisableString> FilterTerms => new[] { Header };
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2017-05-30 15:33:26 +08:00
|
|
|
|
public bool MatchingFilter
|
2017-05-08 02:35:57 +08:00
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
set => this.FadeTo(value ? 1 : 0);
|
2017-05-08 02:35:57 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-03-28 23:29:07 +08:00
|
|
|
|
public bool FilteringActive { get; set; }
|
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
protected SettingsSubsection()
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
2017-03-04 18:00:17 +08:00
|
|
|
|
Direction = FillDirection.Vertical;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-08-23 11:48:53 +08:00
|
|
|
|
FlowContent = new FillFlowContainer
|
|
|
|
|
{
|
2021-10-10 01:54:20 +08:00
|
|
|
|
Margin = new MarginPadding { Top = SettingsSection.ITEM_SPACING },
|
2017-08-23 11:48:53 +08:00
|
|
|
|
Direction = FillDirection.Vertical,
|
2021-10-10 01:54:20 +08:00
|
|
|
|
Spacing = new Vector2(0, SettingsSection.ITEM_SPACING),
|
2017-08-23 11:48:53 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-10 01:54:20 +08:00
|
|
|
|
private const int header_height = 43;
|
|
|
|
|
private const int header_font_size = 20;
|
|
|
|
|
|
2017-08-23 11:48:53 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2017-07-11 21:58:06 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2021-10-10 01:54:20 +08:00
|
|
|
|
Text = Header,
|
|
|
|
|
Margin = new MarginPadding { Vertical = (header_height - header_font_size) * 0.5f, Horizontal = SettingsPanel.CONTENT_MARGINS },
|
|
|
|
|
Font = OsuFont.GetFont(size: header_font_size),
|
2017-02-07 12:52:19 +08:00
|
|
|
|
},
|
2017-08-23 11:48:53 +08:00
|
|
|
|
FlowContent
|
2017-02-07 12:52:19 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|