diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2020-04-06 15:03:07 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2020-04-06 22:20:59 +0200 |
commit | 75984e5d13ae2020fbac8a00748bc17d2a932f57 (patch) | |
tree | 4c81c35f16d062bc716bd577ab8e90dac900fa20 /src | |
parent | c77c95816fbbecba5994825d9b68b749ac7c0fe4 (diff) |
Optionally display the fractional part of evo counts
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_draw.c | 60 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 4 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 7 |
3 files changed, 65 insertions, 6 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index cea2527..d9545b7 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -520,6 +520,59 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale, //=============== TA: was cg_newdraw.c +static void CG_DrawPlayerEvos( rectDef_t *rect, int value ) +{ + int fprec, len; + char buffer[ 30 ], *p; + float evos, x, y, w, h; + + if( cg_drawFractionalEvos.integer < 1 ) + { + fprec = 0; + } + else if( cg_drawFractionalEvos.integer > 4 ) + { + fprec = 4; + } + else + { + fprec = cg_drawFractionalEvos.integer; + } + + evos = value / EVO_TO_CREDS_RATE; + + Com_sprintf( buffer, sizeof( buffer ), va( "%%.%df", fprec ), evos ); + len = strlen( buffer ); + + w = rect->w / ( len - 0.5f ); // the dot is half-width + h = w * rect->h / rect->w * 1.6f; + x = rect->x + 2.0f; // same random offset as in CG_DrawField + y = rect->y + (rect->h - h) / 2.0f; + + for( p = buffer; *p; p++ ) + { + int digit; + float w2 = w; + + if( *p >= '0' && *p <= '9' ) + { + digit = *p - '0'; + } + else if( *p == '.' ) + { + digit = STAT_PERIOD; + w2 /= 2; + } + else + { + digit = STAT_MINUS; + } + + CG_DrawPic( x, y, w2, h, cgs.media.numberShaders[ digit ] ); + x += w2; + } +} + #define NO_CREDITS_TIME 2000 static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean padding ) @@ -541,8 +594,6 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p { if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS ) { - value = floor( value / EVO_TO_CREDS_RATE ); - if( !CG_AtHighestClass( ) && cg.time - cg.lastEvolveAttempt <= NO_CREDITS_TIME ) { if( ( ( cg.time - cg.lastEvolveAttempt ) / 300 ) % 2 ) @@ -552,7 +603,10 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p trap_R_SetColor( color ); - if( padding ) + if( cg_drawFractionalEvos.integer + && cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS ) + CG_DrawPlayerEvos( rect, value ); + else if( padding ) CG_DrawFieldPadded( rect->x, rect->y, 4, rect->w / 4, rect->h, value ); else CG_DrawField( rect->x, rect->y, 1, rect->w, rect->h, value ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index e68e94b..a1ff0a6 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -64,6 +64,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define MAX_MARK_POLYS 256 #define STAT_MINUS 10 // num frame for '-' stats digit +#define STAT_PERIOD 11 #define ICON_SIZE 48 #define CHAR_WIDTH 32 @@ -1174,7 +1175,7 @@ typedef struct qhandle_t scannerLineShader; - qhandle_t numberShaders[ 11 ]; + qhandle_t numberShaders[ 12 ]; qhandle_t shadowMarkShader; qhandle_t wakeMarkShader; @@ -1434,6 +1435,7 @@ extern vmCvar_t cg_teamOverlayUserinfo; extern vmCvar_t cg_crosshairX; extern vmCvar_t cg_crosshairY; extern vmCvar_t cg_drawSpeed; +extern vmCvar_t cg_drawFractionalEvos; extern vmCvar_t cg_drawStatus; extern vmCvar_t cg_draw2D; extern vmCvar_t cg_animSpeed; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 36a9577..ce32b0e 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -139,6 +139,7 @@ vmCvar_t cg_drawRewards; vmCvar_t cg_crosshairX; vmCvar_t cg_crosshairY; vmCvar_t cg_drawSpeed; +vmCvar_t cg_drawFractionalEvos; vmCvar_t cg_draw2D; vmCvar_t cg_drawStatus; vmCvar_t cg_animSpeed; @@ -285,6 +286,7 @@ static cvarTable_t cvarTable[ ] = { &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE }, { &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE }, { &cg_drawSpeed, "cg_drawSpeed", "0", CVAR_ARCHIVE }, + { &cg_drawFractionalEvos, "cg_drawFractionalEvos", "0", CVAR_ARCHIVE }, { &cg_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE }, { &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE }, { &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE }, @@ -972,7 +974,7 @@ This function may execute for a couple of minutes with a slow disk. static void CG_RegisterGraphics( void ) { int i; - static char *sb_nums[ 11 ] = + static char *sb_nums[ 12 ] = { "gfx/2d/numbers/zero_32b", "gfx/2d/numbers/one_32b", @@ -985,6 +987,7 @@ static void CG_RegisterGraphics( void ) "gfx/2d/numbers/eight_32b", "gfx/2d/numbers/nine_32b", "gfx/2d/numbers/minus_32b", + "gfx/2d/numbers/period_32b", }; static char *buildWeaponTimerPieShaders[ 8 ] = { @@ -1005,7 +1008,7 @@ static void CG_RegisterGraphics( void ) trap_R_LoadWorldMap( cgs.mapname ); CG_UpdateMediaFraction( 0.66f ); - for( i = 0; i < 11; i++ ) + for( i = 0; i < 12; i++ ) cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] ); cgs.media.viewBloodShader = trap_R_RegisterShader( "gfx/damage/fullscreen_painblend" ); |