void RenderPlayers() { var currentPlayers = Battle.NonSpectatorCount; var maxPlayers = Battle.MaxPlayers; var friends = 0; var admins = 0; var mes = 0; // whether i'm in the battle (can be 0 or 1) foreach (var user in Battle.Users) { if (user.Name == Program.TasClient.UserName) { mes++; } if (Program.FriendManager.Friends.Contains(user.Name)) { friends++; } else if (user.LobbyUser.IsAdmin || user.LobbyUser.IsZeroKAdmin) { admins++; } } // make sure there aren't more little dudes than non-specs in a battle while (admins != 0 && friends + admins + mes > Battle.NonSpectatorCount) { admins--; } while (friends != 0 && friends + mes > Battle.NonSpectatorCount) { friends--; } if (playersBoxImage != null) { playersBoxImage.Dispose(); } playersBoxImage = DudeRenderer.GetImage(currentPlayers - friends - admins - mes, friends, admins, 0, maxPlayers, mes > 0, DpiMeasurement.ScaleValueX(playersBoxSize.Width), DpiMeasurement.ScaleValueY(playersBoxSize.Height)); }
void RenderPlayers() { int currentPlayers = Battle.NonSpectatorCount; int maxPlayers = Battle.MaxPlayers; int friends = 0; int admins = 0; int mes = 0; // whether i'm in the battle (can be 0 or 1) foreach (User user in Battle.Users.Values.Select(x => x.LobbyUser)) { if (user.Name == Program.TasClient.UserName) { mes++; } if (Program.TasClient.Friends.Contains(user.Name)) { friends++; } else if (user.IsAdmin) { admins++; } } // make sure there aren't more little dudes than non-specs in a battle while (admins != 0 && friends + admins + mes > Battle.NonSpectatorCount) { admins--; } while (friends != 0 && friends + mes > Battle.NonSpectatorCount) { friends--; } if (playersBoxImage != null) { playersBoxImage.Dispose(); } playersBoxImage = DudeRenderer.GetImage(currentPlayers - friends - admins - mes, friends, admins, 0, maxPlayers, mes > 0, (int)playersBoxSize.Width, (int)playersBoxSize.Height); }