void w_players_in_game2::click(int, int) { player_entry2 thePlayerEntry; // make up a name /* int theNameLength = (local_random() % MAXIMUM_PLAYER_NAME_LENGTH) + 1; for(int i = 0; i < theNameLength; i++) thePlayerEntry.player_name[i] = 'a' + (local_random() % ('z' - 'a')); thePlayerEntry.player_name[theNameLength] = '\0'; // strcpy(thePlayerEntry.player_name, "The Big Lebowski"); */ strcpy(thePlayerEntry.player_name, sTestingNames[local_random() % 8]); // Set the size of the text thePlayerEntry.name_width = text_width(thePlayerEntry.player_name, font, style); // Make up a team-color int theTeamColor = local_random() % 8; // Get the pixel-color for the player's team (for drawing the name) thePlayerEntry.name_pixel_color = get_dialog_player_color(theTeamColor); // Set up a player image for the player (funfun) thePlayerEntry.player_image = new PlayerImage; thePlayerEntry.player_image->setRandomFlatteringView(); thePlayerEntry.player_image->setTeamColor(theTeamColor); player_entries.push_back(thePlayerEntry); dirty = true; }
void w_players_in_game2::update_display(bool inFromDynamicWorld /* default=false */) { // Start over - wipe out our local player-storage clear_vector(); // Wipe out references to players through teams for(int i = 0; i < NUMBER_OF_TEAM_COLORS; i++) players_on_team[i].clear(); // Find the number of players int num_players; if(inFromDynamicWorld) num_players = dynamic_world->player_count; else num_players = displaying_actual_information ? NetGetNumberOfPlayers() : 0; // Fill in the entries for(int i = 0; i < num_players; i++) { player_entry2 thePlayerEntry; int thePlayerTeam; int thePlayerColor; if(inFromDynamicWorld) { // Get player information from dynamic_world player_data* thePlayerData = get_player_data(i); // Copy the player name. We will store it as a cstring... strncpy(thePlayerEntry.player_name, thePlayerData->name, MAXIMUM_PLAYER_NAME_LENGTH + 1); // Look up colors thePlayerTeam = thePlayerData->team; thePlayerColor = thePlayerData->color; } else { // Get player information from topology player_info* thePlayerInfo = (player_info*)NetGetPlayerData(i); // Copy the player name. We will store it as a cstring... strncpy(thePlayerEntry.player_name, thePlayerInfo->name, MAXIMUM_PLAYER_NAME_LENGTH + 1); // Look up colors thePlayerTeam = thePlayerInfo->team; thePlayerColor = thePlayerInfo->color; } // Set the size of the text thePlayerEntry.name_width = text_width(thePlayerEntry.player_name, font, style | styleShadow); // Get the pixel-color for the player's team (for drawing the name) thePlayerEntry.name_pixel_color = get_dialog_player_color(thePlayerTeam); // Set up a player image for the player (funfun) thePlayerEntry.player_image = new PlayerImage; thePlayerEntry.player_image->setRandomFlatteringView(); thePlayerEntry.player_image->setPlayerColor(thePlayerColor); thePlayerEntry.player_image->setTeamColor(thePlayerTeam); // Add the player to our local storage area player_entries.push_back(thePlayerEntry); // Add a reference to the player through his team color players_on_team[thePlayerTeam].push_back(i); } dirty = true; }