// Update void CClassMenuPanel::Update() { // Don't allow the player to join a team if they're not in a team if (!g_iTeamNumber) return; int iYPos = CLASSMENU_TOPLEFT_BUTTON_Y; // Cycle through the rest of the buttons for (int i = 0; i <= PC_RANDOM; i++) { bool bCivilian = (gViewPort->GetValidClasses(g_iTeamNumber) == -1); if ( bCivilian ) { // If this team can only be civilians, only the civilian button's visible if (i == 0) { m_pButtons[0]->setVisible( true ); SetActiveInfo( 0 ); iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y; } else { m_pButtons[i]->setVisible( false ); } } else { if ( m_pButtons[i]->IsNotValid() || i == 0 ) { m_pButtons[i]->setVisible( false ); } else { m_pButtons[i]->setVisible( true ); m_pButtons[i]->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos ); iYPos += CLASSMENU_BUTTON_SIZE_Y + CLASSMENU_BUTTON_SPACER_Y; // Start with the first option up if (!m_iCurrentInfo) SetActiveInfo( i ); } } // Now count the number of teammembers of this class int iTotal = 0; for ( int j = 1; j < MAX_PLAYERS; j++ ) { if ( g_PlayerInfoList[j].name == NULL ) continue; // empty player slot, skip if ( g_PlayerExtraInfo[j].teamname[0] == 0 ) continue; // skip over players who are not in a team if ( g_PlayerInfoList[j].thisplayer ) continue; // skip this player if ( g_PlayerExtraInfo[j].teamnumber != g_iTeamNumber ) continue; // skip over players in other teams // If this team is forced to be civilians, just count the number of teammates if ( g_PlayerExtraInfo[j].playerclass != i && !bCivilian ) continue; iTotal++; } char sz[256]; sprintf(sz, m_sPlayersOnTeamString, iTotal); m_pPlayers[i]->setText( sz ); // Set the text color to the teamcolor m_pPlayers[i]->setFgColor( iTeamColors[g_iTeamNumber % iNumberOfTeamColors][0], iTeamColors[g_iTeamNumber % iNumberOfTeamColors][1], iTeamColors[g_iTeamNumber % iNumberOfTeamColors][2], 0 ); // set the graphic to be the team pick for ( int team = 0; team < MAX_TEAMS; team++ ) { // unset all the other images if ( m_pClassImages[team][i] ) { m_pClassImages[team][i]->setVisible( false ); } // set the current team image if ( m_pClassImages[g_iTeamNumber-1][i] != NULL ) { m_pClassImages[g_iTeamNumber-1][i]->setVisible( true ); } else if ( m_pClassImages[0][i] ) { m_pClassImages[0][i]->setVisible( true ); } } } // If the player already has a class, make the cancel button visible if ( g_iPlayerClass ) { m_pCancelButton->setPos( CLASSMENU_TOPLEFT_BUTTON_X, iYPos ); m_pCancelButton->setVisible( true ); } else { m_pCancelButton->setVisible( false ); } }
//----------------------------------------------------------------------------- // Purpose: Called everytime the Team Menu is displayed //----------------------------------------------------------------------------- void CTeamMenuPanel::Update( void ) { int iYPos = TEAMMENU_TOPLEFT_BUTTON_Y; // Set the team buttons for (int i = 1; i <= 4; i++) { if (m_pButtons[i]) { if ( i <= gViewPort->GetNumberOfTeams() ) { m_pButtons[i]->setText( gViewPort->GetTeamName(i) ); // bound key replacement char sz[32]; sprintf( sz, "%d", i ); m_pButtons[i]->setBoundKey( sz[0] ); m_pButtons[i]->setVisible( true ); m_pButtons[i]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; // Start with the first option up if (!m_iCurrentInfo) SetActiveInfo( i ); char szPlayerList[ (MAX_PLAYER_NAME_LENGTH + 3) * 31 ]; // name + ", " strcpy(szPlayerList, "\n"); // Update the Team Info // Now count the number of teammembers of this class int iTotal = 0; for ( int j = 1; j < MAX_PLAYERS; j++ ) { if ( g_PlayerInfoList[j].name == NULL ) continue; // empty player slot, skip if ( g_PlayerInfoList[j].thisplayer ) continue; // skip this player if ( g_PlayerExtraInfo[j].teamnumber != i ) continue; // skip over players in other teams iTotal++; if (iTotal > 1) strncat( szPlayerList, ", ", sizeof(szPlayerList) - strlen(szPlayerList) - 1 ); strncat( szPlayerList, g_PlayerInfoList[j].name, sizeof(szPlayerList) - strlen(szPlayerList) - 1 ); szPlayerList[ sizeof(szPlayerList) - 1 ] = '\0'; } if (iTotal > 0) { // Set the text of the info Panel char szText[ ((MAX_PLAYER_NAME_LENGTH + 3) * 31) + 256 ]; if (iTotal == 1) sprintf(szText, "%s: %d Player (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags ); else sprintf(szText, "%s: %d Players (%d points)", gViewPort->GetTeamName(i), iTotal, g_TeamInfo[i].frags ); strncat( szText, szPlayerList, sizeof(szText) - strlen(szText) - 1); szText[ sizeof(szText) - 1 ] = '\0'; m_pTeamInfoPanel[i]->setText( szText ); } else { m_pTeamInfoPanel[i]->setText( "" ); } } else { // Hide the button (may be visible from previous maps) m_pButtons[i]->setVisible( false ); } } } // Move the AutoAssign button into place m_pButtons[5]->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; // Spectate button if (m_pSpectateButton->IsNotValid()) { m_pSpectateButton->setVisible( false ); } else { m_pSpectateButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); m_pSpectateButton->setVisible( true ); iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; } // If the player is already in a team, make the cancel button visible if ( g_iTeamNumber ) { m_pCancelButton->setPos( TEAMMENU_TOPLEFT_BUTTON_X, iYPos ); iYPos += TEAMMENU_BUTTON_SIZE_Y + TEAMMENU_BUTTON_SPACER_Y; m_pCancelButton->setVisible( true ); } else { m_pCancelButton->setVisible( false ); } // Set the Map Title if (!m_bUpdatedMapName) { const char *level = gEngfuncs.pfnGetLevelName(); if (level && level[0]) { char sz[256]; char szTitle[256]; char *ch; // Update the level name strcpy( sz, level ); ch = strchr( sz, '/' ); if (!ch) ch = strchr( sz, '\\' ); strcpy( szTitle, ch+1 ); ch = strchr( szTitle, '.' ); *ch = '\0'; m_pMapTitle->setText( "%s", szTitle ); *ch = '.'; // Update the map briefing strcpy( sz, level ); ch = strchr( sz, '.' ); *ch = '\0'; strcat( sz, ".txt" ); char *pfile = (char*)gEngfuncs.COM_LoadFile( sz, 5, NULL ); if (pfile) { m_pBriefing->setText( pfile ); // Get the total size of the Briefing text and resize the text panel int iXSize, iYSize; m_pBriefing->getTextImage()->getTextSize( iXSize, iYSize ); m_pBriefing->setSize( iXSize, iYSize ); gEngfuncs.COM_FreeFile( pfile ); } m_bUpdatedMapName = true; } } m_pScrollPanel->validate(); }