1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 14:42:56 +08:00
This commit is contained in:
smoogipoo 2021-07-13 16:51:29 +09:00
parent 0cb80e105b
commit b5d4b9444f
2 changed files with 35 additions and 45 deletions

View File

@ -5,19 +5,21 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osuTK.Graphics;
using osuTK;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
public abstract class FilterControl : CompositeDrawable
{
protected const float VERTICAL_PADDING = 10;
protected const float HORIZONTAL_PADDING = 80;
protected const float HORIZONTAL_PADDING = 20;
protected readonly FillFlowContainer Filters;
[Resolved(CanBeNull = true)]
private Bindable<FilterCriteria> filter { get; set; }
@ -25,60 +27,50 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private readonly Box tabStrip;
private readonly SearchTextBox search;
private readonly PageTabControl<RoomStatusFilter> tabs;
private readonly Dropdown<RoomStatusFilter> statusDropdown;
protected FilterControl()
{
InternalChildren = new Drawable[]
InternalChild = new Container
{
new Box
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Alpha = 0.25f,
Top = VERTICAL_PADDING,
Horizontal = HORIZONTAL_PADDING
},
tabStrip = new Box
Children = new Drawable[]
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
search = new FilterSearchTextBox
{
Top = VERTICAL_PADDING,
Horizontal = HORIZONTAL_PADDING
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
Width = 0.6f,
},
Children = new Drawable[]
Filters = new FillFlowContainer
{
search = new FilterSearchTextBox
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10),
Padding = new MarginPadding { Vertical = 30 },
Child = statusDropdown = new SlimEnumDropdown<RoomStatusFilter>
{
RelativeSizeAxes = Axes.X,
},
tabs = new PageTabControl<RoomStatusFilter>
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
},
}
Anchor = Anchor.BottomRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.None,
Width = 160,
}
},
}
};
tabs.Current.Value = RoomStatusFilter.Open;
tabs.Current.TriggerChange();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
filter ??= new Bindable<FilterCriteria>();
tabStrip.Colour = colours.Yellow;
}
protected override void LoadComplete()
@ -87,7 +79,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
search.Current.BindValueChanged(_ => updateFilterDebounced());
ruleset.BindValueChanged(_ => UpdateFilter());
tabs.Current.BindValueChanged(_ => UpdateFilter(), true);
statusDropdown.Current.BindValueChanged(_ => UpdateFilter(), true);
}
private ScheduledDelegate scheduledFilterUpdate;
@ -106,7 +98,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
var criteria = CreateCriteria();
criteria.SearchString = search.Current.Value;
criteria.Status = tabs.Current.Value;
criteria.Status = statusDropdown.Current.Value;
criteria.Ruleset = ruleset.Value;
filter.Value = criteria;

View File

@ -9,18 +9,16 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
public class PlaylistsFilterControl : FilterControl
{
private readonly Dropdown<PlaylistsCategory> dropdown;
private readonly Dropdown<PlaylistsCategory> categoryDropdown;
public PlaylistsFilterControl()
{
AddInternal(dropdown = new SlimEnumDropdown<PlaylistsCategory>
Filters.Add(categoryDropdown = new SlimEnumDropdown<PlaylistsCategory>
{
Anchor = Anchor.BottomRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.None,
Width = 160,
X = -HORIZONTAL_PADDING,
Y = -30
});
}
@ -28,14 +26,14 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
base.LoadComplete();
dropdown.Current.BindValueChanged(_ => UpdateFilter());
categoryDropdown.Current.BindValueChanged(_ => UpdateFilter());
}
protected override FilterCriteria CreateCriteria()
{
var criteria = base.CreateCriteria();
switch (dropdown.Current.Value)
switch (categoryDropdown.Current.Value)
{
case PlaylistsCategory.Normal:
criteria.Category = "normal";