1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:13:00 +08:00

Rename enum to explicitly mention it is a filter

This commit is contained in:
Dean Herbert 2022-07-01 17:26:40 +09:00
parent 9911c6cbf0
commit e213c1a4ef
5 changed files with 13 additions and 13 deletions

View File

@ -170,11 +170,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("both rooms visible", () => container.Rooms.Count(r => r.IsPresent) == 2);
AddStep("filter public rooms", () => container.Filter.Value = new FilterCriteria { AccessType = RoomAccessType.Public });
AddStep("filter public rooms", () => container.Filter.Value = new FilterCriteria { Permissions = RoomPermissionsFilter.Public });
AddUntilStep("private room hidden", () => container.Rooms.All(r => !r.Room.HasPassword.Value));
AddStep("filter private rooms", () => container.Filter.Value = new FilterCriteria { AccessType = RoomAccessType.Private });
AddStep("filter private rooms", () => container.Filter.Value = new FilterCriteria { Permissions = RoomPermissionsFilter.Private });
AddUntilStep("public room hidden", () => container.Rooms.All(r => r.Room.HasPassword.Value));
}

View File

@ -13,6 +13,6 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public RoomStatusFilter Status;
public string Category;
public RulesetInfo Ruleset;
public RoomAccessType AccessType;
public RoomPermissionsFilter Permissions;
}
}

View File

@ -3,7 +3,7 @@
namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
public enum RoomAccessType
public enum RoomPermissionsFilter
{
All,
Public,

View File

@ -87,27 +87,27 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
matchingFilter &= r.FilterTerms.Any(term => term.ToString().Contains(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase));
}
matchingFilter &= matchesAccessType(r, criteria.AccessType);
matchingFilter &= matchPermissions(r, criteria.Permissions);
r.MatchingFilter = matchingFilter;
}
});
static bool matchesAccessType(DrawableLoungeRoom room, RoomAccessType accessType)
static bool matchPermissions(DrawableLoungeRoom room, RoomPermissionsFilter accessType)
{
switch (accessType)
{
case RoomAccessType.All:
case RoomPermissionsFilter.All:
return true;
case RoomAccessType.Public:
case RoomPermissionsFilter.Public:
return !room.Room.HasPassword.Value;
case RoomAccessType.Private:
case RoomPermissionsFilter.Private:
return room.Room.HasPassword.Value;
default:
throw new ArgumentOutOfRangeException(nameof(accessType), accessType, $"Unsupported {nameof(RoomAccessType)} in filter");
throw new ArgumentOutOfRangeException(nameof(accessType), accessType, $"Unsupported {nameof(RoomPermissionsFilter)} in filter");
}
}
}

View File

@ -31,7 +31,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
[Resolved]
private MultiplayerClient client { get; set; }
private Dropdown<RoomAccessType> roomAccessTypeDropdown;
private Dropdown<RoomPermissionsFilter> roomAccessTypeDropdown;
public override void OnResuming(ScreenTransitionEvent e)
{
@ -48,7 +48,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
protected override IEnumerable<Drawable> CreateFilterControls()
{
roomAccessTypeDropdown = new SlimEnumDropdown<RoomAccessType>
roomAccessTypeDropdown = new SlimEnumDropdown<RoomPermissionsFilter>
{
RelativeSizeAxes = Axes.None,
Width = 160,
@ -63,7 +63,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
var criteria = base.CreateFilterCriteria();
criteria.Category = @"realtime";
criteria.AccessType = roomAccessTypeDropdown.Current.Value;
criteria.Permissions = roomAccessTypeDropdown.Current.Value;
return criteria;
}