Skip to content

Commit

Permalink
Apply patch for Flexible HUD r1
Browse files Browse the repository at this point in the history
This didn't originally get checked into git.

ztm-flexible-hud-r1.pk3/scaleable_hud.diff : November 07 2013 3:21am
  • Loading branch information
zturtleman committed Mar 31, 2024
1 parent fd4cd66 commit 18ee65f
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 20 deletions.
115 changes: 102 additions & 13 deletions code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ static void CG_DrawField (int x, int y, int width, int value) {
l = width;
x += 2 + CHAR_WIDTH*(width - l);

// center x, move y to bottom.
x += (1.0f-cg_statusScale.value)*l*CHAR_WIDTH*0.5f;
y += (1.0f-cg_statusScale.value)*CHAR_HEIGHT;

ptr = num;
while (*ptr && l)
{
Expand All @@ -256,8 +260,8 @@ static void CG_DrawField (int x, int y, int width, int value) {
else
frame = *ptr -'0';

CG_DrawPic( x,y, CHAR_WIDTH, CHAR_HEIGHT, cgs.media.numberShaders[frame] );
x += CHAR_WIDTH;
CG_DrawPic( x,y, CHAR_WIDTH*cg_statusScale.value, CHAR_HEIGHT*cg_statusScale.value, cgs.media.numberShaders[frame] );
x += CHAR_WIDTH*cg_statusScale.value;
ptr++;
l--;
}
Expand Down Expand Up @@ -308,6 +312,58 @@ void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandl
trap_R_RenderScene( &refdef );
}

/*
================
CG_DrawHealthModel
================
*/
void CG_DrawHealthModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, qhandle_t model2, vec3_t origin, vec3_t angles, float yaw2 ) {
refdef_t refdef;
refEntity_t ent;

if ( !cg_draw3dIcons.integer || !cg_drawIcons.integer ) {
return;
}

CG_AdjustFrom640( &x, &y, &w, &h );

memset( &refdef, 0, sizeof( refdef ) );

memset( &ent, 0, sizeof( ent ) );
AnglesToAxis( angles, ent.axis );
VectorCopy( origin, ent.origin );
ent.hModel = model;
ent.customSkin = skin;
ent.renderfx = RF_NOSHADOW; // no stencil shadows

refdef.rdflags = RDF_NOWORLDMODEL;

AxisClear( refdef.viewaxis );

refdef.fov_x = 30;
refdef.fov_y = 30;

refdef.x = x;
refdef.y = y;
refdef.width = w;
refdef.height = h;

refdef.time = cg.time;

trap_R_ClearScene();
trap_R_AddRefEntityToScene( &ent );

if ( model2 ) {
ent.hModel = model2;
angles[YAW] = yaw2;
AnglesToAxis( angles, ent.axis );
trap_R_AddRefEntityToScene( &ent );
}

trap_R_RenderScene( &refdef );
}

/*
================
CG_DrawHead
Expand Down Expand Up @@ -471,7 +527,7 @@ static void CG_DrawStatusBarHead( float x ) {
angles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;
angles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;

CG_DrawHead( x, 480 - size, size, size,
CG_DrawHead( x+(1.0f-cg_statusScale.value)*size*0.5f, 480 - size*cg_statusScale.value, size*cg_statusScale.value, size*cg_statusScale.value,
cg.snap->ps.clientNum, angles );
}
#endif // MISSIONPACK
Expand All @@ -484,7 +540,8 @@ CG_DrawStatusBarFlag
*/
#ifndef MISSIONPACK
static void CG_DrawStatusBarFlag( float x, int team ) {
CG_DrawFlagModel( x, 480 - ICON_SIZE, ICON_SIZE, ICON_SIZE, team, qfalse );
int iconSize = ICON_SIZE*cg_statusScale.value;
CG_DrawFlagModel( x+(1.0f-cg_statusScale.value)*ICON_SIZE*0.5f, 480 - iconSize, iconSize, iconSize, team, qfalse );
}
#endif // MISSIONPACK

Expand Down Expand Up @@ -530,6 +587,7 @@ static void CG_DrawStatusBar( void ) {
vec4_t hcolor;
vec3_t angles;
vec3_t origin;
float scale, iconSize;

static float colors[4][4] = {
// { 0.2, 1.0, 0.2, 1.0 } , { 1.0, 0.2, 0.2, 1.0 }, {0.5, 0.5, 0.5, 1} };
Expand All @@ -542,8 +600,12 @@ static void CG_DrawStatusBar( void ) {
return;
}

scale = Com_Clamp( 0.1f, 2, cg_statusScale.value);

iconSize = scale * ICON_SIZE;

// draw the team background
CG_DrawTeamBackground( 0, 420, 640, 60, 0.33f, cg.snap->ps.persistant[PERS_TEAM] );
CG_DrawTeamBackground( 0, 480 - 60*scale, 640, 60*scale, 0.33f, cg.snap->ps.persistant[PERS_TEAM] );

cent = &cg_entities[cg.snap->ps.clientNum];
ps = &cg.snap->ps;
Expand All @@ -556,11 +618,25 @@ static void CG_DrawStatusBar( void ) {
origin[1] = 0;
origin[2] = 0;
angles[YAW] = 90 + 20 * sin( cg.time / 1000.0 );
CG_Draw3DModel( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,
CG_Draw3DModel( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480-iconSize, iconSize, iconSize,
cg_weapons[ cent->currentState.weapon ].ammoModel, 0, origin, angles );
}

CG_DrawStatusBarHead( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE );
if ( cg_drawStatusHead.integer == 2 ) {
origin[0] = 60;
origin[1] = 0;
origin[2] = -5;
angles[YAW] = ( cg.time & 2047 ) * 360 / 4096.0;
CG_DrawHealthModel( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480-iconSize, iconSize, iconSize,
cg_items[ 6 /*item_health_large*/].models[0], 0, cg_items[ 6 /*item_health_large*/].models[1], origin, angles, 0 );

// if we didn't draw a 3D icon, draw a 2D icon for health
if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {
CG_DrawPic( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480 - iconSize, iconSize, iconSize, cg_items[6/*item_health_large*/].icon );
}
}
else if ( cg_drawStatusHead.integer == 1 )
CG_DrawStatusBarHead( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE );

if( cg.predictedPlayerState.powerups[PW_REDFLAG] ) {
CG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_RED );
Expand All @@ -575,7 +651,7 @@ static void CG_DrawStatusBar( void ) {
origin[1] = 0;
origin[2] = -10;
angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;
CG_Draw3DModel( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,
CG_Draw3DModel( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480 - iconSize, iconSize, iconSize,
cgs.media.armorModel, 0, origin, angles );
}
//
Expand Down Expand Up @@ -606,7 +682,7 @@ static void CG_DrawStatusBar( void ) {

icon = cg_weapons[ cg.predictedPlayerState.weapon ].ammoIcon;
if ( icon ) {
CG_DrawPic( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, icon );
CG_DrawPic( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480 - iconSize, iconSize, iconSize, icon );
}
}
}
Expand Down Expand Up @@ -643,7 +719,7 @@ static void CG_DrawStatusBar( void ) {
trap_R_SetColor( NULL );
// if we didn't draw a 3D icon, draw a 2D icon for armor
if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {
CG_DrawPic( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, cgs.media.armorIcon );
CG_DrawPic( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 480 - iconSize, iconSize, iconSize, cgs.media.armorIcon );
}

}
Expand Down Expand Up @@ -1025,6 +1101,10 @@ static float CG_DrawScores( float y ) {
float y1;
gitem_t *item;

if ( !cg_drawScores.integer ) {
return y;
}

s1 = cgs.scores1;
s2 = cgs.scores2;

Expand Down Expand Up @@ -1294,21 +1374,30 @@ CG_DrawPickupItem
static int CG_DrawPickupItem( int y ) {
int value;
float *fadeColor;
float iconSize, charWidth, charHeight;

if ( cg_drawPickups.value <= 0 ) {
return y;
}

if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {
return y;
}

y -= ICON_SIZE;
iconSize = ICON_SIZE*cg_drawPickups.value;
charWidth = BIGCHAR_WIDTH*cg_drawPickups.value;
charHeight = BIGCHAR_HEIGHT*cg_drawPickups.value;

y -= iconSize;

value = cg.itemPickup;
if ( value ) {
fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 );
if ( fadeColor ) {
CG_RegisterItemVisuals( value );
trap_R_SetColor( fadeColor );
CG_DrawPic( 8, y, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );
CG_DrawBigString( ICON_SIZE + 16, y + (ICON_SIZE/2 - BIGCHAR_HEIGHT/2), bg_itemlist[ value ].pickup_name, fadeColor[0] );
CG_DrawPic( 8, y, iconSize, iconSize, cg_items[ value ].icon );
CG_DrawStringExt( iconSize + 16, y + (iconSize/2 - charHeight/2), bg_itemlist[ value ].pickup_name, fadeColor, qfalse, qtrue, charWidth, charHeight, 0 );
trap_R_SetColor( NULL );
}
}
Expand Down
5 changes: 5 additions & 0 deletions code/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,11 @@ extern vmCvar_t cg_drawCrosshair;
extern vmCvar_t cg_drawCrosshairNames;
extern vmCvar_t cg_drawRewards;
extern vmCvar_t cg_drawTeamOverlay;
extern vmCvar_t cg_drawScores;
extern vmCvar_t cg_drawPickups;
extern vmCvar_t cg_drawWeaponBar;
extern vmCvar_t cg_drawStatusHead;
extern vmCvar_t cg_statusScale;
extern vmCvar_t cg_teamOverlayUserinfo;
extern vmCvar_t cg_crosshairX;
extern vmCvar_t cg_crosshairY;
Expand Down
13 changes: 13 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ vmCvar_t cg_drawAmmoWarning;
vmCvar_t cg_drawCrosshair;
vmCvar_t cg_drawCrosshairNames;
vmCvar_t cg_drawRewards;
vmCvar_t cg_drawScores;
vmCvar_t cg_drawPickups;
vmCvar_t cg_drawWeaponBar;
vmCvar_t cg_drawStatusHead;
vmCvar_t cg_statusScale;
vmCvar_t cg_crosshairSize;
vmCvar_t cg_crosshairX;
vmCvar_t cg_crosshairY;
Expand Down Expand Up @@ -226,6 +231,11 @@ static cvarTable_t cvarTable[] = {
{ &cg_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE },
{ &cg_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
{ &cg_drawRewards, "cg_drawRewards", "1", CVAR_ARCHIVE },
{ &cg_drawScores, "cg_drawScores", "1", CVAR_ARCHIVE },
{ &cg_drawPickups, "cg_drawPickups", "1", CVAR_ARCHIVE },
{ &cg_drawWeaponBar, "cg_drawWeaponBar", "1", CVAR_ARCHIVE },
{ &cg_drawStatusHead, "cg_drawStatusHead", "1", CVAR_ARCHIVE },
{ &cg_statusScale, "cg_statusScale", "1", CVAR_ARCHIVE },
{ &cg_crosshairSize, "cg_crosshairSize", "24", CVAR_ARCHIVE },
{ &cg_crosshairHealth, "cg_crosshairHealth", "1", CVAR_ARCHIVE },
{ &cg_crosshairX, "cg_crosshairX", "0", CVAR_ARCHIVE },
Expand Down Expand Up @@ -1017,6 +1027,9 @@ static void CG_RegisterGraphics( void ) {
}
}

// can be used by HUD so always load it
CG_RegisterItemVisuals( 6 /* item_health_large */ );

// wall marks
cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
Expand Down
26 changes: 19 additions & 7 deletions code/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -1459,6 +1459,11 @@ void CG_DrawWeaponSelect( void ) {
int x, y, w;
char *name;
float *color;
float markerSize, iconSize, offsetSize, charWidth, charHeight;

if ( cg_drawWeaponBar.value <= 0 ) {
return;
}

// don't display if dead
if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
Expand All @@ -1483,9 +1488,16 @@ void CG_DrawWeaponSelect( void ) {
}
}

x = 320 - count * 20;
x = 320 - count * 20 * cg_drawWeaponBar.value;
y = 380;

markerSize = 40 * cg_drawWeaponBar.value;
iconSize = 32 * cg_drawWeaponBar.value;
offsetSize = (markerSize - iconSize) * 0.5f;

charWidth = BIGCHAR_WIDTH * cg_drawWeaponBar.value;
charHeight = BIGCHAR_HEIGHT * cg_drawWeaponBar.value;

for ( i = 1 ; i < MAX_WEAPONS ; i++ ) {
if ( !( bits & ( 1 << i ) ) ) {
continue;
Expand All @@ -1494,28 +1506,28 @@ void CG_DrawWeaponSelect( void ) {
CG_RegisterWeapon( i );

// draw weapon icon
CG_DrawPic( x, y, 32, 32, cg_weapons[i].weaponIcon );
CG_DrawPic( x, y, iconSize, iconSize, cg_weapons[i].weaponIcon );

// draw selection marker
if ( i == cg.weaponSelect ) {
CG_DrawPic( x-4, y-4, 40, 40, cgs.media.selectShader );
CG_DrawPic( x-offsetSize, y-offsetSize, markerSize, markerSize, cgs.media.selectShader );
}

// no ammo cross on top
if ( !cg.snap->ps.ammo[ i ] ) {
CG_DrawPic( x, y, 32, 32, cgs.media.noammoShader );
CG_DrawPic( x, y, iconSize, iconSize, cgs.media.noammoShader );
}

x += 40;
x += markerSize;
}

// draw the selected name
if ( cg_weapons[ cg.weaponSelect ].item ) {
name = cg_weapons[ cg.weaponSelect ].item->pickup_name;
if ( name ) {
w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
w = CG_DrawStrlen( name ) * charWidth;
x = ( SCREEN_WIDTH - w ) / 2;
CG_DrawBigStringColor(x, y - 22, name, color);
CG_DrawStringExt(x, y - 22*cg_drawWeaponBar.value, name, color, qfalse, qtrue, charWidth, charHeight, 0 );
}
}

Expand Down

0 comments on commit 18ee65f

Please sign in to comment.