# HG changeset patch # User Adam Kaminski # Date 1624191080 14400 # Sun Jun 20 08:11:20 2021 -0400 # Node ID 2708da64dc7d4b1deabac33166078c233937409f # Parent ac117eb0464e1feec19386ea24be7c3660abc75e Moved CALLVOTE_Render and CALLVOTE_RenderClassic into callvote.cpp. diff -r ac117eb0464e -r 2708da64dc7d src/callvote.cpp --- a/src/callvote.cpp Sun Jun 20 08:08:00 2021 -0400 +++ b/src/callvote.cpp Sun Jun 20 08:11:20 2021 -0400 @@ -66,6 +66,10 @@ #include "v_video.h" #include "maprotation.h" #include "gamemode.h" +#include "c_bind.h" +#include "c_console.h" +#include "gi.h" +#include "st_hud.h" #include //***************************************************************************** @@ -192,6 +196,127 @@ //***************************************************************************** // +// [RC] New compact version; RenderInVoteClassic is the fullscreen version +// +void CALLVOTE_Render( void ) +{ + ULONG ulVoteChoice = CALLVOTE_GetPlayerVoteChoice( consoleplayer ); + FString text; + + // Render the title and time left. + ULONG ulYPos = 8; + text.Format( "VOTE NOW! ( %d )", static_cast(( CALLVOTE_GetCountdownTicks( ) + TICRATE ) / TICRATE )); + HUD_DrawTextCentered( BigFont, gameinfo.gametype == GAME_Doom ? CR_RED : CR_UNTRANSLATED, ulYPos, text, g_bScale ); + + // Render the command being voted on. + ulYPos += 14; + HUD_DrawTextCentered( SmallFont, CR_WHITE, ulYPos, CALLVOTE_GetVoteMessage( ), g_bScale ); + + ulYPos += 4; + + // Render the reason of the vote being voted on. + if ( strlen( CALLVOTE_GetReason( )) > 0 ) + { + ulYPos += 8; + text.Format( "Reason: %s", CALLVOTE_GetReason( )); + HUD_DrawTextCentered( SmallFont, CR_ORANGE, ulYPos, text, g_bScale ); + } + + ulYPos += 8; + + // Render the number of votes. + text.Format( "%sYes: %d", ulVoteChoice == VOTE_YES ? TEXTCOLOR_YELLOW : "", static_cast( CALLVOTE_GetYesVoteCount( ))); + text.AppendFormat( TEXTCOLOR_NORMAL ", %sNo: %d", ulVoteChoice == VOTE_NO ? TEXTCOLOR_YELLOW : "", static_cast( CALLVOTE_GetNoVoteCount( ))); + HUD_DrawTextCentered( SmallFont, CR_DARKBROWN, ulYPos, text, g_bScale ); + + // Render the explanation of keys. + if ( ulVoteChoice == VOTE_UNDECIDED ) + { + char keyVoteYes[16]; + C_FindBind( "vote_yes", keyVoteYes ); + + char keyVoteNo[16]; + C_FindBind( "vote_no", keyVoteNo ); + + ulYPos += 8; + text.Format( "%s | %s", keyVoteYes, keyVoteNo ); + HUD_DrawTextCentered( SmallFont, CR_BLACK, ulYPos, text, g_bScale ); + } +} + +//***************************************************************************** +// +void CALLVOTE_RenderClassic( void ) +{ + ULONG *pulPlayersWhoVotedYes = CALLVOTE_GetPlayersWhoVotedYes( ); + ULONG *pulPlayersWhoVotedNo = CALLVOTE_GetPlayersWhoVotedNo( ); + ULONG ulMaxYesOrNoVoters = ( MAXPLAYERS / 2 ) + 1; + FString text; + + // Start with the "VOTE NOW!" title. + ULONG ulYPos = 16; + HUD_DrawTextCleanCentered( BigFont, gameinfo.gametype == GAME_Doom ? CR_RED : CR_UNTRANSLATED, ulYPos, "VOTE NOW!" ); + + // Render who called the vote. + ulYPos += 24; + text.Format( "Vote called by: %s", players[CALLVOTE_GetVoteCaller( )].userinfo.GetName( )); + HUD_DrawTextCleanCentered( SmallFont, CR_UNTRANSLATED, ulYPos, text ); + + // Render the command being voted on. + ulYPos += 16; + HUD_DrawTextCleanCentered( SmallFont, CR_WHITE, ulYPos, CALLVOTE_GetVoteMessage( )); + + // Render the reason for the vote being voted on. + if ( strlen( CALLVOTE_GetReason( )) > 0 ) + { + ulYPos += 16; + text.Format( "Reason: %s", CALLVOTE_GetReason( )); + HUD_DrawTextCleanCentered( SmallFont, CR_ORANGE, ulYPos, text ); + } + + // Render how much time is left to vote. + ulYPos += 16; + text.Format( "Vote ends in: %d", static_cast(( CALLVOTE_GetCountdownTicks( ) + TICRATE ) / TICRATE )); + HUD_DrawTextCleanCentered( SmallFont, CR_RED, ulYPos, text ); + + // Display how many have voted for "Yes" and "No". + ulYPos += 16; + text.Format( "Yes: %d", static_cast( CALLVOTE_GetYesVoteCount( ))); + HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 32, ulYPos, text ); + + text.Format( "No: %d", static_cast( CALLVOTE_GetNoVoteCount( ))); + HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 320 - 32 - SmallFont->StringWidth( text ), ulYPos, text ); + + ulYPos += 8; + ULONG ulOldYPos = ulYPos; + + // [AK] Show a list of all the players who voted yes. + for ( ULONG ulIdx = 0; ulIdx < ulMaxYesOrNoVoters; ulIdx++ ) + { + if ( pulPlayersWhoVotedYes[ulIdx] != MAXPLAYERS ) + { + ulYPos += 8; + text.Format( "%s", players[ulIdx].userinfo.GetName( )); + HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 32, ulYPos, text ); + } + } + + ulYPos = ulOldYPos; + + // [AK] Next, show another list with all the players who voted no. + for ( ULONG ulIdx = 0; ulIdx < ulMaxYesOrNoVoters; ulIdx++ ) + { + if ( pulPlayersWhoVotedNo[ulIdx] != MAXPLAYERS ) + { + ulYPos += 8; + text.Format( "%s", players[ulIdx].userinfo.GetName( )); + HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 320 - 32 - SmallFont->StringWidth( text ), ulYPos, text ); + } + } +} + +//***************************************************************************** +// void CALLVOTE_BeginVote( FString Command, FString Parameters, FString Reason, ULONG ulPlayer ) { level_info_t *pLevel = NULL; diff -r ac117eb0464e -r 2708da64dc7d src/scoreboard.cpp --- a/src/scoreboard.cpp Sun Jun 20 08:08:00 2021 -0400 +++ b/src/scoreboard.cpp Sun Jun 20 08:11:20 2021 -0400 @@ -202,127 +202,6 @@ //***************************************************************************** // -void CALLVOTE_RenderClassic( void ) -{ - ULONG *pulPlayersWhoVotedYes = CALLVOTE_GetPlayersWhoVotedYes( ); - ULONG *pulPlayersWhoVotedNo = CALLVOTE_GetPlayersWhoVotedNo( ); - ULONG ulMaxYesOrNoVoters = ( MAXPLAYERS / 2 ) + 1; - FString text; - - // Start with the "VOTE NOW!" title. - ULONG ulYPos = 16; - HUD_DrawTextCleanCentered( BigFont, gameinfo.gametype == GAME_Doom ? CR_RED : CR_UNTRANSLATED, ulYPos, "VOTE NOW!" ); - - // Render who called the vote. - ulYPos += 24; - text.Format( "Vote called by: %s", players[CALLVOTE_GetVoteCaller( )].userinfo.GetName( )); - HUD_DrawTextCleanCentered( SmallFont, CR_UNTRANSLATED, ulYPos, text ); - - // Render the command being voted on. - ulYPos += 16; - HUD_DrawTextCleanCentered( SmallFont, CR_WHITE, ulYPos, CALLVOTE_GetVoteMessage( )); - - // Render the reason for the vote being voted on. - if ( strlen( CALLVOTE_GetReason( )) > 0 ) - { - ulYPos += 16; - text.Format( "Reason: %s", CALLVOTE_GetReason( )); - HUD_DrawTextCleanCentered( SmallFont, CR_ORANGE, ulYPos, text ); - } - - // Render how much time is left to vote. - ulYPos += 16; - text.Format( "Vote ends in: %d", static_cast(( CALLVOTE_GetCountdownTicks( ) + TICRATE ) / TICRATE )); - HUD_DrawTextCleanCentered( SmallFont, CR_RED, ulYPos, text ); - - // Display how many have voted for "Yes" and "No". - ulYPos += 16; - text.Format( "Yes: %d", static_cast( CALLVOTE_GetYesVoteCount( ))); - HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 32, ulYPos, text ); - - text.Format( "No: %d", static_cast( CALLVOTE_GetNoVoteCount( ))); - HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 320 - 32 - SmallFont->StringWidth( text ), ulYPos, text ); - - ulYPos += 8; - ULONG ulOldYPos = ulYPos; - - // [AK] Show a list of all the players who voted yes. - for ( ULONG ulIdx = 0; ulIdx < ulMaxYesOrNoVoters; ulIdx++ ) - { - if ( pulPlayersWhoVotedYes[ulIdx] != MAXPLAYERS ) - { - ulYPos += 8; - text.Format( "%s", players[ulIdx].userinfo.GetName( )); - HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 32, ulYPos, text ); - } - } - - ulYPos = ulOldYPos; - - // [AK] Next, show another list with all the players who voted no. - for ( ULONG ulIdx = 0; ulIdx < ulMaxYesOrNoVoters; ulIdx++ ) - { - if ( pulPlayersWhoVotedNo[ulIdx] != MAXPLAYERS ) - { - ulYPos += 8; - text.Format( "%s", players[ulIdx].userinfo.GetName( )); - HUD_DrawTextClean( SmallFont, CR_UNTRANSLATED, 320 - 32 - SmallFont->StringWidth( text ), ulYPos, text ); - } - } -} - -//***************************************************************************** -// -// [RC] New compact version; RenderInVoteClassic is the fullscreen version -// -void CALLVOTE_Render( void ) -{ - ULONG ulVoteChoice = CALLVOTE_GetPlayerVoteChoice( consoleplayer ); - FString text; - - // Render the title and time left. - ULONG ulYPos = 8; - text.Format( "VOTE NOW! ( %d )", static_cast(( CALLVOTE_GetCountdownTicks( ) + TICRATE ) / TICRATE )); - HUD_DrawTextCentered( BigFont, gameinfo.gametype == GAME_Doom ? CR_RED : CR_UNTRANSLATED, ulYPos, text, g_bScale ); - - // Render the command being voted on. - ulYPos += 14; - HUD_DrawTextCentered( SmallFont, CR_WHITE, ulYPos, CALLVOTE_GetVoteMessage( ), g_bScale ); - - ulYPos += 4; - - // Render the reason of the vote being voted on. - if ( strlen( CALLVOTE_GetReason( )) > 0 ) - { - ulYPos += 8; - text.Format( "Reason: %s", CALLVOTE_GetReason( )); - HUD_DrawTextCentered( SmallFont, CR_ORANGE, ulYPos, text, g_bScale ); - } - - ulYPos += 8; - - // Render the number of votes. - text.Format( "%sYes: %d", ulVoteChoice == VOTE_YES ? TEXTCOLOR_YELLOW : "", static_cast( CALLVOTE_GetYesVoteCount( ))); - text.AppendFormat( TEXTCOLOR_NORMAL ", %sNo: %d", ulVoteChoice == VOTE_NO ? TEXTCOLOR_YELLOW : "", static_cast( CALLVOTE_GetNoVoteCount( ))); - HUD_DrawTextCentered( SmallFont, CR_DARKBROWN, ulYPos, text, g_bScale ); - - // Render the explanation of keys. - if ( ulVoteChoice == VOTE_UNDECIDED ) - { - char keyVoteYes[16]; - C_FindBind( "vote_yes", keyVoteYes ); - - char keyVoteNo[16]; - C_FindBind( "vote_no", keyVoteNo ); - - ulYPos += 8; - text.Format( "%s | %s", keyVoteYes, keyVoteNo ); - HUD_DrawTextCentered( SmallFont, CR_BLACK, ulYPos, text, g_bScale ); - } -} - -//***************************************************************************** -// LONG SCOREBOARD_GetLeftToLimit( void ) { ULONG ulIdx;