From ca8bfcd348b36105da313745b3da6114774eb022 Mon Sep 17 00:00:00 2001 From: Gelmo Date: Wed, 1 Nov 2023 11:41:54 -0600 Subject: [PATCH] By default, center print new votes to clients - A new cvar has been added - `cg_centerVote` - Default value is 1 - If the player does not have `cg_centerVote` set to 0 and a new vote is started, they will receive a center print message that a vote is in progress, in addition to the standard messages in chat - If the player does not have `cg_centerVote` set to 0 and they have not yet voted when the vote status is re-printed to chat, they will receive another center print message that a vote is in progress, in addition to the standard messages in chat - A new checkbox has been added to the HUD options to control the cvar `cg_centerVote` - New strings for translation: - Console description - `cg_centerVote` - UI - `Centered vote notifications` - UI - `Vote in progress - View chat` --- .../l10n/console/descriptions/cg/en.po | 6 +++ assets/data0_21/l10n/ui/ui_en.po | 6 +++ .../data0_21pure/ui/porkui/options_player.rml | 5 ++- assets/default.cfg | 1 + source/cgame/cg_local.h | 1 + source/cgame/cg_main.cpp | 8 ++-- source/game/g_callvotes.cpp | 37 ++++++++++++++++++- 7 files changed, 59 insertions(+), 5 deletions(-) diff --git a/assets/data0_21/l10n/console/descriptions/cg/en.po b/assets/data0_21/l10n/console/descriptions/cg/en.po index cc486ea23c..759a1ad1f1 100644 --- a/assets/data0_21/l10n/console/descriptions/cg/en.po +++ b/assets/data0_21/l10n/console/descriptions/cg/en.po @@ -56,6 +56,12 @@ msgstr "<0/1> Critical hit effects will be displayed for high damage value attac "^6Enable: cg_cartoonHitEffect \"1\"\n" "^6Note: Critical hit effect color varies based on damage dealt. Green (39 or more), Yellow (50 or more), and Red (64 or more)." +#. Console/cg +msgid "cg_centerVote" +msgstr "<0/1> Displays a centered notice when a vote is in progress.\n" +"^6Disable: cg_centerVote \"0\"\n" +"^6Enable: cg_centerVote \"1\"" + #. Console/cg msgid "cg_chatBeep" msgstr "<0/1> Plays a chat beep sound when someone sends a message.\n" diff --git a/assets/data0_21/l10n/ui/ui_en.po b/assets/data0_21/l10n/ui/ui_en.po index 930cde6d5e..731997bd91 100644 --- a/assets/data0_21/l10n/ui/ui_en.po +++ b/assets/data0_21/l10n/ui/ui_en.po @@ -627,6 +627,12 @@ msgstr "chat + center" msgid "chat + center + icons" msgstr "chat + center + icons" +msgid "Centered vote notifications" +msgstr "Centered vote notifications" + +msgid "Vote in progress - View chat" +msgstr "Vote in progress - View chat" + #. Shows indicators at the top of the teammates, even if they are not visible #. through the walls msgid "Show teammates' indicators" diff --git a/assets/data0_21pure/ui/porkui/options_player.rml b/assets/data0_21pure/ui/porkui/options_player.rml index 8534d85417..ad84670ab7 100644 --- a/assets/data0_21pure/ui/porkui/options_player.rml +++ b/assets/data0_21pure/ui/porkui/options_player.rml @@ -339,7 +339,10 @@
- + +
Centered vote notifications
+ +
Show teammates' indicators
diff --git a/assets/default.cfg b/assets/default.cfg index 76946448fe..6708a5720e 100755 --- a/assets/default.cfg +++ b/assets/default.cfg @@ -11,6 +11,7 @@ set cg_autoaction_screenshot "0" set cg_autoaction_spectator "0" set cg_bloodTrail "10" set cg_bloodTrailAlpha "1.0" +set cg_centerVote "1" set cg_chatBeep "1" set cg_chatFilter "0" set cg_chatFilterTV "2" diff --git a/source/cgame/cg_local.h b/source/cgame/cg_local.h index 2eb5981abf..8ab57ba428 100644 --- a/source/cgame/cg_local.h +++ b/source/cgame/cg_local.h @@ -931,6 +931,7 @@ extern cvar_t *cg_raceGhostsAlpha; extern cvar_t *cg_chatBeep; extern cvar_t *cg_chatFilter; extern cvar_t *cg_chatFilterTV; +extern cvar_t *cg_centerVote; //force models extern cvar_t *cg_teamPLAYERSmodel; diff --git a/source/cgame/cg_main.cpp b/source/cgame/cg_main.cpp index 008a18dca1..f41158ac01 100644 --- a/source/cgame/cg_main.cpp +++ b/source/cgame/cg_main.cpp @@ -91,6 +91,7 @@ cvar_t *cg_raceGhostsAlpha; cvar_t *cg_chatBeep; cvar_t *cg_chatFilter; cvar_t *cg_chatFilterTV; +cvar_t *cg_centerVote; cvar_t *cg_cartoonEffects; cvar_t *cg_cartoonHitEffect; @@ -747,9 +748,10 @@ static void CG_RegisterVariables( void ) cg_handicap = trap_Cvar_Get( "handicap", "0", CVAR_USERINFO | CVAR_ARCHIVE ); cg_clan = trap_Cvar_Get( "clan", "", CVAR_USERINFO | CVAR_ARCHIVE ); cg_movementStyle = trap_Cvar_Get( "cg_movementStyle", "0", CVAR_USERINFO | CVAR_ARCHIVE ); - cg_noAutohop = trap_Cvar_Get( "cg_noAutohop", "0", CVAR_USERINFO | CVAR_ARCHIVE ); - cg_fov = trap_Cvar_Get( "fov", "100", CVAR_ARCHIVE ); - cg_zoomfov = trap_Cvar_Get( "zoomfov", "30", CVAR_ARCHIVE ); + cg_noAutohop = trap_Cvar_Get( "cg_noAutohop", "0", CVAR_USERINFO | CVAR_ARCHIVE ); + cg_centerVote = trap_Cvar_Get( "cg_centerVote", "1", CVAR_USERINFO | CVAR_ARCHIVE ); + cg_fov = trap_Cvar_Get( "fov", "100", CVAR_ARCHIVE ); + cg_zoomfov = trap_Cvar_Get( "zoomfov", "30", CVAR_ARCHIVE ); cg_addDecals = trap_Cvar_Get( "cg_decals", "1", CVAR_ARCHIVE ); //cg_footSteps = trap_Cvar_Get( "cg_footSteps", "1", 0 ); diff --git a/source/game/g_callvotes.cpp b/source/game/g_callvotes.cpp index b20aa9cb91..7663dc6d45 100644 --- a/source/game/g_callvotes.cpp +++ b/source/game/g_callvotes.cpp @@ -2099,7 +2099,7 @@ static void G_CallVotes_CheckState( void ) clientVoted[PLAYERNUM( ent )] == VOTED_NOTHING ) { continue; } - } + } if( callvoteState.vote.callvote->need_auth && sv_mm_enable->integer ) { @@ -2142,6 +2142,24 @@ static void G_CallVotes_CheckState( void ) { if( callvoteState.timeout - game.realtime <= 7500 && callvoteState.timeout - game.realtime > 2500 ) G_AnnouncerSound( NULL, trap_SoundIndex( S_ANNOUNCER_CALLVOTE_VOTE_NOW ), GS_MAX_TEAMS, true, NULL ); + + char *ival; + int iCenterVoteEnabled; + edict_t *i; + + // If a player doesn't have "Centered vote notifications" disabled, and they still have not voted, notify them of the vote via center print + for( i = game.edicts + 1; PLAYERNUM( i ) < gs.maxclients; i++ ) + { + iCenterVoteEnabled = 1; + ival = NULL; + ival = Info_ValueForKey( i->r.client->userinfo, "cg_centerVote" ); + if( ival ) + iCenterVoteEnabled = atoi( ival ); + + if ( iCenterVoteEnabled != 0 && clientVoted[PLAYERNUM( i )] == VOTED_NOTHING ) + G_CenterPrintMsg( i, S_COLOR_YELLOW "Vote in progress - View chat"); + } + G_PrintMsg( NULL, "Vote in progress: %s%s%s, %i voted yes, %i voted no. %i required\n", S_COLOR_YELLOW, G_CallVotes_String( &callvoteState.vote ), S_COLOR_WHITE, yeses, noes, needvotes + 1 ); @@ -2403,6 +2421,23 @@ static void G_CallVote( edict_t *ent, bool isopcall ) G_AnnouncerSound( NULL, trap_SoundIndex( va( S_ANNOUNCER_CALLVOTE_CALLED_1_to_2, ( rand()&1 )+1 ) ), GS_MAX_TEAMS, true, NULL ); + char *zval; + int zCenterVoteEnabled; + edict_t *z; + + // If a player doesn't have "Centered vote notifications" disabled, and they still have not voted, notify them of the vote via center print + for( z = game.edicts + 1; PLAYERNUM( z ) < gs.maxclients; z++ ) + { + zCenterVoteEnabled = 1; + zval = NULL; + zval = Info_ValueForKey( z->r.client->userinfo, "cg_centerVote" ); + if( zval ) + zCenterVoteEnabled = atoi( zval ); + + if ( zCenterVoteEnabled != 0 && clientVoted[PLAYERNUM( z )] == VOTED_NOTHING ) + G_CenterPrintMsg( z, S_COLOR_YELLOW "Vote in progress - View chat"); + } + G_PrintMsg( NULL, "%s" S_COLOR_WHITE " requested to vote " S_COLOR_YELLOW "%s\n", ent->r.client->netname, G_CallVotes_String( &callvoteState.vote ) );