1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 06:13:04 +08:00

Merge pull request #9469 from peppy/song-select-filter-control

Clean up song select filter control UI
This commit is contained in:
Dan Balasescu 2020-07-09 14:59:47 +09:00 committed by GitHub
commit 280d9f3532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 68 deletions

View File

@ -23,6 +23,8 @@ namespace osu.Game.Graphics.UserInterface
{ {
private Color4 accentColour; private Color4 accentColour;
public const float HORIZONTAL_SPACING = 10;
public virtual Color4 AccentColour public virtual Color4 AccentColour
{ {
get => accentColour; get => accentColour;
@ -54,7 +56,7 @@ namespace osu.Game.Graphics.UserInterface
public OsuTabControl() public OsuTabControl()
{ {
TabContainer.Spacing = new Vector2(10f, 0f); TabContainer.Spacing = new Vector2(HORIZONTAL_SPACING, 0f);
AddInternal(strip = new Box AddInternal(strip = new Box
{ {

View File

@ -2,21 +2,20 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Select.Filter;
using Container = osu.Framework.Graphics.Containers.Container;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Configuration;
using osu.Game.Rulesets;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Screens.Select.Filter;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Select namespace osu.Game.Screens.Select
{ {
@ -26,9 +25,7 @@ namespace osu.Game.Screens.Select
public Action<FilterCriteria> FilterChanged; public Action<FilterCriteria> FilterChanged;
private readonly OsuTabControl<SortMode> sortTabs; private OsuTabControl<SortMode> sortTabs;
private readonly TabControl<GroupMode> groupTabs;
private Bindable<SortMode> sortMode; private Bindable<SortMode> sortMode;
@ -56,19 +53,39 @@ namespace osu.Game.Screens.Select
return criteria; return criteria;
} }
private readonly SeekLimitedSearchTextBox searchTextBox; private SeekLimitedSearchTextBox searchTextBox;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) =>
base.ReceivePositionalInputAt(screenSpacePos) || groupTabs.ReceivePositionalInputAt(screenSpacePos) || sortTabs.ReceivePositionalInputAt(screenSpacePos); base.ReceivePositionalInputAt(screenSpacePos) || sortTabs.ReceivePositionalInputAt(screenSpacePos);
public FilterControl() [BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, IBindable<RulesetInfo> parentRuleset, OsuConfigManager config)
{ {
config.BindWith(OsuSetting.ShowConvertedBeatmaps, showConverted);
showConverted.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMinimum, minimumStars);
minimumStars.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMaximum, maximumStars);
maximumStars.ValueChanged += _ => updateCriteria();
ruleset.BindTo(parentRuleset);
ruleset.BindValueChanged(_ => updateCriteria());
sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
groupMode = config.GetBindable<GroupMode>(OsuSetting.SongSelectGroupingMode);
groupMode.BindValueChanged(_ => updateCriteria());
sortMode.BindValueChanged(_ => updateCriteria());
Children = new Drawable[] Children = new Drawable[]
{ {
Background = new Box new Box
{ {
Colour = Color4.Black, Colour = Color4.Black,
Alpha = 0.8f, Alpha = 0.8f,
Width = 2,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
new Container new Container
@ -96,33 +113,35 @@ namespace osu.Game.Screens.Select
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Spacing = new Vector2(OsuTabControl<SortMode>.HORIZONTAL_SPACING, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
groupTabs = new OsuTabControl<GroupMode> new OsuTabControlCheckbox
{ {
RelativeSizeAxes = Axes.X, Text = "Show converted",
Height = 24, Current = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps),
Width = 0.5f, Anchor = Anchor.BottomRight,
AutoSort = true, Origin = Anchor.BottomRight,
}, },
//spriteText = new OsuSpriteText
//{
// Font = @"Exo2.0-Bold",
// Text = "Sort results by",
// Size = 14,
// Margin = new MarginPadding
// {
// Top = 5,
// Bottom = 5
// },
//},
sortTabs = new OsuTabControl<SortMode> sortTabs = new OsuTabControl<SortMode>
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Width = 0.5f, Width = 0.5f,
Height = 24, Height = 24,
AutoSort = true, AutoSort = true,
} Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
AccentColour = colours.GreenLight,
Current = { BindTarget = sortMode }
},
new OsuSpriteText
{
Text = "Sort by",
Font = OsuFont.GetFont(size: 14),
Margin = new MarginPadding(5),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
} }
}, },
} }
@ -131,8 +150,7 @@ namespace osu.Game.Screens.Select
searchTextBox.Current.ValueChanged += _ => FilterChanged?.Invoke(CreateCriteria()); searchTextBox.Current.ValueChanged += _ => FilterChanged?.Invoke(CreateCriteria());
groupTabs.PinItem(GroupMode.All); updateCriteria();
groupTabs.PinItem(GroupMode.RecentlyPlayed);
} }
public void Deactivate() public void Deactivate()
@ -156,37 +174,6 @@ namespace osu.Game.Screens.Select
private readonly Bindable<double> minimumStars = new BindableDouble(); private readonly Bindable<double> minimumStars = new BindableDouble();
private readonly Bindable<double> maximumStars = new BindableDouble(); private readonly Bindable<double> maximumStars = new BindableDouble();
public readonly Box Background;
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuColour colours, IBindable<RulesetInfo> parentRuleset, OsuConfigManager config)
{
sortTabs.AccentColour = colours.GreenLight;
config.BindWith(OsuSetting.ShowConvertedBeatmaps, showConverted);
showConverted.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMinimum, minimumStars);
minimumStars.ValueChanged += _ => updateCriteria();
config.BindWith(OsuSetting.DisplayStarsMaximum, maximumStars);
maximumStars.ValueChanged += _ => updateCriteria();
ruleset.BindTo(parentRuleset);
ruleset.BindValueChanged(_ => updateCriteria());
sortMode = config.GetBindable<SortMode>(OsuSetting.SongSelectSortingMode);
groupMode = config.GetBindable<GroupMode>(OsuSetting.SongSelectGroupingMode);
sortTabs.Current.BindTo(sortMode);
groupTabs.Current.BindTo(groupMode);
groupMode.BindValueChanged(_ => updateCriteria());
sortMode.BindValueChanged(_ => updateCriteria());
updateCriteria();
}
private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria());
protected override bool OnClick(ClickEvent e) => true; protected override bool OnClick(ClickEvent e) => true;

View File

@ -173,7 +173,6 @@ namespace osu.Game.Screens.Select
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = FilterControl.HEIGHT, Height = FilterControl.HEIGHT,
FilterChanged = ApplyFilterToCarousel, FilterChanged = ApplyFilterToCarousel,
Background = { Width = 2 },
}, },
new GridContainer // used for max width implementation new GridContainer // used for max width implementation
{ {