1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Split overlong conditional to local function

This commit is contained in:
Bartłomiej Dach 2022-06-23 18:03:04 +02:00
parent bea70988bc
commit 04d69010b5
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

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