1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 21:27:23 +08:00
osu-lazer/osu.Game/Overlays/Settings/SettingsSubsection.cs

72 lines
2.5 KiB
C#
Raw Normal View History

// 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
2018-11-20 15:51:59 +08:00
using osuTK;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Game.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings
{
[ExcludeFromDynamicCompile]
2018-04-13 17:19:50 +08:00
public abstract class SettingsSubsection : FillFlowContainer, IHasFilterableChildren
{
protected override Container<Drawable> Content => FlowContent;
protected readonly FillFlowContainer FlowContent;
protected abstract LocalisableString Header { get; }
2018-04-13 17:19:50 +08:00
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
// FilterTerms should contains both original string and localised string for user to search.
// Since LocalisableString is unable to get original string at this time (2021-08-14),
// only call .ToString() to use localised one.
// TODO: Update here when FilterTerms accept LocalisableString.
public virtual IEnumerable<string> FilterTerms => new[] { Header.ToString() };
2019-02-28 12:31:40 +08:00
2018-04-13 17:19:50 +08:00
public bool MatchingFilter
{
set => this.FadeTo(value ? 1 : 0);
2018-04-13 17:19:50 +08:00
}
2019-03-28 23:29:07 +08:00
public bool FilteringActive { get; set; }
2018-04-13 17:19:50 +08:00
protected SettingsSubsection()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
FlowContent = new FillFlowContainer
{
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 8),
2018-04-13 17:19:50 +08:00
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
};
}
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Drawable[]
{
new OsuSpriteText
{
Text = Header.ToString().ToUpper(), // TODO: Add localisation support after https://github.com/ppy/osu-framework/pull/4603 is merged.
Margin = new MarginPadding { Vertical = 30, Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS },
2020-03-17 07:32:25 +08:00
Font = OsuFont.GetFont(weight: FontWeight.Bold),
2018-04-13 17:19:50 +08:00
},
FlowContent
});
}
}
}