mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 19:02:57 +08:00
Document + refactor max player limitation
This commit is contained in:
parent
b25340653d
commit
575ec7c528
@ -42,7 +42,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userIds">The players to spectate.</param>
|
/// <param name="userIds">The players to spectate.</param>
|
||||||
public MultiSpectatorScreen(int[] userIds)
|
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];
|
instances = new PlayerArea[UserIds.Length];
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class PlayerGrid : CompositeDrawable
|
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;
|
private const float player_spacing = 5;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,11 +64,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// Adds a new cell with content to this grid.
|
/// Adds a new cell with content to this grid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="content">The content the cell should contain.</param>
|
/// <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)
|
public void Add(Drawable content)
|
||||||
{
|
{
|
||||||
if (cellContainer.Count == 16)
|
if (cellContainer.Count == MAX_PLAYERS)
|
||||||
throw new InvalidOperationException("Only 16 cells are supported.");
|
throw new InvalidOperationException($"Only {MAX_PLAYERS} cells are supported.");
|
||||||
|
|
||||||
int index = cellContainer.Count;
|
int index = cellContainer.Count;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user