mirror of
https://github.com/ppy/osu.git
synced 2025-03-21 12:47:44 +08:00
Implement TimeshiftFilterControl
This commit is contained in:
parent
1b3836aeef
commit
f599427080
@ -6,14 +6,17 @@ using osu.Game.Screens.Multi.Lounge.Components;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
public class TestSceneLoungeFilterControl : OsuTestScene
|
||||
public class TestSceneTimeshiftFilterControl : OsuTestScene
|
||||
{
|
||||
public TestSceneLoungeFilterControl()
|
||||
public TestSceneTimeshiftFilterControl()
|
||||
{
|
||||
Child = new FilterControl
|
||||
Child = new TimeshiftFilterControl
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Width = 0.7f,
|
||||
Height = 80,
|
||||
};
|
||||
}
|
||||
}
|
@ -11,24 +11,24 @@ namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
public class GetRoomsRequest : APIRequest<List<Room>>
|
||||
{
|
||||
private readonly RoomStatusFilter statusFilter;
|
||||
private readonly RoomCategoryFilter categoryFilter;
|
||||
private readonly RoomStatusFilter status;
|
||||
private readonly string category;
|
||||
|
||||
public GetRoomsRequest(RoomStatusFilter statusFilter, RoomCategoryFilter categoryFilter)
|
||||
public GetRoomsRequest(RoomStatusFilter status, string category)
|
||||
{
|
||||
this.statusFilter = statusFilter;
|
||||
this.categoryFilter = categoryFilter;
|
||||
this.status = status;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
if (statusFilter != RoomStatusFilter.Open)
|
||||
req.AddParameter("mode", statusFilter.ToString().Underscore().ToLowerInvariant());
|
||||
if (status != RoomStatusFilter.Open)
|
||||
req.AddParameter("mode", status.ToString().Underscore().ToLowerInvariant());
|
||||
|
||||
if (categoryFilter != RoomCategoryFilter.Any)
|
||||
req.AddParameter("category", categoryFilter.ToString().Underscore().ToLowerInvariant());
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
req.AddParameter("category", category);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
public class FilterCriteria
|
||||
{
|
||||
public string SearchString;
|
||||
public RoomStatusFilter StatusFilter;
|
||||
public RoomCategoryFilter RoomCategoryFilter;
|
||||
public RoomStatusFilter Status;
|
||||
public string Category;
|
||||
public RulesetInfo Ruleset;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
public enum RoomCategoryFilter
|
||||
{
|
||||
Any,
|
||||
Normal,
|
||||
Spotlight
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
// 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.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.SearchableList;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
{
|
||||
public class TimeshiftFilterControl : FilterControl
|
||||
{
|
||||
private readonly Dropdown<TimeshiftCategory> dropdown;
|
||||
|
||||
public TimeshiftFilterControl()
|
||||
{
|
||||
AddInternal(dropdown = new SlimEnumDropdown<TimeshiftCategory>
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 160,
|
||||
X = -HORIZONTAL_PADDING,
|
||||
Y = -30
|
||||
});
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
dropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
}
|
||||
|
||||
protected override FilterCriteria CreateCriteria()
|
||||
{
|
||||
var criteria = base.CreateCriteria();
|
||||
|
||||
switch (dropdown.Current.Value)
|
||||
{
|
||||
case TimeshiftCategory.Normal:
|
||||
criteria.Category = "normal";
|
||||
break;
|
||||
|
||||
case TimeshiftCategory.Spotlight:
|
||||
criteria.Category = "spotlight";
|
||||
break;
|
||||
}
|
||||
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private enum TimeshiftCategory
|
||||
{
|
||||
Any,
|
||||
Normal,
|
||||
Spotlight
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,6 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
Filter = new FilterControl { Depth = -1 },
|
||||
content = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -79,6 +78,11 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
},
|
||||
},
|
||||
},
|
||||
Filter = new TimeshiftFilterControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 80,
|
||||
},
|
||||
};
|
||||
|
||||
// scroll selected room into view on selection.
|
||||
|
@ -317,7 +317,7 @@ namespace osu.Game.Screens.Multi
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
pollReq?.Cancel();
|
||||
pollReq = new GetRoomsRequest(currentFilter.Value.StatusFilter, currentFilter.Value.RoomCategoryFilter);
|
||||
pollReq = new GetRoomsRequest(currentFilter.Value.Status, currentFilter.Value.Category);
|
||||
|
||||
pollReq.Success += result =>
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user