mirror of
https://github.com/osukey/osukey.git
synced 2025-05-21 05:27:17 +09:00
Implement category dropdown for multiplayer
This commit is contained in:
parent
ed926de77f
commit
926279e39b
@ -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();
|
||||||
{
|
|
||||||
string target = "rooms";
|
|
||||||
|
|
||||||
switch (primaryFilter)
|
switch (statusFilter)
|
||||||
{
|
{
|
||||||
case PrimaryFilter.Open:
|
case RoomStatusFilter.Owned:
|
||||||
|
req.AddParameter("mode", "owned");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PrimaryFilter.Owned:
|
case RoomStatusFilter.Participated:
|
||||||
target += "/owned";
|
req.AddParameter("mode", "participated");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PrimaryFilter.Participated:
|
case RoomStatusFilter.RecentlyEnded:
|
||||||
target += "/participated";
|
req.AddParameter("mode", "ended");
|
||||||
break;
|
|
||||||
|
|
||||||
case PrimaryFilter.RecentlyEnded:
|
|
||||||
target += "/ended";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
switch (categoryFilter)
|
||||||
}
|
{
|
||||||
}
|
case RoomCategoryFilter.Spotlight:
|
||||||
|
req.AddParameter("category", "spotlight");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => "rooms";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.Normal;
|
||||||
|
|
||||||
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,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
|||||||
Owned,
|
Owned,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SecondaryFilter
|
public enum RoomCategoryFilter
|
||||||
{
|
{
|
||||||
Public,
|
Normal,
|
||||||
//Private,
|
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