This is more of a code of the loadHUD features.
This is a more recent version of the editable HUD that is available in baconET 2.0.2 and greater. I’ve removed all unstable code. It’s now entirely possible to recreate the etmain HUD.
You will have to figure out how to use the values on your own.
cg_local.h
// bacon - put this somewhere above cg_t
typedef struct {
int healthbar[3];
int staminabar[3];
int chargebar[3];
int compass[3];
int hp[3];
int xp[3];
int draws[2];
int skillpics[3][3];
int skilltexts[3][3];
int skillboxes[3][3];
int overheat[4];
int weaponcard[3];
int fireteam[3];
int ammo[3];
int cp[2];
int head[4];
} hud_t;
// put this somewhere in cg_t
hud_t hud;
// place this at the end of the file
//
// cg_hud.c
//
qboolean CG_LoadHud ( char * filename ) ;
cg_consolecmds.c
// replace CG_LoadHud_f() with this
static void CG_LoadHud_f( void ) {
char filename[MAX_TOKEN_CHARS];
if ( trap_Argc() < 2 ) {
strcpy(filename, "hud/default.hud");
} else {
trap_Argv(1, filename, sizeof(filename) );
if (strstr(filename, ".hud")) {
strcpy(filename, va( "hud/%s", filename ));
} else {
strcpy(filename, va( "hud/%s.hud", filename ));
}
}
if (CG_LoadHud( filename )) {
CG_Printf("^2Loaded HUD settings from '%s'
", filename);
} else {
CG_Printf("^1Failed to load HUD settings from '%s'
", filename);
}
}
cg_hud.c
#include "cg_local.h"
qboolean CG_LoadHud(char *filename) {
int handle;
pc_token_t token;
memset(&cg.hud, 0, sizeof(cg.hud));
handle = trap_PC_LoadSource( filename );
if (!handle)
return qfalse;
while ( 1 ) {
// hud elements
if ( !trap_PC_ReadToken( handle, &token ) ) {
break;
}
if ( !Q_stricmp( token.string, "elements") ) {
// we need a bracket
if ( !trap_PC_ReadToken( handle, &token ) ) {
return qfalse;
}
if ( !Q_stricmp( token.string, "{" ) ) {
while ( 1 ) {
if ( !trap_PC_ReadToken( handle, &token ) ) {
break;
}
// we've reached the end
if ( !Q_stricmp( token.string, "}" ) ) {
break;
}
//
// compass
//
if ( !Q_stricmp ( token.string, "compass" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.compass[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.compass[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.compass[2] = atoi(token.string);
//
// health bar
//
} else if ( !Q_stricmp ( token.string, "healthbar" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.healthbar[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.healthbar[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.healthbar[2] = atoi( token.string );
//
// stamina bar
//
} else if ( !Q_stricmp( token.string, "staminabar" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.staminabar[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.staminabar[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.staminabar[2] = atoi(token.string);
//
// weapon charge bar
//
} else if ( !Q_stricmp( token.string, "chargebar" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.chargebar[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.chargebar[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.chargebar[2] = atoi(token.string);
//
// weapon overheat bar
//
} else if ( !Q_stricmp( token.string, "overheat" ) ) {
// x y width height
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.overheat[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.overheat[1] = atoi(token.string);
// width
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.overheat[2] = atoi(token.string);
// height
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.overheat[3] = atoi(token.string);
//
// weapon card
//
} else if ( !Q_stricmp( token.string, "weaponcard" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.weaponcard[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.weaponcard[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.weaponcard[2] = atoi(token.string);
//
// fireteam
//
} else if ( !Q_stricmp( token.string, "fireteam" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.fireteam[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.fireteam[1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.fireteam[2] = atoi(token.string);
//
// health text
//
} else if (!Q_stricmp( token.string, "healthtext" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.hp[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.hp[1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.hp[2] = atoi(token.string);
//
// xp text
//
} else if ( !Q_stricmp( token.string, "xptext" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.xp[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.xp[1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.xp[2] = atoi(token.string);
//
// upper right
//
} else if ( !Q_stricmp( token.string, "upperright" ) ) {
// y
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.draws[0] = atoi(token.string);
//
// ammo count
//
} else if ( !Q_stricmp( token.string, "ammocount" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.ammo[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.ammo[1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.ammo[2] = atoi(token.string);
//
// skill pic #1
//
} else if ( !Q_stricmp( token.string, "skillpic1" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[0][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[0][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[0][2] = atoi(token.string);
//
// skill pic #2
//
} else if ( !Q_stricmp( token.string, "skillpic2" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[1][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[1][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[1][2] = atoi(token.string);
//
// skill pic #3
//
} else if ( !Q_stricmp( token.string, "skillpic3" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[2][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[2][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillpics[2][2] = atoi(token.string);
//
// skill text #1
//
} else if ( !Q_stricmp( token.string, "skilltext1" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[0][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[0][1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[0][2] = atoi(token.string);
//
// skill text #2
//
} else if ( !Q_stricmp( token.string, "skilltext2" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[1][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[1][1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[1][2] = atoi(token.string);
//
// skill text #3
//
} else if ( !Q_stricmp( token.string, "skilltext3" ) ) {
// x y scale
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[2][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[2][1] = atoi(token.string);
// scale
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skilltexts[2][2] = atoi(token.string);
}
//
// cp text
//
else if ( !Q_stricmp( token.string, "cptext" ) ) {
// x y
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.cp[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.cp[1] = atoi(token.string);
}
//
// head
//
else if ( !Q_stricmp( token.string, "head" ) ) {
// x y width height
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.head[0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.head[1] = atoi(token.string);
// width
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.head[2] = atoi(token.string);
// height
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.head[3] = atoi(token.string);
}
//
// skillbox1
//
else if ( !Q_stricmp( token.string, "skillbox1" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[0][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[0][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[0][2] = atoi(token.string);
}
//
// skillbox2
//
else if ( !Q_stricmp( token.string, "skillbox2" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[1][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[1][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[1][2] = atoi(token.string);
}
//
// skillbox3
//
else if ( !Q_stricmp( token.string, "skillbox3" ) ) {
// x y size
// x
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[2][0] = atoi(token.string);
// y
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[2][1] = atoi(token.string);
// size
if ( !trap_PC_ReadToken( handle, &token ) )
continue;
cg.hud.skillboxes[2][2] = atoi(token.string);
}
}
}
}
}
return qtrue;
}
example1.hud
// HUD ELEMENTS
elements {
"healthbar" 20 388 12 // x y size
"staminabar" 4 388 12 // x y size
"chargebar" 622 388 12 // x y size
"healthtext" 29 474 20 // x y scale
"xptext" 70 475 20 // x y scale
"compass" 51 383 80 // x y size
"upperright" 140 // y
"skillpic1" 37 390 14 // x y size
"skillpic2" 37 412 14 // x y size
"skillpic3" 37 434 14 // x y size
"skilltext1" 40 412 20 // x y scale
"skilltext2" 40 434 20 // x y scale
"skilltext3" 40 456 20 // x y scale
"overheat" 558 424 70 90 // x y width height
"weaponcard" 558 424 60 // x y size
"ammocount" 618 470 25 // x y scale
"fireteam" 10 10 100 // x y size
"cptext" 320 300 // x y
}
example2.hud
// HUD ELEMENTS
elements {
"healthbar" 0 0 0 // x y size
"staminabar" 4 403 12 // x y size
"chargebar" 622 360 16 // x y size
"healthtext" 606 474 22 // x y scale
"xptext" 163 475 25 // x y scale
"compass" 275 383 90 // x y size
"upperright" 295 // y
"skillpic1" 49 460 14 // x y size
"skillpic2" 69 460 14 // x y size
"skillpic3" 89 460 14 // x y size
"skilltext1" 52 453 20 // x y scale
"skilltext2" 72 453 20 // x y scale
"skilltext3" 92 453 20 // x y scale
"overheat" 285 254 70 14 // x y width height
"weaponcard" 558 424 60 // x y size
"ammocount" 618 420 25 // x y scale
"fireteam" 10 10 180 // x y size
"cptext" 330 340 // x y
}
etmain.hud
// HUD ELEMENTS
elements {
"healthbar" 20 388 12 // x y size
"staminabar" 4 388 12 // x y size
"chargebar" 622 388 12 // x y size
"healthtext" 84 476 25 // x y scale
"xptext" 140 476 25 // x y scale
"compass" 504 4 132 // x y size
"upperright" 140 // y
"skillpic1" 128 446 16 // x y size
"skillpic2" 144 446 16 // x y size
"skillpic3" 160 446 16 // x y size
"skillbox1" 128 386 14 // x y size
"skillbox2" 144 386 14 // x y size
"skillbox3" 160 386 14 // x y size
"overheat" 558 424 70 90 // x y width height
"weaponcard" 558 424 60 // x y size
"ammocount" 618 470 25 // x y scale
"fireteam" 10 10 100 // x y size
"head" 44 378 62 80 // x y width height
}