diff options
author | Christopher Schwarz <lakitu7@gmail.com> | 2011-02-21 08:37:02 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:18:01 +0000 |
commit | cf1f5dc37a767c2ebe3c88fc106a23e5cc13b15a (patch) | |
tree | 23ee24c2113cc32eadc648a77c8b766d141c95a7 | |
parent | 194bcc454fa4964185c721577d3605fe11a97660 (diff) |
* (bug 4908) Show BP from marked buildables on the HUD
-rw-r--r-- | assets/ui/tremulous_alien_builder_hud.menu | 2 | ||||
-rw-r--r-- | assets/ui/tremulous_human_hud.menu | 2 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 39 | ||||
-rw-r--r-- | src/game/bg_public.h | 5 | ||||
-rw-r--r-- | src/game/g_active.c | 4 | ||||
-rw-r--r-- | src/game/g_buildable.c | 52 | ||||
-rw-r--r-- | src/game/g_local.h | 3 |
7 files changed, 97 insertions, 10 deletions
diff --git a/assets/ui/tremulous_alien_builder_hud.menu b/assets/ui/tremulous_alien_builder_hud.menu index 4822bb29..b5322646 100644 --- a/assets/ui/tremulous_alien_builder_hud.menu +++ b/assets/ui/tremulous_alien_builder_hud.menu @@ -31,7 +31,7 @@ itemDef { name "build-points" - rect 483.5 421.5 60 15 + rect 493.5 421.5 60 15 aspectBias ALIGN_RIGHT visible MENU_TRUE decoration diff --git a/assets/ui/tremulous_human_hud.menu b/assets/ui/tremulous_human_hud.menu index 114214a1..f2b4ca99 100644 --- a/assets/ui/tremulous_human_hud.menu +++ b/assets/ui/tremulous_human_hud.menu @@ -254,7 +254,7 @@ itemDef { name "ammo" - rect 494 430 60 15 + rect 507 430 53 15 aspectBias ALIGN_RIGHT visible MENU_TRUE decoration diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 3793d947..9797e779 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -636,6 +636,8 @@ static void CG_DrawPlayerWallclimbing( rectDef_t *rect, vec4_t backColor, vec4_t static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color ) { int value; + int valueMarked = -1; + qboolean bp = qfalse; switch( BG_PrimaryWeapon( cg.snap->ps.stats ) ) { @@ -647,6 +649,8 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color ) case WP_ABUILD2: case WP_HBUILD: value = cg.snap->ps.persistant[ PERS_BP ]; + valueMarked = cg.snap->ps.persistant[ PERS_MARKEDBP ]; + bp = qtrue; break; default: @@ -656,11 +660,44 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color ) if( value > 999 ) value = 999; + if( valueMarked > 999 ) + valueMarked = 999; if( value > -1 ) { + float tx, ty; + char *text; + float scale; + int len; + trap_R_SetColor( color ); - CG_DrawField( rect->x, rect->y, 4, rect->w / 4, rect->h, value ); + if( !bp ) + { + CG_DrawField( rect->x - 5, rect->y, 4, rect->w / 4, rect->h, value ); + trap_R_SetColor( NULL ); + return; + } + + if( valueMarked > 0 ) + text = va( "%d+(%d)", value, valueMarked ); + else + text = va( "%d", value ); + + len = strlen( text ); + + if( len <= 4 ) + scale = 0.50; + else if( len <= 6 ) + scale = 0.43; + else if( len == 7 ) + scale = 0.36; + else if( len == 8 ) + scale = 0.33; + else if( len >= 9 ) + scale = 0.31; + + CG_AlignText( rect, text, scale, 0.0f, 0.0f, ALIGN_RIGHT, VALIGN_CENTER, &tx, &ty ); + UI_Text_Paint( tx + 1, ty, scale, color, text, 0, 0, ITEM_TEXTSTYLE_NORMAL ); trap_R_SetColor( NULL ); } } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index eb6bb8af..6ba46f6e 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -274,8 +274,9 @@ typedef enum PERS_CREDIT, // human credit PERS_QUEUEPOS, // position in the spawn queue PERS_NEWWEAPON, // weapon to switch to - PERS_BP - // netcode has space for 4 more + PERS_BP, + PERS_MARKEDBP + // netcode has space for 3 more } persEnum_t; #define PS_WALLCLIMBINGFOLLOW 0x00000001 diff --git a/src/game/g_active.c b/src/game/g_active.c index 89882760..a7cd08c0 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1713,7 +1713,9 @@ void ClientThink_real( gentity_t *ent ) } client->ps.persistant[ PERS_BP ] = G_GetBuildPoints( client->ps.origin, - client->ps.stats[ STAT_TEAM ], BG_Class( client->ps.stats[ STAT_CLASS ] )->buildDist ); + client->ps.stats[ STAT_TEAM ] ); + client->ps.persistant[ PERS_MARKEDBP ] = G_GetMarkedBuildPoints( client->ps.origin, + client->ps.stats[ STAT_TEAM ] ); if( client->ps.persistant[ PERS_BP ] < 0 ) client->ps.persistant[ PERS_BP ] = 0; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index dd603309..2be2bf45 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -335,7 +335,7 @@ G_GetBuildPoints Get the number of build points from a position ================== */ -int G_GetBuildPoints( const vec3_t pos, team_t team, int extraDistance ) +int G_GetBuildPoints( const vec3_t pos, team_t team ) { if( G_TimeTilSuddenDeath( ) <= 0 ) { @@ -368,6 +368,52 @@ int G_GetBuildPoints( const vec3_t pos, team_t team, int extraDistance ) /* ================== +G_GetMarkedBuildPoints + +Get the number of marked build points from a position +================== +*/ +int G_GetMarkedBuildPoints( const vec3_t pos, team_t team ) +{ + gentity_t *ent; + int i; + int sum = 0; + + if( G_TimeTilSuddenDeath( ) <= 0 ) + return 0; + + if( !g_markDeconstruct.integer ) + return 0; + + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + { + if( ent->s.eType != ET_BUILDABLE ) + continue; + + if( team == TEAM_HUMANS && + ent->s.modelindex != BA_H_REACTOR && + ent->s.modelindex != BA_H_REPEATER && + ent->parentNode != G_PowerEntityForPoint( pos ) ) + continue; + + if( !ent->inuse ) + continue; + + if( ent->health <= 0 ) + continue; + + if( ent->buildableTeam != team ) + continue; + + if( ent->deconstruct ) + sum += BG_Buildable( ent->s.modelindex )->buildPoints; + } + + return sum; +} + +/* +================== G_InPowerZone See if a buildable is inside of another power zone. @@ -3053,7 +3099,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, if( team == TEAM_ALIENS ) { - remainingBP = G_GetBuildPoints( origin, team, 0 ); + remainingBP = G_GetBuildPoints( origin, team ); remainingSpawns = level.numAlienSpawns; bpError = IBE_NOALIENBP; spawn = BA_A_SPAWN; @@ -3064,7 +3110,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, if( buildable == BA_H_REACTOR || buildable == BA_H_REPEATER ) remainingBP = level.humanBuildPoints; else - remainingBP = G_GetBuildPoints( origin, team, 0 ); + remainingBP = G_GetBuildPoints( origin, team ); remainingSpawns = level.numHumanSpawns; bpError = IBE_NOHUMANBP; diff --git a/src/game/g_local.h b/src/game/g_local.h index 703e305e..a420d39e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -796,7 +796,8 @@ void G_LayoutLoad( void ); void G_BaseSelfDestruct( team_t team ); int G_NextQueueTime( int queuedBP, int totalBP, int queueBaseRate ); void G_QueueBuildPoints( gentity_t *self ); -int G_GetBuildPoints( const vec3_t pos, team_t team, int dist ); +int G_GetBuildPoints( const vec3_t pos, team_t team ); +int G_GetMarkedBuildPoints( const vec3_t pos, team_t team ); qboolean G_FindPower( gentity_t *self, qboolean searchUnspawned ); gentity_t *G_PowerEntityForPoint( const vec3_t origin ); gentity_t *G_PowerEntityForEntity( gentity_t *ent ); |