From f639515054b2122c7166793f7c0a0a751087209f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Fri, 3 Apr 2015 13:51:24 +0200 Subject: Make health bars customizable with cvars. --- src/cgame/cg_draw.c | 4 ++-- src/cgame/cg_local.h | 3 +++ src/cgame/cg_main.c | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/cgame') diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 340a207..64e5ed7 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -4063,12 +4063,12 @@ static void CG_DrawHealthBars( void ) hf = (float)bar->value / bar->max; - h = 20 * 100 / bar->dist; + h = cg_healthBarSize.value / bar->dist; w = 4 * h * cgDC.aspectScale; Com_sprintf( buffer, sizeof( buffer ), "%d", bar->value ); - color[ 3 ] = 1.0f; + color[ 3 ] = cg_healthBarAlpha.value; VectorSet( color, 0.1, 0.7, 0.1 ); trap_R_SetColor( color ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index bb38c41..83cac63 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1610,6 +1610,9 @@ extern vmCvar_t cg_viewQuakeLimit; extern vmCvar_t cg_damageBlobSize; extern vmCvar_t cg_damageBlobAlpha; +extern vmCvar_t cg_healthBarSize; +extern vmCvar_t cg_healthBarAlpha; + // // cg_main.c // diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 714b0d8..0fdb028 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -235,6 +235,9 @@ vmCvar_t cg_viewQuakeLimit; vmCvar_t cg_damageBlobSize; vmCvar_t cg_damageBlobAlpha; +vmCvar_t cg_healthBarSize; +vmCvar_t cg_healthBarAlpha; + typedef struct { vmCvar_t *vmCvar; @@ -385,7 +388,10 @@ static cvarTable_t cvarTable[ ] = { &cg_viewQuakeLimit, "cg_viewQuakeLimit", "5", CVAR_ARCHIVE }, { &cg_damageBlobSize, "cg_damageBlobSize", "400", CVAR_ARCHIVE }, - { &cg_damageBlobAlpha, "cg_damageBlobAlpha", "0.8", CVAR_ARCHIVE } + { &cg_damageBlobAlpha, "cg_damageBlobAlpha", "0.8", CVAR_ARCHIVE }, + + { &cg_healthBarSize, "cg_healthBarSize", "2000", CVAR_ARCHIVE }, + { &cg_healthBarAlpha, "cg_healthBarAlpha", "0.5", CVAR_ARCHIVE } }; static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); -- cgit