mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 22:27:23 +08:00
Merge pull request #9491 from smoogipoo/multiplayer-categories
This commit is contained in:
commit
285da83f1b
osu.Game.Tests/Visual/Multiplayer
osu.Game
Online/API/Requests
Overlays
Screens/Multi
@ -0,0 +1,20 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Multiplayer
|
||||||
|
{
|
||||||
|
public class TestSceneLoungeFilterControl : OsuTestScene
|
||||||
|
{
|
||||||
|
public TestSceneLoungeFilterControl()
|
||||||
|
{
|
||||||
|
Child = new FilterControl
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
// 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.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.IO.Network;
|
||||||
using osu.Game.Online.Multiplayer;
|
using osu.Game.Online.Multiplayer;
|
||||||
using osu.Game.Screens.Multi.Lounge.Components;
|
using osu.Game.Screens.Multi.Lounge.Components;
|
||||||
|
|
||||||
@ -9,39 +10,44 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetRoomsRequest : APIRequest<List<Room>>
|
public class GetRoomsRequest : APIRequest<List<Room>>
|
||||||
{
|
{
|
||||||
private readonly PrimaryFilter primaryFilter;
|
private readonly RoomStatusFilter statusFilter;
|
||||||
|
private readonly RoomCategoryFilter categoryFilter;
|
||||||
|
|
||||||
public GetRoomsRequest(PrimaryFilter primaryFilter)
|
public GetRoomsRequest(RoomStatusFilter statusFilter, RoomCategoryFilter categoryFilter)
|
||||||
{
|
{
|
||||||
this.primaryFilter = primaryFilter;
|
this.statusFilter = statusFilter;
|
||||||
|
this.categoryFilter = categoryFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target
|
protected override WebRequest CreateWebRequest()
|
||||||
{
|
{
|
||||||
get
|
var req = base.CreateWebRequest();
|
||||||
|
|
||||||
|
switch (statusFilter)
|
||||||
{
|
{
|
||||||
string target = "rooms";
|
case RoomStatusFilter.Owned:
|
||||||
|
req.AddParameter("mode", "owned");
|
||||||
|
break;
|
||||||
|
|
||||||
switch (primaryFilter)
|
case RoomStatusFilter.Participated:
|
||||||
{
|
req.AddParameter("mode", "participated");
|
||||||
case PrimaryFilter.Open:
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case PrimaryFilter.Owned:
|
case RoomStatusFilter.RecentlyEnded:
|
||||||
target += "/owned";
|
req.AddParameter("mode", "ended");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PrimaryFilter.Participated:
|
|
||||||
target += "/participated";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PrimaryFilter.RecentlyEnded:
|
|
||||||
target += "/ended";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (categoryFilter)
|
||||||
|
{
|
||||||
|
case RoomCategoryFilter.Spotlight:
|
||||||
|
req.AddParameter("category", "spotlight");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override string Target => "rooms";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -11,44 +10,23 @@ using osu.Game.Graphics.Containers;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.SearchableList
|
namespace osu.Game.Overlays.SearchableList
|
||||||
{
|
{
|
||||||
public class DisplayStyleControl<T> : Container
|
public class DisplayStyleControl : CompositeDrawable
|
||||||
where T : struct, Enum
|
|
||||||
{
|
{
|
||||||
public readonly SlimEnumDropdown<T> Dropdown;
|
|
||||||
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();
|
public readonly Bindable<PanelDisplayStyle> DisplayStyle = new Bindable<PanelDisplayStyle>();
|
||||||
|
|
||||||
public DisplayStyleControl()
|
public DisplayStyleControl()
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
Children = new[]
|
InternalChild = new FillFlowContainer
|
||||||
{
|
{
|
||||||
new FillFlowContainer
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Spacing = new Vector2(5f, 0f),
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new[]
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
new DisplayStyleToggleButton(FontAwesome.Solid.ThLarge, PanelDisplayStyle.Grid, DisplayStyle),
|
||||||
Anchor = Anchor.TopRight,
|
new DisplayStyleToggleButton(FontAwesome.Solid.ListUl, PanelDisplayStyle.List, DisplayStyle),
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Spacing = new Vector2(10f, 0f),
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new FillFlowContainer
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both,
|
|
||||||
Spacing = new Vector2(5f, 0f),
|
|
||||||
Direction = FillDirection.Horizontal,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
new DisplayStyleToggleButton(FontAwesome.Solid.ThLarge, PanelDisplayStyle.Grid, DisplayStyle),
|
|
||||||
new DisplayStyleToggleButton(FontAwesome.Solid.ListUl, PanelDisplayStyle.List, DisplayStyle),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Dropdown = new SlimEnumDropdown<T>
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.None,
|
|
||||||
Width = 160f,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,12 +19,14 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
{
|
{
|
||||||
private const float padding = 10;
|
private const float padding = 10;
|
||||||
|
|
||||||
private readonly Container filterContainer;
|
private readonly Drawable filterContainer;
|
||||||
|
private readonly Drawable rightFilterContainer;
|
||||||
private readonly Box tabStrip;
|
private readonly Box tabStrip;
|
||||||
|
|
||||||
public readonly SearchTextBox Search;
|
public readonly SearchTextBox Search;
|
||||||
public readonly PageTabControl<TTab> Tabs;
|
public readonly PageTabControl<TTab> Tabs;
|
||||||
public readonly DisplayStyleControl<TCategory> DisplayStyleControl;
|
public readonly SlimEnumDropdown<TCategory> Dropdown;
|
||||||
|
public readonly DisplayStyleControl DisplayStyleControl;
|
||||||
|
|
||||||
protected abstract Color4 BackgroundColour { get; }
|
protected abstract Color4 BackgroundColour { get; }
|
||||||
protected abstract TTab DefaultTab { get; }
|
protected abstract TTab DefaultTab { get; }
|
||||||
@ -42,7 +44,7 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
|
|
||||||
var controls = CreateSupplementaryControls();
|
var controls = CreateSupplementaryControls();
|
||||||
Container controlsContainer;
|
Container controlsContainer;
|
||||||
Children = new Drawable[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
filterContainer = new Container
|
filterContainer = new Container
|
||||||
{
|
{
|
||||||
@ -104,11 +106,27 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DisplayStyleControl = new DisplayStyleControl<TCategory>
|
rightFilterContainer = new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
},
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
Dropdown = new SlimEnumDropdown<TCategory>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
RelativeSizeAxes = Axes.None,
|
||||||
|
Width = 160f,
|
||||||
|
},
|
||||||
|
DisplayStyleControl = new DisplayStyleControl
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (controls != null) controlsContainer.Children = new[] { controls };
|
if (controls != null) controlsContainer.Children = new[] { controls };
|
||||||
@ -116,8 +134,8 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
Tabs.Current.Value = DefaultTab;
|
Tabs.Current.Value = DefaultTab;
|
||||||
Tabs.Current.TriggerChange();
|
Tabs.Current.TriggerChange();
|
||||||
|
|
||||||
DisplayStyleControl.Dropdown.Current.Value = DefaultCategory;
|
Dropdown.Current.Value = DefaultCategory;
|
||||||
DisplayStyleControl.Dropdown.Current.TriggerChange();
|
Dropdown.Current.TriggerChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -131,7 +149,7 @@ namespace osu.Game.Overlays.SearchableList
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
Height = filterContainer.Height;
|
Height = filterContainer.Height;
|
||||||
DisplayStyleControl.Margin = new MarginPadding { Top = filterContainer.Height - 35, Right = SearchableListOverlay.WIDTH_PADDING };
|
rightFilterContainer.Margin = new MarginPadding { Top = filterContainer.Height - 30, Right = ContentHorizontalPadding };
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FilterSearchTextBox : SearchTextBox
|
private class FilterSearchTextBox : SearchTextBox
|
||||||
|
@ -72,7 +72,7 @@ namespace osu.Game.Overlays
|
|||||||
Filter.Tabs.Current.ValueChanged += _ => onFilterUpdate();
|
Filter.Tabs.Current.ValueChanged += _ => onFilterUpdate();
|
||||||
|
|
||||||
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += _ => recreatePanels();
|
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += _ => recreatePanels();
|
||||||
Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += _ => recreatePanels();
|
Filter.Dropdown.Current.ValueChanged += _ => recreatePanels();
|
||||||
|
|
||||||
currentQuery.BindTo(Filter.Search.Current);
|
currentQuery.BindTo(Filter.Search.Current);
|
||||||
currentQuery.ValueChanged += query =>
|
currentQuery.ValueChanged += query =>
|
||||||
@ -155,7 +155,7 @@ namespace osu.Game.Overlays
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Filter.DisplayStyleControl.Dropdown.Current.Value == SortDirection.Descending)
|
if (Filter.Dropdown.Current.Value == SortDirection.Descending)
|
||||||
sortedUsers = sortedUsers.Reverse();
|
sortedUsers = sortedUsers.Reverse();
|
||||||
|
|
||||||
var newPanels = new FillFlowContainer<UserPanel>
|
var newPanels = new FillFlowContainer<UserPanel>
|
||||||
|
@ -12,11 +12,11 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Multi.Lounge.Components
|
namespace osu.Game.Screens.Multi.Lounge.Components
|
||||||
{
|
{
|
||||||
public class FilterControl : SearchableListFilterControl<PrimaryFilter, SecondaryFilter>
|
public class FilterControl : SearchableListFilterControl<RoomStatusFilter, RoomCategoryFilter>
|
||||||
{
|
{
|
||||||
protected override Color4 BackgroundColour => Color4.Black.Opacity(0.5f);
|
protected override Color4 BackgroundColour => Color4.Black.Opacity(0.5f);
|
||||||
protected override PrimaryFilter DefaultTab => PrimaryFilter.Open;
|
protected override RoomStatusFilter DefaultTab => RoomStatusFilter.Open;
|
||||||
protected override SecondaryFilter DefaultCategory => SecondaryFilter.Public;
|
protected override RoomCategoryFilter DefaultCategory => RoomCategoryFilter.Any;
|
||||||
|
|
||||||
protected override float ContentHorizontalPadding => base.ContentHorizontalPadding + OsuScreen.HORIZONTAL_OVERFLOW_PADDING;
|
protected override float ContentHorizontalPadding => base.ContentHorizontalPadding + OsuScreen.HORIZONTAL_OVERFLOW_PADDING;
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
|
|
||||||
ruleset.BindValueChanged(_ => updateFilter());
|
ruleset.BindValueChanged(_ => updateFilter());
|
||||||
Search.Current.BindValueChanged(_ => scheduleUpdateFilter());
|
Search.Current.BindValueChanged(_ => scheduleUpdateFilter());
|
||||||
|
Dropdown.Current.BindValueChanged(_ => updateFilter());
|
||||||
Tabs.Current.BindValueChanged(_ => updateFilter(), true);
|
Tabs.Current.BindValueChanged(_ => updateFilter(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,14 +62,14 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
filter.Value = new FilterCriteria
|
filter.Value = new FilterCriteria
|
||||||
{
|
{
|
||||||
SearchString = Search.Current.Value ?? string.Empty,
|
SearchString = Search.Current.Value ?? string.Empty,
|
||||||
PrimaryFilter = Tabs.Current.Value,
|
StatusFilter = Tabs.Current.Value,
|
||||||
SecondaryFilter = DisplayStyleControl.Dropdown.Current.Value,
|
RoomCategoryFilter = Dropdown.Current.Value,
|
||||||
Ruleset = ruleset.Value
|
Ruleset = ruleset.Value
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PrimaryFilter
|
public enum RoomStatusFilter
|
||||||
{
|
{
|
||||||
Open,
|
Open,
|
||||||
|
|
||||||
@ -78,9 +79,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
Owned,
|
Owned,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SecondaryFilter
|
public enum RoomCategoryFilter
|
||||||
{
|
{
|
||||||
Public,
|
Any,
|
||||||
//Private,
|
Normal,
|
||||||
|
Spotlight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
public class FilterCriteria
|
public class FilterCriteria
|
||||||
{
|
{
|
||||||
public string SearchString;
|
public string SearchString;
|
||||||
public PrimaryFilter PrimaryFilter;
|
public RoomStatusFilter StatusFilter;
|
||||||
public SecondaryFilter SecondaryFilter;
|
public RoomCategoryFilter RoomCategoryFilter;
|
||||||
public RulesetInfo Ruleset;
|
public RulesetInfo Ruleset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,14 +77,6 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
if (!string.IsNullOrEmpty(criteria.SearchString))
|
if (!string.IsNullOrEmpty(criteria.SearchString))
|
||||||
matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0);
|
||||||
|
|
||||||
switch (criteria.SecondaryFilter)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case SecondaryFilter.Public:
|
|
||||||
matchingFilter &= r.Room.Availability.Value == RoomAvailability.Public;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
r.MatchingFilter = matchingFilter;
|
r.MatchingFilter = matchingFilter;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -318,7 +318,7 @@ namespace osu.Game.Screens.Multi
|
|||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
pollReq?.Cancel();
|
pollReq?.Cancel();
|
||||||
pollReq = new GetRoomsRequest(currentFilter.Value.PrimaryFilter);
|
pollReq = new GetRoomsRequest(currentFilter.Value.StatusFilter, currentFilter.Value.RoomCategoryFilter);
|
||||||
|
|
||||||
pollReq.Success += result =>
|
pollReq.Success += result =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user