summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-16 21:55:45 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:52 +0000
commit3389e221f87765a77e5ee268f1b56d2de2ac73a0 (patch)
tree90dbb9ca62f75b21d93c71ddd03a8d33749afe41
parent81cd07825027f7bb554d73977498e9490827553e (diff)
* (bug 4265) Fix buildable health display not accomodating cg_viewsize (Rezyn)
-rw-r--r--src/cgame/cg_buildable.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index db6eb539..c099b14d 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -814,7 +814,20 @@ void CG_BuildableStatusParse( const char *filename, buildStat_t *bs )
trap_Parse_FreeSource( handle );
}
-#define STATUS_FADE_TIME 200
+static void CG_ViewScaleGeometry( float x, float y, float w, float h,
+ float *sx, float *sy, float *sw, float *sh, float scale )
+{
+ if( sx )
+ *sx = 320.0f - 320.0f * scale + x * scale;
+ if( sy )
+ *sy = 240.0f - 240.0f * scale + y * scale;
+ if( sw )
+ *sw = w * scale;
+ if( sh )
+ *sh = h * scale;
+}
+
+#define STATUS_FADE_TIME 200.0f
#define STATUS_MAX_VIEW_DIST 900.0f
#define STATUS_PEEK_DIST 20
/*
@@ -972,11 +985,14 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
float picX = x;
float picY = y;
float scale;
+ float viewscale;
float subH, subY;
+ float sX, sY, sW, sH;
vec4_t frameColor;
// this is fudged to get the width/height in the cfg to be more realistic
- scale = ( picH / d ) * 3;
+ scale = ( picH / d ) * 3.0f;
+ viewscale = (float)cg_viewsize.integer / 100.0f;
powered = es->eFlags & EF_B_POWERED;
marked = es->eFlags & EF_B_MARKED;
@@ -990,12 +1006,16 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
subH = picH - ( picH * bs->verticalMargin );
subY = picY + ( picH * 0.5f ) - ( subH * 0.5f );
+ CG_ViewScaleGeometry( 0.0f, 0.0f, 640.0f, 480.0f, &sX, &sY, &sW, &sH, viewscale );
+ CG_SetClipRegion( sX, sY, sW, sH );
+
if( bs->frameShader )
{
Vector4Copy( bs->backColor, frameColor );
frameColor[ 3 ] = color[ 3 ];
trap_R_SetColor( frameColor );
- CG_DrawPic( picX, picY, picW, picH, bs->frameShader );
+ CG_ViewScaleGeometry( picX, picY, picW, picH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawPic( sX, sY, sW, sH, bs->frameShader );
trap_R_SetColor( NULL );
}
@@ -1023,7 +1043,8 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
healthColor[ 3 ] = color[ 3 ];
trap_R_SetColor( healthColor );
- CG_DrawPic( hX, hY, hW, hH, cgs.media.whiteShader );
+ CG_ViewScaleGeometry( hX, hY, hW, hH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawPic( sX, sY, sW, sH, cgs.media.whiteShader );
trap_R_SetColor( NULL );
}
@@ -1040,7 +1061,8 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
oY -= ( oH * 0.5f );
trap_R_SetColor( frameColor );
- CG_DrawPic( oX, oY, oW, oH, bs->overlayShader );
+ CG_ViewScaleGeometry( oX, oY, oW, oH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawPic( sX, sY, sW, sH, bs->overlayShader );
trap_R_SetColor( NULL );
}
@@ -1050,7 +1072,8 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
float pX;
pX = picX + ( subH * bs->horizontalMargin );
- CG_DrawPic( pX, subY, subH, subH, bs->noPowerShader );
+ CG_ViewScaleGeometry( pX, subY, subH, subH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawPic( sX, sY, sH, sH, bs->noPowerShader );
}
if( marked )
@@ -1058,11 +1081,13 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
float mX;
mX = picX + picW - ( subH * bs->horizontalMargin ) - subH;
- CG_DrawPic( mX, subY, subH, subH, bs->markedShader );
+ CG_ViewScaleGeometry( mX, subY, subH, subH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawPic( sX, sY, sH, sH, bs->markedShader );
}
{
float nX;
+ float cW;
int healthMax;
int healthPoints;
@@ -1070,19 +1095,22 @@ static void CG_BuildableStatusDisplay( centity_t *cent )
healthPoints = (int)( healthScale * healthMax );
if( health > 0 && healthPoints < 1 )
healthPoints = 1;
- nX = picX + ( picW * 0.5f ) - 2.0f - ( ( subH * 4 ) * 0.5f );
+ cW = subH * CHAR_WIDTH / CHAR_HEIGHT;
+ nX = picX + ( picW * 0.5f ) - 2.0f - ( ( cW * 4.0f ) * 0.5f );
if( healthPoints > 999 )
nX -= 0.0f;
else if( healthPoints > 99 )
- nX -= subH * 0.5f;
+ nX -= cW * 0.5f;
else if( healthPoints > 9 )
- nX -= subH * 1.0f;
+ nX -= cW * 1.0f;
else
- nX -= subH * 1.5f;
+ nX -= cW * 1.5f;
- CG_DrawField( nX, subY, 4, subH, subH, healthPoints );
+ CG_ViewScaleGeometry( nX, subY, cW, subH, &sX, &sY, &sW, &sH, viewscale );
+ CG_DrawField( sX, sY, 4, sW, sH, healthPoints );
}
+ CG_ClearClipRegion( );
trap_R_SetColor( NULL );
}
}