// // HU_Drawer() // // Draw all the pieces of the heads-up display // // Passed nothing, returns nothing // void HU_Drawer(void) { char *s; player_t *plr; char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods char healthstr[80];//jff char armorstr[80]; //jff int i,doit; // don't draw anything if there's a fullscreen menu up if (menuactive == mnact_full) return; plr = &players[displayplayer]; // killough 3/7/98 // draw the automap widgets if automap is displayed if (automapmode & am_active) { // map title HUlib_drawTextLine(&w_title, false); //jff 2/16/98 output new coord display // x-coord if (map_point_coordinates) { sprintf(hud_coordstrx,"X: %-5d", (plr->mo->x)>>FRACBITS); HUlib_clearTextLine(&w_coordx); s = hud_coordstrx; while (*s) HUlib_addCharToTextLine(&w_coordx, *(s++)); HUlib_drawTextLine(&w_coordx, false); //jff 3/3/98 split coord display into x,y,z lines // y-coord sprintf(hud_coordstry,"Y: %-5d", (plr->mo->y)>>FRACBITS); HUlib_clearTextLine(&w_coordy); s = hud_coordstry; while (*s) HUlib_addCharToTextLine(&w_coordy, *(s++)); HUlib_drawTextLine(&w_coordy, false); //jff 3/3/98 split coord display into x,y,z lines //jff 2/22/98 added z // z-coord sprintf(hud_coordstrz,"Z: %-5d", (plr->mo->z)>>FRACBITS); HUlib_clearTextLine(&w_coordz); s = hud_coordstrz; while (*s) HUlib_addCharToTextLine(&w_coordz, *(s++)); HUlib_drawTextLine(&w_coordz, false); } }
void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc) { t->x = x; t->y = y; t->f = f; t->sc = sc; HUlib_clearTextLine(t); }
void HUlib_addLineToSText(hu_stext_t* s) { int i; if (++s->cl >= s->h) // add a clear line s->cl = 0; HUlib_clearTextLine(s->l + s->cl); for (i = 0 ; i < s->h ; i++) // everything needs updating s->l[i].needsupdate = 4; }
void HUlib_initTextLine(hu_textline_t* t, int x, int y, patch_t** f, int sc, char* cr) //jff 2/16/98 add color range parameter { t->x = x; t->y = y; t->f = f; t->sc = sc; t->cr = cr; HUlib_clearTextLine(t); }
// // HUlib_initTextLine() // // Initialize a hu_textline_t widget. Set the position, font, start char // of the font, and color range to be used. // // Passed a hu_textline_t, and the values used to initialize // Returns nothing // void HUlib_initTextLine(hu_textline_t* t, int x, int y, const patchnum_t* f, int sc, int cm ) //jff 2/16/98 add color range parameter { t->x = x; t->y = y; t->f = f; t->sc = sc; t->cm = cm; HUlib_clearTextLine(t); }
static void HUlib_addLineToSText(hu_stext_t *s) { // add a clear line if (++s->cl == s->h) s->cl = 0; HUlib_clearTextLine(&s->l[s->cl]); // everything needs updating for (int i = 0; i < s->h; i++) s->l[i].needsupdate = 4; }
// // HUlib_initTextLine() // // Initialize a hu_textline_t widget. Set the position, font, start char // of the font, and color range to be used. // // Passed a hu_textline_t, and the values used to initialize // Returns nothing // void HUlib_initTextLine(hu_textline_t* t, int x, int y, const patchnum_t* f, int sc, int cm, enum patch_translation_e flags ) //jff 2/16/98 add color range parameter { t->x = x; t->y = y; t->val = -1; t->f = f; t->sc = sc; t->cm = cm; t->flags = flags; HUlib_clearTextLine(t); }
// // HUlib_addLineToMText() // // Adds a blank line to a hu_mtext_t widget // // Passed a hu_mtext_t // Returns nothing // static void HUlib_addLineToMText(hu_mtext_t* m) { // add a clear line if (++m->cl == hud_msg_lines) m->cl = 0; HUlib_clearTextLine(&m->l[m->cl]); if (m->nl<hud_msg_lines) m->nl++; // needs updating m->l[m->cl].needsupdate = 4; }
void HUlib_resetIText(hu_itext_t* it) { it->lm = 0; HUlib_clearTextLine(&it->l); }
// // HU_Drawer() // // Draw all the pieces of the heads-up display // // Passed nothing, returns nothing // void HU_Drawer(void) { char* s; player_t* plr; char ammostr[80]; //jff 3/8/98 allow plenty room for dehacked mods char healthstr[80];//jff char armorstr[80]; //jff int i; plr = &players[displayplayer]; // killough 3/7/98 // draw the automap widgets if automap is displayed if (automapactive) { fixed_t x, y, z; // killough 10/98: void AM_Coordinates(const mobj_t*, fixed_t*, fixed_t*, fixed_t*); // map title HUlib_drawTextLine(&w_title, false); // killough 10/98: allow coordinates to display non-following pointer AM_Coordinates(plr->mo, &x, &y, &z); //jff 2/16/98 output new coord display // x-coord sprintf(hud_coordstrx, "X: %-5d", x >> FRACBITS); // killough 10/98 HUlib_clearTextLine(&w_coordx); s = hud_coordstrx; while (*s) HUlib_addCharToTextLine(&w_coordx, *s++); HUlib_drawTextLine(&w_coordx, false); //jff 3/3/98 split coord display into x,y,z lines // y-coord sprintf(hud_coordstry, "Y: %-5d", y >> FRACBITS); // killough 10/98 HUlib_clearTextLine(&w_coordy); s = hud_coordstry; while (*s) HUlib_addCharToTextLine(&w_coordy, *s++); HUlib_drawTextLine(&w_coordy, false); //jff 3/3/98 split coord display into x,y,z lines //jff 2/22/98 added z // z-coord sprintf(hud_coordstrz, "Z: %-5d", z >> FRACBITS); // killough 10/98 HUlib_clearTextLine(&w_coordz); s = hud_coordstrz; while (*s) HUlib_addCharToTextLine(&w_coordz, *s++); HUlib_drawTextLine(&w_coordz, false); } // draw the weapon/health/ammo/armor/kills/keys displays if optioned //jff 2/17/98 allow new hud stuff to be turned off // killough 2/21/98: really allow new hud stuff to be turned off COMPLETELY if ( hud_active > 0 && // hud optioned on hud_displayed && // hud on from fullscreen key scaledviewheight == SCREENHEIGHT && // fullscreen mode is active !automapactive // automap is not active ) { HU_MoveHud(); // insure HUD display coords are correct // do the hud ammo display // clear the widgets internal line HUlib_clearTextLine(&w_ammo); strcpy(hud_ammostr, "AMM "); if (weaponinfo[plr->readyweapon].ammo == am_noammo) { // special case for weapon with no ammo selected - blank bargraph + N/A strcat(hud_ammostr, "\x7f\x7f\x7f\x7f\x7f\x7f\x7f N/A"); w_ammo.cr = colrngs[CR_GRAY]; } else { int ammo = plr->ammo[weaponinfo[plr->readyweapon].ammo]; int fullammo = plr->maxammo[weaponinfo[plr->readyweapon].ammo]; int ammopct = (100 * ammo) / fullammo; int ammobars = ammopct / 4; // build the numeric amount init string sprintf(ammostr, "%d/%d", ammo, fullammo); // build the bargraph string // full bargraph chars for (i = 4; i < 4 + ammobars / 4;) hud_ammostr[i++] = 123; // plus one last character with 0,1,2,3 bars switch (ammobars % 4) { case 0: break; case 1: hud_ammostr[i++] = 126; break; case 2: hud_ammostr[i++] = 125; break; case 3: hud_ammostr[i++] = 124; break; } // pad string with blank bar characters while (i < 4 + 7) hud_ammostr[i++] = 127; hud_ammostr[i] = '\0'; strcat(hud_ammostr, ammostr); // set the display color from the percentage of total ammo held if (ammopct < ammo_red) w_ammo.cr = colrngs[CR_RED]; else if (ammopct < ammo_yellow) w_ammo.cr = colrngs[CR_GOLD]; else w_ammo.cr = colrngs[CR_GREEN]; } // transfer the init string to the widget s = hud_ammostr; while (*s) HUlib_addCharToTextLine(&w_ammo, *s++); // display the ammo widget every frame HUlib_drawTextLine(&w_ammo, false); // do the hud health display { int health = plr->health; int healthbars = health > 100 ? 25 : health / 4; // clear the widgets internal line HUlib_clearTextLine(&w_health); // build the numeric amount init string sprintf(healthstr, "%3d", health); // build the bargraph string // full bargraph chars for (i = 4; i < 4 + healthbars / 4;) hud_healthstr[i++] = 123; // plus one last character with 0,1,2,3 bars switch (healthbars % 4) { case 0: break; case 1: hud_healthstr[i++] = 126; break; case 2: hud_healthstr[i++] = 125; break; case 3: hud_healthstr[i++] = 124; break; } // pad string with blank bar characters while (i < 4 + 7) hud_healthstr[i++] = 127; hud_healthstr[i] = '\0'; strcat(hud_healthstr, healthstr); // set the display color from the amount of health posessed if (health < health_red) w_health.cr = colrngs[CR_RED]; else if (health < health_yellow) w_health.cr = colrngs[CR_GOLD]; else if (health <= health_green) w_health.cr = colrngs[CR_GREEN]; else w_health.cr = colrngs[CR_BLUE]; // transfer the init string to the widget s = hud_healthstr; while (*s) HUlib_addCharToTextLine(&w_health, *s++); } // display the health widget every frame HUlib_drawTextLine(&w_health, false); // do the hud armor display { int armor = plr->armorpoints; int armorbars = armor > 100 ? 25 : armor / 4; // clear the widgets internal line HUlib_clearTextLine(&w_armor); // build the numeric amount init string sprintf(armorstr, "%3d", armor); // build the bargraph string // full bargraph chars for (i = 4; i < 4 + armorbars / 4;) hud_armorstr[i++] = 123; // plus one last character with 0,1,2,3 bars switch (armorbars % 4) { case 0: break; case 1: hud_armorstr[i++] = 126; break; case 2: hud_armorstr[i++] = 125; break; case 3: hud_armorstr[i++] = 124; break; } // pad string with blank bar characters while (i < 4 + 7) hud_armorstr[i++] = 127; hud_armorstr[i] = '\0'; strcat(hud_armorstr, armorstr); // set the display color from the amount of armor posessed w_armor.cr = armor < armor_red ? colrngs[CR_RED] : armor < armor_yellow ? colrngs[CR_GOLD] : armor <= armor_green ? colrngs[CR_GREEN] : colrngs[CR_BLUE]; // transfer the init string to the widget s = hud_armorstr; while (*s) HUlib_addCharToTextLine(&w_armor, *s++); } // display the armor widget every frame HUlib_drawTextLine(&w_armor, false); // do the hud weapon display { int w, ammo, fullammo, ammopct; // clear the widgets internal line HUlib_clearTextLine(&w_weapon); i = 4; hud_weapstr[i] = '\0'; //jff 3/7/98 make sure ammo goes away // do each weapon that exists in current gamemode for (w = 0; w <= wp_supershotgun; w++) //jff 3/4/98 show fists too, why not? { int ok = 1; //jff avoid executing for weapons that do not exist switch (gamemode) { case shareware: if (w >= wp_plasma && w != wp_chainsaw) ok = 0; break; case retail: case registered: if (w >= wp_supershotgun) ok = 0; break; default: case commercial: break; } if (!ok) continue; ammo = plr->ammo[weaponinfo[w].ammo]; fullammo = plr->maxammo[weaponinfo[w].ammo]; ammopct = 0; // skip weapons not currently posessed if (!plr->weaponowned[w]) continue; ammopct = fullammo ? (100 * ammo) / fullammo : 100; // display each weapon number in a color related to the ammo for it hud_weapstr[i++] = '\x1b'; //jff 3/26/98 use ESC not '\' for paths if (weaponinfo[w].ammo == am_noammo) //jff 3/14/98 show berserk on HUD hud_weapstr[i++] = plr->powers[pw_strength] ? '0' + CR_GREEN : '0' + CR_GRAY; else if (ammopct < ammo_red) hud_weapstr[i++] = '0' + CR_RED; else if (ammopct < ammo_yellow) hud_weapstr[i++] = '0' + CR_GOLD; else hud_weapstr[i++] = '0' + CR_GREEN; hud_weapstr[i++] = '0' + w + 1; hud_weapstr[i++] = ' '; hud_weapstr[i] = '\0'; } // transfer the init string to the widget s = hud_weapstr; while (*s) HUlib_addCharToTextLine(&w_weapon, *s++); } // display the weapon widget every frame HUlib_drawTextLine(&w_weapon, false); if (hud_active > 1) { int k; hud_keysstr[4] = '\0'; //jff 3/7/98 make sure deleted keys go away //jff add case for graphic key display if (!deathmatch && hud_graph_keys) { i = 0; hud_gkeysstr[i] = '\0'; //jff 3/7/98 init graphic keys widget string // build text string whose characters call out graphic keys from fontk for (k = 0; k < 6; k++) { // skip keys not possessed if (!plr->cards[k]) continue; hud_gkeysstr[i++] = '!' + k; // key number plus '!' is char for key hud_gkeysstr[i++] = ' '; // spacing hud_gkeysstr[i++] = ' '; } hud_gkeysstr[i] = '\0'; } else // not possible in current code, unless deathmatching, { i = 4; hud_keysstr[i] = '\0'; //jff 3/7/98 make sure deleted keys go away // if deathmatch, build string showing top four frag counts if (deathmatch) //jff 3/17/98 show frags, not keys, in deathmatch { int top1 = -999, top2 = -999, top3 = -999, top4 = -999; int idx1 = -1, idx2 = -1, idx3 = -1, idx4 = -1; int fragcount, m; // scan thru players for (k = 0; k < MAXPLAYERS; k++) { // skip players not in game if (!playeringame[k]) continue; fragcount = 0; // compute number of times they've fragged each player // minus number of times they've been fragged by them for (m = 0; m < MAXPLAYERS; m++) { if (!playeringame[m]) continue; fragcount += (m != k) ? players[k].frags[m] : -players[k].frags[m]; } // very primitive sort of frags to find top four if (fragcount > top1) { top4 = top3; top3 = top2; top2 = top1; top1 = fragcount; idx4 = idx3; idx3 = idx2; idx2 = idx1; idx1 = k; } else if (fragcount > top2) { top4 = top3; top3 = top2; top2 = fragcount; idx4 = idx3; idx3 = idx2; idx2 = k; } else if (fragcount > top3) { top4 = top3; top3 = fragcount; idx4 = idx3; idx3 = k; } else if (fragcount > top4) { top4 = fragcount; idx4 = k; } } // killough 11/98: replaced cut-and-pasted code with function // if the biggest number exists, // put it in the init string i = HU_top(i, idx1, top1); // if the second biggest number exists, // put it in the init string i = HU_top(i, idx2, top2); // if the third biggest number exists, // put it in the init string i = HU_top(i, idx3, top3); // if the fourth biggest number exists, // put it in the init string i = HU_top(i, idx4, top4); hud_keysstr[i] = '\0'; } //jff 3/17/98 end of deathmatch clause else // build alphabetical key display (not used currently) { // scan the keys for (k = 0; k < 6; k++) { // skip any not possessed by the displayed player's stats if (!plr->cards[k]) continue; // use color escapes to make text in key's color hud_keysstr[i++] = '\x1b'; //jff 3/26/98 use ESC not '\' for paths switch (k) { case 0: hud_keysstr[i++] = '0' + CR_BLUE; hud_keysstr[i++] = 'B'; hud_keysstr[i++] = 'C'; hud_keysstr[i++] = ' '; break; case 1: hud_keysstr[i++] = '0' + CR_GOLD; hud_keysstr[i++] = 'Y'; hud_keysstr[i++] = 'C'; hud_keysstr[i++] = ' '; break; case 2: hud_keysstr[i++] = '0' + CR_RED; hud_keysstr[i++] = 'R'; hud_keysstr[i++] = 'C'; hud_keysstr[i++] = ' '; break; case 3: hud_keysstr[i++] = '0' + CR_BLUE; hud_keysstr[i++] = 'B'; hud_keysstr[i++] = 'S'; hud_keysstr[i++] = ' '; break; case 4: hud_keysstr[i++] = '0' + CR_GOLD; hud_keysstr[i++] = 'Y'; hud_keysstr[i++] = 'S'; hud_keysstr[i++] = ' '; break; case 5: hud_keysstr[i++] = '0' + CR_RED; hud_keysstr[i++] = 'R'; hud_keysstr[i++] = 'S'; hud_keysstr[i++] = ' '; break; } hud_keysstr[i] = '\0'; } } } } // display the keys/frags line each frame if (hud_active > 1) { HUlib_clearTextLine(&w_keys); // clear the widget strings HUlib_clearTextLine(&w_gkeys); // transfer the built string (frags or key title) to the widget s = hud_keysstr; //jff 3/7/98 display key titles/key text or frags while (*s) HUlib_addCharToTextLine(&w_keys, *s++); HUlib_drawTextLine(&w_keys, false); //jff 3/17/98 show graphic keys in non-DM only if (!deathmatch) //jff 3/7/98 display graphic keys { // transfer the graphic key text to the widget s = hud_gkeysstr; while (*s) HUlib_addCharToTextLine(&w_gkeys, *s++); // display the widget HUlib_drawTextLine(&w_gkeys, false); } } // display the hud kills/items/secret display if optioned if (!hud_nosecrets) { if (hud_active > 1) { // clear the internal widget text buffer HUlib_clearTextLine(&w_monsec); //jff 3/26/98 use ESC not '\' for paths // build the init string with fixed colors sprintf(hud_monsecstr, "STS \x1b\x36K \x1b\x33%d/%d" " \x1b\x37I \x1b\x33%d/%d \x1b\x35S \x1b\x33%d/%d", plr->killcount, totalkills, plr->itemcount, totalitems, plr->secretcount, totalsecret); // transfer the init string to the widget s = hud_monsecstr; while (*s) HUlib_addCharToTextLine(&w_monsec, *s++); } // display the kills/items/secrets each frame, if optioned if (hud_active > 1) HUlib_drawTextLine(&w_monsec, false); } } //jff 3/4/98 display last to give priority // jff 4/24/98 Erase current lines before drawing current // needed when screen not fullsize // killough 11/98: only do it when not fullsize if (scaledviewheight < 200) HU_Erase(); //jff 4/21/98 if setup has disabled message list while active, turn it off // if the message review is enabled show the scrolling message review // if the message review not enabled, show the standard message widget // killough 11/98: simplified if (message_list) HUlib_drawMText(&w_rtext); else HUlib_drawSText(&w_message); // display the interactive buffer for chat entry HUlib_drawIText(&w_chat); }