summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2015-04-04 12:33:20 +0200
committerPaweł Redman <pawel.redman@gmail.com>2015-04-04 12:33:20 +0200
commiteb30895efbad7f5f1ca5d943dbe87ebcd3502fa3 (patch)
tree45979666162f6a1177320d7c28ecf452746c7ad1
parentf3008f9819d57b671a424a0097f50c93926af74e (diff)
Improve numbers_alt, make health bars' colors change depending on the health, make health bars not appear on entities with 100% health.
-rw-r--r--assets/gfx/2d/numbers_alt/0.tgabin1038 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/1.tgabin772 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/2.tgabin854 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/3.tgabin786 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/4.tgabin860 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/5.tgabin834 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/6.tgabin904 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/7.tgabin710 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/8.tgabin1102 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/9.tgabin904 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/minus.tgabin282 -> 12306 bytes
-rw-r--r--assets/gfx/2d/numbers_alt/slash.tgabin0 -> 12306 bytes
-rw-r--r--src/cgame/cg_draw.c54
-rw-r--r--src/cgame/cg_local.h2
-rw-r--r--src/cgame/cg_main.c5
15 files changed, 36 insertions, 25 deletions
diff --git a/assets/gfx/2d/numbers_alt/0.tga b/assets/gfx/2d/numbers_alt/0.tga
index ed72ed5..73afce3 100644
--- a/assets/gfx/2d/numbers_alt/0.tga
+++ b/assets/gfx/2d/numbers_alt/0.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/1.tga b/assets/gfx/2d/numbers_alt/1.tga
index 8267352..787a23f 100644
--- a/assets/gfx/2d/numbers_alt/1.tga
+++ b/assets/gfx/2d/numbers_alt/1.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/2.tga b/assets/gfx/2d/numbers_alt/2.tga
index 92414db..68d71a5 100644
--- a/assets/gfx/2d/numbers_alt/2.tga
+++ b/assets/gfx/2d/numbers_alt/2.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/3.tga b/assets/gfx/2d/numbers_alt/3.tga
index 862606a..3c60a17 100644
--- a/assets/gfx/2d/numbers_alt/3.tga
+++ b/assets/gfx/2d/numbers_alt/3.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/4.tga b/assets/gfx/2d/numbers_alt/4.tga
index bd7e6cc..43124f1 100644
--- a/assets/gfx/2d/numbers_alt/4.tga
+++ b/assets/gfx/2d/numbers_alt/4.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/5.tga b/assets/gfx/2d/numbers_alt/5.tga
index 0de619f..42ae6ec 100644
--- a/assets/gfx/2d/numbers_alt/5.tga
+++ b/assets/gfx/2d/numbers_alt/5.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/6.tga b/assets/gfx/2d/numbers_alt/6.tga
index 770ee54..747b73e 100644
--- a/assets/gfx/2d/numbers_alt/6.tga
+++ b/assets/gfx/2d/numbers_alt/6.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/7.tga b/assets/gfx/2d/numbers_alt/7.tga
index cf173e7..4431943 100644
--- a/assets/gfx/2d/numbers_alt/7.tga
+++ b/assets/gfx/2d/numbers_alt/7.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/8.tga b/assets/gfx/2d/numbers_alt/8.tga
index 21a0b54..5339ef6 100644
--- a/assets/gfx/2d/numbers_alt/8.tga
+++ b/assets/gfx/2d/numbers_alt/8.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/9.tga b/assets/gfx/2d/numbers_alt/9.tga
index d548695..f05f81c 100644
--- a/assets/gfx/2d/numbers_alt/9.tga
+++ b/assets/gfx/2d/numbers_alt/9.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/minus.tga b/assets/gfx/2d/numbers_alt/minus.tga
index 2129858..d7570d5 100644
--- a/assets/gfx/2d/numbers_alt/minus.tga
+++ b/assets/gfx/2d/numbers_alt/minus.tga
Binary files differ
diff --git a/assets/gfx/2d/numbers_alt/slash.tga b/assets/gfx/2d/numbers_alt/slash.tga
new file mode 100644
index 0000000..f44acda
--- /dev/null
+++ b/assets/gfx/2d/numbers_alt/slash.tga
Binary files differ
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 2c6645f..92e64b5 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -3888,7 +3888,7 @@ static void CG_DrawNumber( float x, float y, float h, char *str )
char *p;
len = strlen( str );
- w = h * cgDC.aspectScale * 0.5f;
+ w = h * cgDC.aspectScale * 0.75f;
y -= h / 2;
x -= len * w / 2;
@@ -3897,10 +3897,14 @@ static void CG_DrawNumber( float x, float y, float h, char *str )
{
if( *p >= '0' && *p <= '9' )
index = *p - '0';
- else
+ else if( *p == '.' )
index = 10;
-
- CG_DrawPic( x, y, w, h, cgs.media.numberShadersAlt[ index ] );
+ else
+ index = 11;
+
+ if( *p != ' ' )
+ CG_DrawPic( x, y, w, h, cgs.media.numberShadersAlt[ index ] );
+
x += w;
}
}
@@ -3984,7 +3988,7 @@ typedef struct
static int CompareHealthBars( const healthBar_t *a, const healthBar_t *b )
{
- return a->dist < b->dist;
+ return ( a->dist < b->dist ? 1 : -1 );
}
static void CG_DrawHealthBars( void )
@@ -4047,44 +4051,50 @@ static void CG_DrawHealthBars( void )
qsort( bars, bare - bars, sizeof( healthBar_t ),
(int(*)(const void*,const void*))CompareHealthBars );
-/*
- TODO: figure out why qsort fails for more than 5 bars
-
- for( i = 0; i < bare - bars - 1; i++ )
- if( CompareHealthBars( bars + i, bars + i + 1 ) )
- {
- Com_Printf( "qsort is retarded\n" );
- break;
- }
-*/
-
for( bar = bars; bar < bare; bar++ )
{
- float x, y, w, h, hf;
+ float x, y, w, h, hf, cf;
char buffer[ 64 ];
vec4_t color;
+ if( bar->value >= bar->max )
+ continue;
+
if( !CG_WorldToScreen( bar->origin, &x, &y ) )
continue;
hf = (float)bar->value / bar->max;
h = cg_healthBarSize.value / bar->dist;
- w = 4 * h * cgDC.aspectScale;
+ w = 6 * h * cgDC.aspectScale;
- Com_sprintf( buffer, sizeof( buffer ), "%d", bar->value );
+ Com_sprintf( buffer, sizeof( buffer ), "%d/%d", bar->value, bar->max );
color[ 3 ] = cg_healthBarAlpha.value;
- VectorSet( color, 0.1, 0.7, 0.1 );
+ if( hf <= 1.0f && hf > 0.5f )
+ {
+ cf = ( hf - 0.5f ) / 0.5f;
+ VectorSet( color, 1 - cf, 1.0f, 0.0f );
+ }
+ else
+ {
+ cf = hf / 0.5f;
+ VectorSet( color, 1.0f, cf, 0.0f );
+ }
+
+ VectorScale( color, 0.5f, color );
+
trap_R_SetColor( color );
CG_DrawPic( x - w/2, y - h/2, w * hf, h, cgs.media.whiteShader );
- VectorSet( color, 0.7, 0.1, 0.1 );
+
+
+ VectorSet( color, 0.1, 0.1, 0.1 );
trap_R_SetColor( color );
CG_DrawPic( x - w/2 + w * hf, y - h/2, w * ( 1 - hf ), h, cgs.media.whiteShader );
- VectorSet( color, 0, 0, 0 );
+ VectorSet( color, 1, 1, 1 );
trap_R_SetColor( color );
CG_DrawNumber( x, y, h, buffer );
}
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 83cac63..2d2598c 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1198,7 +1198,7 @@ typedef struct
qhandle_t teamOverlayShader;
qhandle_t numberShaders[ 11 ];
- qhandle_t numberShadersAlt[ 11 ];
+ qhandle_t numberShadersAlt[ 12 ];
qhandle_t shadowMarkShader;
qhandle_t wakeMarkShader;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 0fdb028..9e51258 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -781,7 +781,7 @@ static void CG_RegisterGraphics( void )
"gfx/2d/numbers/nine_32b",
"gfx/2d/numbers/minus_32b",
};
- static char *sb_nums_alt[ 11 ] =
+ static char *sb_nums_alt[ 12 ] =
{
"gfx/2d/numbers_alt/0",
"gfx/2d/numbers_alt/1",
@@ -794,6 +794,7 @@ static void CG_RegisterGraphics( void )
"gfx/2d/numbers_alt/8",
"gfx/2d/numbers_alt/9",
"gfx/2d/numbers_alt/minus",
+ "gfx/2d/numbers_alt/slash",
};
static char *buildWeaponTimerPieShaders[ 8 ] =
{
@@ -817,7 +818,7 @@ static void CG_RegisterGraphics( void )
for( i = 0; i < 11; i++ )
cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] );
- for( i = 0; i < 11; i++ )
+ for( i = 0; i < 12; i++ )
cgs.media.numberShadersAlt[ i ] = trap_R_RegisterShader( sb_nums_alt[ i ] );
cgs.media.viewBloodShader = trap_R_RegisterShader( "gfx/damage/fullscreen_painblend" );