diff options
author | enneract <trem.redman@gmail.com> | 2014-12-12 20:45:09 +0100 |
---|---|---|
committer | enneract <trem.redman@gmail.com> | 2014-12-12 20:45:09 +0100 |
commit | 964371805c751877c99ed2faeb8214355c2b3d6b (patch) | |
tree | 60cce1719928b9d8a376e0040841748e99cf3b84 /src/cgame | |
parent | 9d1b014b113ae04fe2d15ea12bf2e21b74f7df60 (diff) |
Flash BP display when MOD_NOBP kills a building.
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_draw.c | 53 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 9 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 2 |
3 files changed, 58 insertions, 6 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index a8331b1..e1ee2b7 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -1790,7 +1790,7 @@ static void CG_DrawBuildPoolReport( rectDef_t *rect, float text_x, float text_y, char out[ 20 ]; float tx, ty; - Com_sprintf( out, sizeof( out ), "%s", Info_ValueForKey( CG_ConfigString( CS_BUILD_POOLS ), ( humans ? "h" : "a" ) ) ); + Com_sprintf( out, sizeof( out ), "%d", ( humans ? cgs.humanBuildPool : cgs.alienBuildPool ) ); CG_AlignText( rect, out, scale, 0.0f, 0.0f, textalign, textvalign, &tx, &ty ); UI_Text_Paint( text_x + tx, text_y + ty, scale, color, out, 0, 0, textStyle ); @@ -1803,14 +1803,11 @@ CG_DrawBuildPoolBars */ static void CG_DrawBuildPoolBars( rectDef_t *rect, vec4_t color ) { - const char *cs; float abp, hbp, f; float x, y, w, h; - cs = CG_ConfigString( CS_BUILD_POOLS ); - - abp = atof( Info_ValueForKey( cs, "a" ) ) / atof( Info_ValueForKey( cs, "ad" ) ); - hbp = atof( Info_ValueForKey( cs, "h" ) ) / atof( Info_ValueForKey( cs, "hd" ) ); + abp = (float)cgs.alienBuildPool / (float)cgs.alienBuildPoolMax; + hbp = (float)cgs.humanBuildPool / (float)cgs.humanBuildPoolMax; if( fabs( abp + hbp ) < 1e-3 ) f = 0.5f; @@ -1841,6 +1838,35 @@ static void CG_DrawBuildPoolBars( rectDef_t *rect, vec4_t color ) /* ================== +CG_DrawNoBPFlash +================== +*/ +#define NOBP_FLASH_TIME 3000 +static void CG_DrawNoBPFlash( rectDef_t *rect, vec4_t color, qboolean humans ) +{ + vec4_t mcolor; + int flashTime; + + Vector4Copy( color, mcolor ); + flashTime = ( humans ? cgs.humanNoBPFlashTime : cgs.alienNoBPFlashTime ); + + if( flashTime == -1 ) + return; + + mcolor[ 3 ] *= 1.0f - ( (float)( cg.time - flashTime ) / NOBP_FLASH_TIME ); + + if( mcolor[ 3 ] <= 0 ) + return; + + trap_R_SetColor( mcolor ); + CG_DrawPic( rect->x, rect->y, rect->w, rect->h, + ( humans ? cgs.media.humanNoBPFlash : + cgs.media.alienNoBPFlash ) ); + trap_R_SetColor( NULL ); +} + +/* +================== CG_DrawFPS ================== */ @@ -3209,6 +3235,12 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, case CG_BUILD_POOL_BARS: CG_DrawBuildPoolBars( &rect, foreColor ); break; + case CG_ALIEN_NOBP_FLASH: + CG_DrawNoBPFlash( &rect, foreColor, qfalse ); + break; + case CG_HUMAN_NOBP_FLASH: + CG_DrawNoBPFlash( &rect, foreColor, qtrue ); + break; case CG_ALIENS_SCORE_LABEL: CG_DrawTeamLabel( &rect, TEAM_ALIENS, text_x, text_y, foreColor, scale, textalign, textvalign, textStyle ); break; @@ -3831,6 +3863,15 @@ static void CG_Draw2D( void ) if( cg_draw2D.integer == 0 ) return; + // this has to be here, CG_ConfigStringModified isn't reliable + sscanf( CG_ConfigString( CS_BUILD_POOLS ), "%d %d %d %d %d %d", + &cgs.alienBuildPool, + &cgs.alienBuildPoolMax, + &cgs.alienNoBPFlashTime, + &cgs.humanBuildPool, + &cgs.humanBuildPoolMax, + &cgs.humanNoBPFlashTime ); + if( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission( ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 097da54..10e89fd 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1339,6 +1339,8 @@ typedef struct qhandle_t alienBuildPoolBar; qhandle_t humanBuildPoolBar; + qhandle_t alienNoBPFlash; + qhandle_t humanNoBPFlash; } cgMedia_t; typedef struct @@ -1443,6 +1445,13 @@ typedef struct voice_t *voices; clientList_t ignoreList; + + int alienBuildPool; + int alienBuildPoolMax; + int alienNoBPFlashTime; + int humanBuildPool; + int humanBuildPoolMax; + int humanNoBPFlashTime; } cgs_t; typedef struct diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 8f3ceb7..3985834 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -824,6 +824,8 @@ static void CG_RegisterGraphics( void ) cgs.media.alienBuildPoolBar = trap_R_RegisterShader( "ui/assets/alien/build_pool_bar.tga" ); cgs.media.humanBuildPoolBar = trap_R_RegisterShader( "ui/assets/human/build_pool_bar.tga" ); + cgs.media.alienNoBPFlash = trap_R_RegisterShader( "ui/assets/alien/nobp_flash.tga" ); + cgs.media.humanNoBPFlash = trap_R_RegisterShader( "ui/assets/human/nobp_flash.tga" ); cgs.media.disconnectPS = CG_RegisterParticleSystem( "disconnectPS" ); |