mirror of
https://github.com/ppy/osu.git
synced 2025-03-25 11:47:19 +08:00
Merge pull request #31073 from bdach/filter-playing-rooms
Add ability to filter out currently playing rooms
This commit is contained in:
commit
2930db5d6e
@ -202,6 +202,7 @@ namespace osu.Game.Configuration
|
||||
SetDefault(OsuSetting.HideCountryFlags, false);
|
||||
|
||||
SetDefault(OsuSetting.MultiplayerRoomFilter, RoomPermissionsFilter.All);
|
||||
SetDefault(OsuSetting.MultiplayerShowInProgressFilter, true);
|
||||
|
||||
SetDefault(OsuSetting.LastProcessedMetadataId, -1);
|
||||
|
||||
@ -447,6 +448,7 @@ namespace osu.Game.Configuration
|
||||
EditorRotationOrigin,
|
||||
EditorTimelineShowBreaks,
|
||||
EditorAdjustExistingObjectsOnTimingChanges,
|
||||
AlwaysRequireHoldingForPause
|
||||
AlwaysRequireHoldingForPause,
|
||||
MultiplayerShowInProgressFilter,
|
||||
}
|
||||
}
|
||||
|
@ -11,28 +11,33 @@ namespace osu.Game.Online.Rooms
|
||||
{
|
||||
public class GetRoomsRequest : APIRequest<List<Room>>
|
||||
{
|
||||
private readonly RoomStatusFilter status;
|
||||
private readonly RoomModeFilter mode;
|
||||
private readonly RoomStatusFilter? status;
|
||||
private readonly string category;
|
||||
|
||||
public GetRoomsRequest(RoomStatusFilter status, string category)
|
||||
public GetRoomsRequest(FilterCriteria filterCriteria)
|
||||
{
|
||||
this.status = status;
|
||||
this.category = category;
|
||||
mode = filterCriteria.Mode;
|
||||
category = filterCriteria.Category;
|
||||
status = filterCriteria.Status;
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
if (status != RoomStatusFilter.Open)
|
||||
req.AddParameter("mode", status.ToString().ToSnakeCase().ToLowerInvariant());
|
||||
if (mode != RoomModeFilter.Open)
|
||||
req.AddParameter(@"mode", mode.ToString().ToSnakeCase().ToLowerInvariant());
|
||||
|
||||
if (status != null)
|
||||
req.AddParameter(@"status", status.Value.ToString().ToSnakeCase().ToLowerInvariant());
|
||||
|
||||
if (!string.IsNullOrEmpty(category))
|
||||
req.AddParameter("category", category);
|
||||
req.AddParameter(@"category", category);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => "rooms";
|
||||
protected override string Target => @"rooms";
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
|
||||
lastPollRequest?.Cancel();
|
||||
|
||||
var req = new GetRoomsRequest(Filter.Value.Status, Filter.Value.Category);
|
||||
var req = new GetRoomsRequest(Filter.Value);
|
||||
|
||||
req.Success += result =>
|
||||
{
|
||||
|
@ -8,7 +8,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
public class FilterCriteria
|
||||
{
|
||||
public string SearchString = string.Empty;
|
||||
public RoomStatusFilter Status;
|
||||
public RoomModeFilter Mode;
|
||||
public RoomStatusFilter? Status;
|
||||
public string Category = string.Empty;
|
||||
public RulesetInfo? Ruleset;
|
||||
public RoomPermissionsFilter Permissions;
|
||||
|
@ -0,0 +1,17 @@
|
||||
// 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 System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public enum RoomModeFilter
|
||||
{
|
||||
Open,
|
||||
|
||||
[Description("Recently Ended")]
|
||||
Ended,
|
||||
Participated,
|
||||
Owned,
|
||||
}
|
||||
}
|
@ -1,17 +1,11 @@
|
||||
// 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.
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
||||
{
|
||||
public enum RoomStatusFilter
|
||||
{
|
||||
Open,
|
||||
|
||||
[Description("Recently Ended")]
|
||||
Ended,
|
||||
Participated,
|
||||
Owned,
|
||||
Idle,
|
||||
Playing,
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
private LoadingLayer loadingLayer = null!;
|
||||
private RoomsContainer roomsContainer = null!;
|
||||
private SearchTextBox searchTextBox = null!;
|
||||
private Dropdown<RoomStatusFilter> statusDropdown = null!;
|
||||
|
||||
protected Dropdown<RoomModeFilter> StatusDropdown { get; private set; } = null!;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load()
|
||||
@ -223,20 +224,20 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
|
||||
{
|
||||
SearchString = searchTextBox.Current.Value,
|
||||
Ruleset = ruleset.Value,
|
||||
Status = statusDropdown.Current.Value
|
||||
Mode = StatusDropdown.Current.Value
|
||||
};
|
||||
|
||||
protected virtual IEnumerable<Drawable> CreateFilterControls()
|
||||
{
|
||||
statusDropdown = new SlimEnumDropdown<RoomStatusFilter>
|
||||
StatusDropdown = new SlimEnumDropdown<RoomModeFilter>
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 160,
|
||||
};
|
||||
|
||||
statusDropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
StatusDropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
|
||||
yield return statusDropdown;
|
||||
yield return StatusDropdown;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -31,6 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
private MultiplayerClient client { get; set; } = null!;
|
||||
|
||||
private Dropdown<RoomPermissionsFilter> roomAccessTypeDropdown = null!;
|
||||
private OsuCheckbox showInProgress = null!;
|
||||
|
||||
public override void OnResuming(ScreenTransitionEvent e)
|
||||
{
|
||||
@ -47,7 +47,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
protected override IEnumerable<Drawable> CreateFilterControls()
|
||||
{
|
||||
roomAccessTypeDropdown = new SlimEnumDropdown<RoomPermissionsFilter>
|
||||
foreach (var control in base.CreateFilterControls())
|
||||
yield return control;
|
||||
|
||||
yield return roomAccessTypeDropdown = new SlimEnumDropdown<RoomPermissionsFilter>
|
||||
{
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Current = Config.GetBindable<RoomPermissionsFilter>(OsuSetting.MultiplayerRoomFilter),
|
||||
@ -56,7 +59,17 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
roomAccessTypeDropdown.Current.BindValueChanged(_ => UpdateFilter());
|
||||
|
||||
return base.CreateFilterControls().Append(roomAccessTypeDropdown);
|
||||
yield return showInProgress = new OsuCheckbox
|
||||
{
|
||||
LabelText = "Show in-progress rooms",
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Width = 220,
|
||||
Padding = new MarginPadding { Vertical = 5, },
|
||||
Current = Config.GetBindable<bool>(OsuSetting.MultiplayerShowInProgressFilter),
|
||||
};
|
||||
|
||||
showInProgress.Current.BindValueChanged(_ => UpdateFilter());
|
||||
StatusDropdown.Current.BindValueChanged(_ => showInProgress.Alpha = StatusDropdown.Current.Value == RoomModeFilter.Open ? 1 : 0, true);
|
||||
}
|
||||
|
||||
protected override FilterCriteria CreateFilterCriteria()
|
||||
@ -64,6 +77,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
var criteria = base.CreateFilterCriteria();
|
||||
criteria.Category = @"realtime";
|
||||
criteria.Permissions = roomAccessTypeDropdown.Current.Value;
|
||||
criteria.Status = showInProgress.Current.Value && criteria.Mode == RoomModeFilter.Open ? null : RoomStatusFilter.Idle;
|
||||
return criteria;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user