// ===================================================================// Unified HUD initialization// ===================================================================// cursor positioning// xl <value> x-left side// xr <value> x-right side// yb <value> y-bottom// yt <value> y-top// xv <value> x-virtual(?)// yv <value> y-virtual(?)// drawing// statpic <name>// pic <stat>// num <fieldwidth> <stat>// string <stat>// control// if <stat>// ifeq <stat> <value>// ifbit <stat> <value>// endif// //QW//// In all cases <stat> is the integer representing the stat(us) message item// to be presented. I've used manifest constants to keep the messages// properly enumerated across the game modes and they are defined in // q_shared.h. The ZOID code originally had these scattered about in// different places but he mostly used magic numbers in the messages and that just// made it hard to figure out exactly what was happening. He defined the constants// and then didn't use them. (Duh!) Later authors were overlapping them in their// mods or pulling in overlapping stat items from other mods and this created// HUD conflicts. ENUM or #DEFINE, then USE the damn things. Please.// Positioning:// It looks like 0,0 is the center of the screen with x going negative to the right.// xv, yv is relative to this origin at center.// xl is plus counts from origin left justified.// xr is minus counts from origin right justified.// yb is minus counts from bottom.// yt is plus counts from 0 at top./* //QW//A standard HUD character (conchar) is 8 screen units wide. The xl and xr origins are withrespect to the left and right borders. Add/subract 2 units to keep a little space betweenthe edge and the chars. For example, the string "FPH" is 3 chars wide, 3 * 8 = 24 units. If using xr, add 2 and negate, giving -26 from the right edge as the start of the string on the screen, "Range" is (-1)(5 * 8 + 2) = -42.Using xl, just use an origin of 2 to space a string 2 units from the border so it looks nice.*/// //QW//// The big HUD characters for the counters are 16 units wide but // their origin is already offset by 2.// They are positioned at 0 on the left and at (n * 16)-2 on the right// when n is the number of digits you want to display.//// Printing big chars on the left is problematic, they are right-justfied inside their// block so printing them on the left will gap them from the edge when the value doesn't// fill the full range of digits. Negative signs will probably be clipped if you don't// allow an extra space for them. // You should layout for signed values on the right side or midline where negative// values aren't a problem. // Layout for unsigned on the left if you don't mind having right-justfied // blocks there. Allow space only for the number of digits you expect to// display to keep the HUD packet as small as possible.// I think I first saw an integrated HUD as a function in the CTC mod.// I took it a little further by integrating the game modes and collecting// the stat constants in one place. /* //QW//Big HUD chars are 24 units tall and conchars are 8 for a total of 32 plusvertical spacing of 3 units to make it 35 units for a per-line incrementon the big chars. I use a 25 unit vertical offset for the conchars labelbelow it. This seems to give a nice uniform leading between lines.*/// ===================================================================void CreateStatusBar(){ char Bar[256]; size_t s; memset(statusbar, 0, sizeof(statusbar)); sprintf(Bar, "if %d yb -24 xv 0 hnum xv 50 pic %d ", STAT_HEALTH_ICON, STAT_HEALTH_ICON); strcat(statusbar, Bar); sprintf(Bar, "if %d xv 100 anum xv 150 pic %d endif ", STAT_AMMO_ICON, STAT_AMMO_ICON); strcat(statusbar, Bar); sprintf(Bar, "if %d xv 200 rnum xv 250 pic %d endif ", STAT_ARMOR_ICON, STAT_ARMOR_ICON); strcat(statusbar, Bar); sprintf(Bar, "if %d xv 296 pic %d endif ", STAT_SELECTED_ICON, STAT_SELECTED_ICON); strcat(statusbar, Bar); sprintf(Bar, "yb -50 if %d xv 0 pic %d xv 26 yb -42 stat_string %d yb -50 endif ", STAT_PICKUP_ICON, STAT_PICKUP_ICON, STAT_PICKUP_STRING); strcat(statusbar, Bar); // ctf bar had xv at 262, test this //QW// sprintf(Bar, "if %d xv 246 num 2 %d xv 296 pic %d endif ", STAT_TIMER_ICON, STAT_TIMER, STAT_TIMER_ICON); strcat(statusbar, Bar); sprintf(Bar, "if %d xv 148 pic %d endif ", STAT_HELPICON, STAT_HELPICON); strcat(statusbar, Bar); sprintf(Bar, "xr -50 yt 2 num 3 %d ",STAT_FRAGS); //player frag count strcat(statusbar, Bar); if (ctf->value) { //red team pad captures sprintf(Bar, "yb -102 if %d xr -26 pic %d endif xr -62 num 2 %d ", STAT_CTF_TEAM1_PIC, STAT_CTF_TEAM1_PIC, STAT_CTF_TEAM1_CAPS); strcat(statusbar, Bar); //red joined overlay sprintf(Bar, "if %d yb -104 xr -28 pic %d endif ", STAT_CTF_JOINED_TEAM1_PIC, STAT_CTF_JOINED_TEAM1_PIC); //player frag count strcat(statusbar, Bar); //blue team pad captures sprintf(Bar, "yb -75 if %d xr -26 pic %d endif xr -62 num 2 %d ", STAT_CTF_TEAM2_PIC, STAT_CTF_TEAM2_PIC, STAT_CTF_TEAM2_CAPS); strcat(statusbar, Bar); //blue joined overlay sprintf(Bar, "if %d yb -77 xr -28 pic %d endif ", STAT_CTF_JOINED_TEAM2_PIC, STAT_CTF_JOINED_TEAM2_PIC); //player frag count strcat(statusbar, Bar); //uncaptured spawnpoints sprintf(Bar, "if %d yb -50 xr -62 num 2 %d endif ", STAT_CTF_NOTCAPPED, STAT_CTF_NOTCAPPED); strcat(statusbar, Bar); } // player ID sprintf(Bar, "if %d xv 30 yv 220 stat_string %d endif ", STAT_PLAYER, STAT_PLAYER); strcat(statusbar, Bar); // player frag per hour sprintf(Bar, "if %d xr -66 yt 30 num 4 %d xr -26 yt 55 string FPH endif ",STAT_FPH, STAT_FPH); strcat(statusbar, Bar); // looks like a score digit is 16 screen units wide. // rangefinder (-66)(-42) sprintf(Bar, "if %d xr -66 yt 65 num 4 %d xr -42 yt 90 string Range endif ", STAT_RANGEFINDER, STAT_RANGEFINDER); strcat(statusbar, Bar); // player Height (-66)(-50) lines are spaced 35 units. sprintf(Bar, "if %d xr -66 yt 100 num 4 %d xr -50 yt 125 string Height endif ", STAT_HEIGHT, STAT_HEIGHT); strcat(statusbar, Bar); // player number of TRACKERS deployed sprintf(Bar, "if %d xr -34 yt 135 num 2 %d xr -66 yt 160 string Trackers endif ", STAT_NUMTRACKER, STAT_NUMTRACKER); strcat(statusbar, Bar); // player number of TURRETS deployed sprintf(Bar, "if %d xr -34 yt 170 num 2 %d xr -58 yt 195 string Turrets endif ", STAT_NUMTURRET, STAT_NUMTURRET); strcat(statusbar, Bar); // player location sprintf(Bar, "if %d xv 105 yv 140 stat_string %d endif ", STAT_LOCATION, STAT_LOCATION); strcat(statusbar, Bar); // Make sure we dont blow anything out of the water s = strlen(statusbar); if ( s > 1024) { gi.dprintf("HOLY COW: Statusbar too big %d\n", strlen(statusbar)); //to the log statusbar[1023] = 0; }}// end HUD initialization// ===================================================================