static void DrawTeamScores( int x, int y ) { if (( GAMEMODE_GetCurrentFlags() & GMF_PLAYERSONTEAMS ) == 0 ) return; int numteams = TEAM_GetNumAvailableTeams(); FString text; // [TP] Common case if ( numteams == 2 ) { int scores[2] = { GetScoreForTeam( 0 ), GetScoreForTeam( 1 ) }; int leadingTeam = !!( scores[1] > scores[0] ); int losingTeam = 1 - leadingTeam; text.Format ("\\c%c%d\\cC - \\c%c%d", V_GetColorChar( TEAM_GetTextColor( leadingTeam )), scores[leadingTeam], V_GetColorChar( TEAM_GetTextColor( losingTeam )), scores[losingTeam] ); } else { int teams[MAX_TEAMS] = { 0, 1, 2, 3 }; std::sort( teams, teams + countof( teams ), TeamScoreSorter ); for ( int i = 0; i < numteams; ++i ) { if ( i > 0 ) text += "\\cC - "; text += "\\c"; text += V_GetColorChar( TEAM_GetTextColor( teams[i] )); text.AppendFormat( "%d", GetScoreForTeam( teams[i] )); } } V_ColorizeString( text ); screen->DrawText( HudFont, CR_UNTRANSLATED, x, y + 17, text.GetChars(), DTA_KeepRatio, true, DTA_VirtualWidth, hudwidth, DTA_VirtualHeight, hudheight, DTA_Alpha, 0xc000, TAG_DONE ); }
//***************************************************************************** // void LASTMANSTANDING_DoWinSequence( ULONG ulWinner ) { ULONG ulIdx; // Put the game state in the win sequence state. if (( NETWORK_GetState( ) != NETSTATE_CLIENT ) && ( CLIENTDEMO_IsPlaying( ) == false )) { LASTMANSTANDING_SetState( LMSS_WINSEQUENCE ); } // Tell clients to do the win sequence. if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVERCOMMANDS_DoGameModeWinSequence( ulWinner ); if ( NETWORK_GetState( ) != NETSTATE_SERVER ) { char szString[64]; DHUDMessageFadeOut *pMsg; if ( teamlms ) { if ( ulWinner == teams.Size( ) ) sprintf( szString, "\\cdDraw Game!" ); else sprintf( szString, "\\c%c%s Wins!", V_GetColorChar( TEAM_GetTextColor( ulWinner ) ), TEAM_GetName( ulWinner )); } else if ( ulWinner == MAXPLAYERS ) sprintf( szString, "\\cdDRAW GAME!" ); else sprintf( szString, "%s \\c-WINS!", players[ulWinner].userinfo.netname ); V_ColorizeString( szString ); // Display "%s WINS!" HUD message. pMsg = new DHUDMessageFadeOut( BigFont, szString, 160.4f, 75.0f, 320, 200, CR_RED, 3.0f, 2.0f ); StatusBar->AttachMessage( pMsg, MAKE_ID('C','N','T','R') ); szString[0] = 0; pMsg = new DHUDMessageFadeOut( SmallFont, szString, 0.0f, 0.0f, 0, 0, CR_RED, 3.0f, 2.0f ); StatusBar->AttachMessage( pMsg, MAKE_ID('F','R','A','G') ); pMsg = new DHUDMessageFadeOut( SmallFont, szString, 0.0f, 0.0f, 0, 0, CR_RED, 3.0f, 2.0f ); StatusBar->AttachMessage( pMsg, MAKE_ID('P','L','A','C') ); } // Award a victory or perfect medal to the winner. if (( lastmanstanding ) && ( NETWORK_GetState( ) != NETSTATE_CLIENT ) && ( CLIENTDEMO_IsPlaying( ) == false )) { LONG lMedal; // If the winner has full health, give him a "Perfect!". if ( players[ulWinner].health == deh.MegasphereHealth ) lMedal = MEDAL_PERFECT; else lMedal = MEDAL_VICTORY; // Give the player the medal. MEDAL_GiveMedal( ulWinner, lMedal ); if ( NETWORK_GetState( ) == NETSTATE_SERVER ) SERVERCOMMANDS_GivePlayerMedal( ulWinner, lMedal ); } for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) { if (( playeringame[ulIdx] ) && ( players[ulIdx].pSkullBot )) players[ulIdx].pSkullBot->PostEvent( BOTEVENT_LMS_WINSEQUENCE ); } }
//***************************************************************************** // void CHAT_PrintChatString( ULONG ulPlayer, ULONG ulMode, const char *pszString ) { ULONG ulChatLevel = 0; FString OutString; FString ChatString; // [RC] Are we ignoring this player? if (( ulPlayer != MAXPLAYERS ) && players[ulPlayer].bIgnoreChat ) return; // If ulPlayer == MAXPLAYERS, it is the server talking. if ( ulPlayer == MAXPLAYERS ) { // Special support for "/me" commands. ulChatLevel = PRINT_HIGH; if ( strnicmp( "/me", pszString, 3 ) == 0 ) { pszString += 3; OutString = "* <server>"; } else OutString = "<server>: "; } else if ( ulMode == CHATMODE_GLOBAL ) { ulChatLevel = PRINT_CHAT; // Special support for "/me" commands. if ( strnicmp( "/me", pszString, 3 ) == 0 ) { ulChatLevel = PRINT_HIGH; pszString += 3; OutString.AppendFormat( "* %s\\cc", players[ulPlayer].userinfo.netname ); } else { OutString.AppendFormat( "%s" TEXTCOLOR_CHAT ": ", players[ulPlayer].userinfo.netname ); } } else if ( ulMode == CHATMODE_TEAM ) { ulChatLevel = PRINT_TEAMCHAT; if ( PLAYER_IsTrueSpectator ( &players[consoleplayer] ) ) OutString += "<SPEC> "; else { OutString = "\\c"; OutString += V_GetColorChar( TEAM_GetTextColor( players[consoleplayer].ulTeam )); OutString += "<TEAM> "; } // Special support for "/me" commands. if ( strnicmp( "/me", pszString, 3 ) == 0 ) { ulChatLevel = PRINT_HIGH; pszString += 3; OutString.AppendFormat( "\\cc* %s\\cc", players[ulPlayer].userinfo.netname ); } else { OutString.AppendFormat( "\\cd%s" TEXTCOLOR_TEAMCHAT ": ", players[ulPlayer].userinfo.netname ); } } ChatString = pszString; // [RC] Remove linebreaks and other escape codes from chat. ChatString.Substitute("\\", "\\\\"); // [RC] ...but allow chat colors. ChatString.Substitute("\\\\c", "\\c"); // [BB] Remove invalid color codes, those can confuse the printing and create new lines. V_RemoveInvalidColorCodes( ChatString ); // [RC] ...if the user wants them. if ( con_colorinmessages == 2) V_RemoveColorCodes( ChatString ); // [BB] Remove any kind of trailing crap. V_RemoveTrailingCrapFromFString ( ChatString ); // [BB] If the chat string is empty now, it only contained crap and is ignored. if ( ChatString.IsEmpty() ) return; OutString += ChatString; Printf( ulChatLevel, "%s\n", OutString.GetChars() ); // [BB] If the user doesn't want to see the messages, they shouldn't make a sound. if ( show_messages ) { // [RC] User can choose the chat sound. if ( chat_sound == 1 ) // Default S_Sound( CHAN_VOICE | CHAN_UI, gameinfo.chatSound, 1, ATTN_NONE ); else if ( chat_sound == 2 ) // Doom 1 S_Sound( CHAN_VOICE | CHAN_UI, "misc/chat2", 1, ATTN_NONE ); else if ( chat_sound == 3 ) // Doom 2 S_Sound( CHAN_VOICE | CHAN_UI, "misc/chat", 1, ATTN_NONE ); } BOTCMD_SetLastChatString( pszString ); BOTCMD_SetLastChatPlayer( players[ulPlayer].userinfo.netname ); { ULONG ulIdx; for ( ulIdx = 0; ulIdx < MAXPLAYERS; ulIdx++ ) { if ( playeringame[ulIdx] == false ) continue; // Don't tell the bot someone talked if it was it who talked. if ( ulIdx == ulPlayer ) continue; // If this is a bot, tell it a player said something. if ( players[ulIdx].pSkullBot ) players[ulIdx].pSkullBot->PostEvent( BOTEVENT_PLAYER_SAY ); } } }
//***************************************************************************** // void CHAT_Render( void ) { UCVarValue ValWidth; UCVarValue ValHeight; bool bScale; float fXScale; float fYScale; ULONG ulYPos; LONG lIdx; LONG lX; char szString[64]; if ( g_ulChatMode == CHATMODE_NONE ) return; ValWidth = con_virtualwidth.GetGenericRep( CVAR_Int ); ValHeight = con_virtualheight.GetGenericRep( CVAR_Int ); // Initialization. if (( con_scaletext ) && ( con_virtualwidth > 0 ) && ( con_virtualheight > 0 )) { fXScale = (float)ValWidth.Int / SCREENWIDTH; fYScale = (float)ValHeight.Int / SCREENHEIGHT; bScale = true; ulYPos = (( gamestate == GS_INTERMISSION ) ? SCREENHEIGHT : ST_Y ) - ( Scale( SCREENHEIGHT, SmallFont->GetHeight( ) + 1, ValHeight.Int )) + 1; } else { fXScale = 1.0f; fYScale = 1.0f; bScale = false; ulYPos = (( gamestate == GS_INTERMISSION ) ? SCREENHEIGHT : ST_Y ) - SmallFont->GetHeight( ) + 1; } lX = static_cast<LONG>(SmallFont->GetCharWidth( '_' ) * fXScale * 2 + SmallFont->StringWidth( g_pszChatPrompt )); // figure out if the text is wider than the screen-> // if so, only draw the right-most portion of it. for ( lIdx = g_lStringLength - 1; (( lIdx >= 0 ) && ( lX < ( (float)SCREENWIDTH * fXScale ))); lIdx-- ) { lX += SmallFont->GetCharWidth( g_szChatBuffer[lIdx] & 0x7f ); } // If lIdx is >= 0, then this chat string goes beyond the edge of the screen. if ( lIdx >= 0 ) lIdx++; else lIdx = 0; // Temporarily h4x0r the chat buffer string to include the cursor. g_szChatBuffer[g_lStringLength] = gameinfo.gametype == GAME_Doom ? '_' : '['; g_szChatBuffer[g_lStringLength+1] = 0; if ( g_ulChatMode == CHATMODE_GLOBAL ) { HUD_DrawText( SmallFont, CR_GREEN, 0, (LONG)( ulYPos * fYScale ), g_pszChatPrompt ); HUD_DrawText( SmallFont, CR_GRAY, SmallFont->StringWidth( g_pszChatPrompt ), (LONG)( ulYPos * fYScale ), g_szChatBuffer + lIdx ); } else { HUD_DrawText( SmallFont, CR_GREY, 0, (LONG)( ulYPos * fYScale ), g_pszChatPrompt ); HUD_DrawText( SmallFont, (TEAM_GetTextColor (players[consoleplayer].ulTeam)), SmallFont->StringWidth( g_pszChatPrompt ), (LONG)( ulYPos * fYScale ), g_szChatBuffer + lIdx ); } // [RC] Tell chatters about the iron curtain of LMS chat. if ( GAMEMODE_AreSpectatorsFordiddenToChatToPlayers() ) { // Is this the spectator talking? if ( players[consoleplayer].bSpectating ) sprintf( szString, "\\cdNOTE: \\ccPlayers cannot hear you chat" ); else sprintf( szString, "\\cdNOTE: \\ccSpectators cannot talk to you" ); V_ColorizeString( szString ); HUD_DrawText( SmallFont, CR_UNTRANSLATED, (LONG)(( ( bScale ? ValWidth.Int : SCREENWIDTH )/ 2 ) - ( SmallFont->StringWidth( szString ) / 2 )), (LONG)(( ulYPos * fYScale ) - ( SmallFont->GetHeight( ) * 2 ) + 1 ), szString ); } g_szChatBuffer[g_lStringLength] = 0; BorderTopRefresh = screen->GetPageCount( ); }