From 9d1b014b113ae04fe2d15ea12bf2e21b74f7df60 Mon Sep 17 00:00:00 2001 From: enneract Date: Sun, 7 Dec 2014 20:53:38 +0100 Subject: Further improve on-HUD BP display. --- assets/scripts/system_ui.shader | 13 -------- assets/ui/assets/alien/build_pool_bar.tga | Bin 0 -> 9757 bytes assets/ui/assets/human/build_pool_bar.tga | Bin 0 -> 8222 bytes assets/ui/assets/neutral/build_pool_bg.tga | Bin 0 -> 13458 bytes assets/ui/assets/neutral/stagebar.tga | Bin 13458 -> 0 bytes assets/ui/assets/neutral/stagebar_add.jpg | Bin 5787 -> 0 bytes assets/ui/menudef.h | 1 + assets/ui/tremulous_common_hud.h | 15 +++++++-- src/cgame/cg_draw.c | 52 +++++++++++++++++++++++++---- src/cgame/cg_local.h | 3 ++ src/cgame/cg_main.c | 4 ++- src/game/g_main.c | 6 ++-- 12 files changed, 70 insertions(+), 24 deletions(-) create mode 100644 assets/ui/assets/alien/build_pool_bar.tga create mode 100644 assets/ui/assets/human/build_pool_bar.tga create mode 100644 assets/ui/assets/neutral/build_pool_bg.tga delete mode 100644 assets/ui/assets/neutral/stagebar.tga delete mode 100644 assets/ui/assets/neutral/stagebar_add.jpg diff --git a/assets/scripts/system_ui.shader b/assets/scripts/system_ui.shader index 2f9ef9b..4650ee0 100644 --- a/assets/scripts/system_ui.shader +++ b/assets/scripts/system_ui.shader @@ -189,16 +189,3 @@ ui/assets/neutral/squad_v } } -ui/assets/neutral/stagebar -{ - nomipmaps - { - map ui/assets/neutral/stagebar.tga - blendFunc blend - } - { - map ui/assets/neutral/stagebar_add.jpg - blendFunc add - } -} - diff --git a/assets/ui/assets/alien/build_pool_bar.tga b/assets/ui/assets/alien/build_pool_bar.tga new file mode 100644 index 0000000..38fad1a Binary files /dev/null and b/assets/ui/assets/alien/build_pool_bar.tga differ diff --git a/assets/ui/assets/human/build_pool_bar.tga b/assets/ui/assets/human/build_pool_bar.tga new file mode 100644 index 0000000..08b2b4d Binary files /dev/null and b/assets/ui/assets/human/build_pool_bar.tga differ diff --git a/assets/ui/assets/neutral/build_pool_bg.tga b/assets/ui/assets/neutral/build_pool_bg.tga new file mode 100644 index 0000000..458511b Binary files /dev/null and b/assets/ui/assets/neutral/build_pool_bg.tga differ diff --git a/assets/ui/assets/neutral/stagebar.tga b/assets/ui/assets/neutral/stagebar.tga deleted file mode 100644 index a21ec7e..0000000 Binary files a/assets/ui/assets/neutral/stagebar.tga and /dev/null differ diff --git a/assets/ui/assets/neutral/stagebar_add.jpg b/assets/ui/assets/neutral/stagebar_add.jpg deleted file mode 100644 index a8b0a33..0000000 Binary files a/assets/ui/assets/neutral/stagebar_add.jpg and /dev/null differ diff --git a/assets/ui/menudef.h b/assets/ui/menudef.h index 30ce6a2..411f987 100644 --- a/assets/ui/menudef.h +++ b/assets/ui/menudef.h @@ -198,6 +198,7 @@ enum CG_STAGE_REPORT_TEXT, CG_ALIEN_BUILD_POOL, CG_HUMAN_BUILD_POOL, + CG_BUILD_POOL_BARS, CG_ALIENS_SCORE_LABEL, CG_HUMANS_SCORE_LABEL, CG_DEMO_PLAYBACK, diff --git a/assets/ui/tremulous_common_hud.h b/assets/ui/tremulous_common_hud.h index cecd114..5c0029a 100644 --- a/assets/ui/tremulous_common_hud.h +++ b/assets/ui/tremulous_common_hud.h @@ -213,10 +213,21 @@ itemDef aspectBias ALIGN_CENTER visible 1 foreColor 1 1 1 0.5 - background "ui/assets/neutral/stagebar" + background "ui/assets/neutral/build_pool_bg" decoration } +itemDef +{ + name "bpbars" + rect 160 -5 320 40 + aspectBias ALIGN_CENTER + visible 1 + foreColor 1 1 1 0.5 + decoration + ownerDraw CG_BUILD_POOL_BARS +} + itemDef { name "stagereport" @@ -228,7 +239,7 @@ itemDef visible 1 decoration textScale .22 - textStyle ITEM_TEXTSTYLE_NORMAL + textStyle ITEM_TEXTSTYLE_SHADOWED ownerdraw CG_STAGE_REPORT_TEXT } diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 1001a30..a8331b1 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -1735,9 +1735,6 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, char s[ MAX_TOKEN_CHARS ]; float tx, ty; - if( cg.intermissionStarted ) - return; - if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_NONE ) // return; { @@ -1793,15 +1790,55 @@ static void CG_DrawBuildPoolReport( rectDef_t *rect, float text_x, float text_y, char out[ 20 ]; float tx, ty; - if( cg.intermissionStarted ) - return; - Com_sprintf( out, sizeof( out ), "%s", Info_ValueForKey( CG_ConfigString( CS_BUILD_POOLS ), ( humans ? "h" : "a" ) ) ); 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 ); } +/* +================== +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" ) ); + + if( fabs( abp + hbp ) < 1e-3 ) + f = 0.5f; + else + f = ( ( abp - hbp ) / ( abp + hbp ) + 1.0f ) / 2.0f; + + f = ( f < 0.0f ) ? 0.0f : ( f > 1.0f ) ? 1.0f : f; + f = f * 0.55f + 0.225f; + + trap_R_SetColor( color ); + + x = rect->x; + y = rect->y; + w = rect->w * f; + h = rect->h; + CG_AdjustFrom640( &x, &y, &w, &h ); + trap_R_DrawStretchPic( x, y, w, h, 0, 0, f, 1, cgs.media.alienBuildPoolBar ); + + x = rect->x + rect->w * f; + y = rect->y; + w = rect->w * ( 1.0f - f ); + h = rect->h; + CG_AdjustFrom640( &x, &y, &w, &h ); + trap_R_DrawStretchPic( x, y, w, h, f, 0, 1, 1, cgs.media.humanBuildPoolBar ); + + trap_R_SetColor( NULL ); +} + /* ================== CG_DrawFPS @@ -3169,6 +3206,9 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, case CG_HUMAN_BUILD_POOL: CG_DrawBuildPoolReport( &rect, text_x, text_y, foreColor, scale, textalign, textvalign, textStyle, qtrue ); break; + case CG_BUILD_POOL_BARS: + CG_DrawBuildPoolBars( &rect, foreColor ); + break; case CG_ALIENS_SCORE_LABEL: CG_DrawTeamLabel( &rect, TEAM_ALIENS, text_x, text_y, foreColor, scale, textalign, textvalign, textStyle ); break; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index a477336..097da54 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1336,6 +1336,9 @@ typedef struct qhandle_t headShotPS; qhandle_t humanWoundsBleedPS; qhandle_t alienWoundsBleedPS; + + qhandle_t alienBuildPoolBar; + qhandle_t humanBuildPoolBar; } cgMedia_t; typedef struct diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index b7885ec..8f3ceb7 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -821,7 +821,9 @@ static void CG_RegisterGraphics( void ) cgs.media.healthCrossPoisoned = trap_R_RegisterShader( "ui/assets/neutral/cross_poison.tga" ); cgs.media.upgradeClassIconShader = trap_R_RegisterShader( "icons/icona_upgrade.tga" ); - + + 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.disconnectPS = CG_RegisterParticleSystem( "disconnectPS" ); diff --git a/src/game/g_main.c b/src/game/g_main.c index f41d8d3..62df632 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -1405,9 +1405,11 @@ void G_CalculateBuildPoints( void ) level.alienBuildPoints += level.alienExtraBuildPoints; } - trap_SetConfigstring( CS_BUILD_POOLS, va( "a\\%d\\h\\%d", + trap_SetConfigstring( CS_BUILD_POOLS, va( "a\\%d\\ad\\%d\\h\\%d\\hd\\%d", g_alienBuildPoints.integer + level.alienExtraBuildPoints, - g_humanBuildPoints.integer + level.humanExtraBuildPoints ) ); + g_alienBuildPoints.integer, + g_humanBuildPoints.integer + level.humanExtraBuildPoints, + g_humanBuildPoints.integer ) ); //zero bp not allowed // if( level.humanBuildPoints < 0 ) -- cgit