1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 09:22:54 +08:00

Document + refactor max player limitation

This commit is contained in:
smoogipoo 2021-04-23 19:09:54 +09:00
parent b25340653d
commit 575ec7c528
2 changed files with 10 additions and 4 deletions

View File

@ -42,7 +42,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
/// <param name="userIds">The players to spectate.</param>
public MultiSpectatorScreen(int[] userIds)
: base(userIds.AsSpan().Slice(0, Math.Min(16, userIds.Length)).ToArray())
: base(userIds.Take(PlayerGrid.MAX_PLAYERS).ToArray())
{
instances = new PlayerArea[UserIds.Length];
}

View File

@ -15,6 +15,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// </summary>
public partial class PlayerGrid : CompositeDrawable
{
/// <summary>
/// A temporary limitation on the number of players, because only layouts up to 16 players are supported for a single screen.
/// Todo: Can be removed in the future with scrolling support + performance improvements.
/// </summary>
public const int MAX_PLAYERS = 16;
private const float player_spacing = 5;
/// <summary>
@ -58,11 +64,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
/// Adds a new cell with content to this grid.
/// </summary>
/// <param name="content">The content the cell should contain.</param>
/// <exception cref="InvalidOperationException">If more than 16 cells are added.</exception>
/// <exception cref="InvalidOperationException">If more than <see cref="MAX_PLAYERS"/> cells are added.</exception>
public void Add(Drawable content)
{
if (cellContainer.Count == 16)
throw new InvalidOperationException("Only 16 cells are supported.");
if (cellContainer.Count == MAX_PLAYERS)
throw new InvalidOperationException($"Only {MAX_PLAYERS} cells are supported.");
int index = cellContainer.Count;