2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // sbar.c -- status bar code
30 static sbarpic_t sbarpics[256];
31 static int numsbarpics;
33 static sbarpic_t *Sbar_NewPic(const char *name)
35 strcpy(sbarpics[numsbarpics].name, name);
37 // FIXME: precache on every renderer restart (or move this to client)
38 Draw_CachePic(sbarpics[numsbarpics].name);
39 return sbarpics + (numsbarpics++);
44 #define STAT_MINUS 10 // num frame for '-' stats digit
45 sbarpic_t *sb_nums[2][11];
46 sbarpic_t *sb_colon, *sb_slash;
49 sbarpic_t *sb_scorebar;
50 // AK only used by NEX(and only if everybody agrees)
51 sbarpic_t *sb_sbar_overlay;
53 // AK changed the bound to 9
54 sbarpic_t *sb_weapons[7][9]; // 0 is active, 1 is owned, 2-5 are flashes
55 sbarpic_t *sb_ammo[4];
56 sbarpic_t *sb_sigil[4];
57 sbarpic_t *sb_armor[3];
58 sbarpic_t *sb_items[32];
60 // 0-4 are based on health (in 20 increments)
61 // 0 is static, 1 is temporary animation
62 sbarpic_t *sb_faces[5][2];
64 sbarpic_t *sb_face_invis;
65 sbarpic_t *sb_face_quad;
66 sbarpic_t *sb_face_invuln;
67 sbarpic_t *sb_face_invis_invuln;
69 qboolean sb_showscores;
71 int sb_lines; // scan lines to draw
73 sbarpic_t *rsb_invbar[2];
74 sbarpic_t *rsb_weapons[5];
75 sbarpic_t *rsb_items[2];
76 sbarpic_t *rsb_ammo[3];
77 sbarpic_t *rsb_teambord; // PGM 01/19/97 - team color border
79 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
80 sbarpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
81 //MED 01/04/97 added array to simplify weapon parsing
82 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
83 //MED 01/04/97 added hipnotic items array
84 sbarpic_t *hsb_items[2];
86 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
88 void Sbar_MiniDeathmatchOverlay (void);
89 void Sbar_DeathmatchOverlay (void);
90 void Sbar_IntermissionOverlay (void);
91 void Sbar_FinaleOverlay (void);
101 void Sbar_ShowScores (void)
105 sb_showscores = true;
115 void Sbar_DontShowScores (void)
117 sb_showscores = false;
120 void sbar_start(void)
126 sb_disc = Sbar_NewPic("gfx/disc");
128 for (i = 0;i < 10;i++)
130 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
131 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
134 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
135 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
137 sb_colon = Sbar_NewPic ("gfx/num_colon");
138 sb_slash = Sbar_NewPic ("gfx/num_slash");
140 //AK NX uses its own hud
141 if(gamemode == GAME_NEXUIZ)
143 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
144 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
145 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
146 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
148 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
149 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
150 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
151 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
153 sb_sbar = Sbar_NewPic("gfx/sbar");
154 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
156 for(i = 0; i < 9;i++)
157 sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
162 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
163 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
164 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
165 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
166 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
167 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
168 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
170 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
171 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
172 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
173 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
174 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
175 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
176 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
178 for (i = 0;i < 5;i++)
180 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
181 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
182 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
183 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
184 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
185 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
186 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
189 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
190 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
191 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
192 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
194 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
195 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
196 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
198 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
199 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
200 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
201 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
202 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
203 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
205 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
206 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
207 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
208 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
210 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
211 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
212 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
213 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
214 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
215 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
216 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
217 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
218 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
219 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
221 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
222 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
223 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
224 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
226 sb_sbar = Sbar_NewPic ("gfx/sbar");
227 sb_ibar = Sbar_NewPic ("gfx/ibar");
228 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
230 //MED 01/04/97 added new hipnotic weapons
231 if (gamemode == GAME_HIPNOTIC)
233 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
234 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
235 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
236 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
237 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
239 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
240 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
241 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
242 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
243 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
245 for (i = 0;i < 5;i++)
247 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
248 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
249 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
250 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
251 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
254 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
255 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
257 else if (gamemode == GAME_ROGUE)
259 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
260 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
262 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
263 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
264 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
265 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
266 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
268 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
269 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
271 // PGM 01/19/97 - team color border
272 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
273 // PGM 01/19/97 - team color border
275 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
276 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
277 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
281 void sbar_shutdown(void)
285 void sbar_newmap(void)
289 void Sbar_Init (void)
291 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
292 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
293 Cvar_RegisterVariable (&showfps);
295 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
299 //=============================================================================
301 // drawing routines are relative to the status bar location
310 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
312 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, 1, 0);
315 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
317 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha, 0);
324 Draws one solid graphics character
327 void Sbar_DrawCharacter (int x, int y, int num)
329 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, 1, 0);
337 void Sbar_DrawString (int x, int y, char *str)
339 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, 1, 0);
347 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
352 l = sprintf(str, "%i", num);
366 Sbar_DrawPic (x, y, sb_nums[color][frame]);
379 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
384 l = sprintf(str, "%i", num);
389 x += (digits-l) * lettersize;
398 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a,flags);
405 //=============================================================================
413 static int fragsort[MAX_SCOREBOARD];
414 static int scoreboardlines;
415 void Sbar_SortFrags (void)
421 for (i=0 ; i<cl.maxclients ; i++)
423 if (cl.scores[i].name[0])
425 fragsort[scoreboardlines] = i;
430 for (i=0 ; i<scoreboardlines ; i++)
431 for (j=0 ; j<scoreboardlines-1-i ; j++)
432 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
435 fragsort[j] = fragsort[j+1];
445 void Sbar_SoloScoreboard (void)
448 int minutes, seconds, tens, units;
451 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
452 Sbar_DrawString (8, 4, str);
454 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
455 Sbar_DrawString (8, 12, str);
458 minutes = cl.time / 60;
459 seconds = cl.time - 60*minutes;
461 units = seconds - 10*tens;
462 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
463 Sbar_DrawString (184, 4, str);
466 l = strlen (cl.levelname);
467 Sbar_DrawString (232 - l*4, 12, cl.levelname);
475 void Sbar_DrawScoreboard (void)
477 Sbar_SoloScoreboard ();
478 if (cl.gametype == GAME_DEATHMATCH)
479 Sbar_DeathmatchOverlay ();
482 //=============================================================================
484 // AK to make DrawInventory smaller
485 static void Sbar_DrawWeapon(int nr, float fade, int active)
487 // width = 300, height = 100
488 const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
489 const float w_scale = 0.4;
491 DrawQ_Pic(vid.conwidth - (w_width + w_space) * w_scale, (w_height + w_space) * w_scale * nr + w_space, sb_weapons[0][nr]->name, w_width * w_scale, w_height * w_scale, (active) ? 1 : 0.6, active ? 1 : 0.6, active ? 1 : 1, fade, DRAWFLAG_ADDITIVE);
492 DrawQ_String(vid.conwidth - (w_space + font_size ), (w_height + w_space) * w_scale * nr + w_space, va("%i",nr+1), 0, font_size, font_size, 1, 0, 0, fade, 0);
495 DrawQ_Fill(vid.conwidth - (w_width + w_space) * w_scale, (w_height + w_space) * w_scale * nr + w_space, w_width * w_scale, w_height * w_scale, 0.3, 0.3, 0.3, fade, DRAWFLAG_ADDITIVE);
503 void Sbar_DrawInventory (void)
512 if(gamemode == GAME_NEXUIZ)
514 num[0] = cl.stats[STAT_ACTIVEWEAPON];
515 // we have a max time 2s (min time = 0)
516 if ((time = cl.time - cl.weapontime) > 2)
519 fade = (1.0 - 0.5 * time);
521 for (i = 0; i < 8;i++)
523 if (!(cl.items & (1 << i)))
525 Sbar_DrawWeapon(i + 1, fade, (i == num[0]));
528 if(!(cl.items & (1<<12)))
530 Sbar_DrawWeapon(0, fade, (num[0] == 12));
534 if (gamemode == GAME_ROGUE)
536 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
537 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
539 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
542 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
545 for (i=0 ; i<7 ; i++)
547 if (cl.items & (IT_SHOTGUN<<i) )
549 time = cl.item_gettime[i];
550 flashon = (int)((cl.time - time)*10);
553 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
559 flashon = (flashon%5) + 2;
561 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
567 if (gamemode == GAME_HIPNOTIC)
569 int grenadeflashing=0;
570 for (i=0 ; i<4 ; i++)
572 if (cl.items & (1<<hipweapons[i]) )
574 time = cl.item_gettime[hipweapons[i]];
575 flashon = (int)((cl.time - time)*10);
578 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
584 flashon = (flashon%5) + 2;
586 // check grenade launcher
589 if (cl.items & HIT_PROXIMITY_GUN)
594 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
600 if (cl.items & (IT_SHOTGUN<<4))
602 if (!grenadeflashing)
603 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
606 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
609 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
614 if (gamemode == GAME_ROGUE)
616 // check for powered up weapon.
617 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
619 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
620 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
624 for (i=0 ; i<4 ; i++)
626 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
628 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
630 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
632 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
636 for (i=0 ; i<6 ; i++)
637 if (cl.items & (1<<(17+i)))
639 //MED 01/04/97 changed keys
640 if (gamemode != GAME_HIPNOTIC || (i>1))
641 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
644 //MED 01/04/97 added hipnotic items
646 if (gamemode == GAME_HIPNOTIC)
648 for (i=0 ; i<2 ; i++)
649 if (cl.items & (1<<(24+i)))
650 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
653 if (gamemode == GAME_ROGUE)
656 for (i=0 ; i<2 ; i++)
657 if (cl.items & (1<<(29+i)))
658 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
663 for (i=0 ; i<4 ; i++)
664 if (cl.items & (1<<(28+i)))
665 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
669 //=============================================================================
676 void Sbar_DrawFrags (void)
686 l = scoreboardlines <= 4 ? scoreboardlines : 4;
690 for (i = 0;i < l;i++)
698 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
699 DrawQ_Fill (sbar_x + x + 10, sbar_y - 23, 28, 4, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
700 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
701 DrawQ_Fill (sbar_x + x + 10, sbar_y + 4 - 23, 28, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
705 sprintf (num, "%3i",f);
707 Sbar_DrawCharacter (x + 8, -24, num[0]);
708 Sbar_DrawCharacter (x + 16, -24, num[1]);
709 Sbar_DrawCharacter (x + 24, -24, num[2]);
711 if (k == cl.viewentity - 1)
713 Sbar_DrawCharacter ( x + 2, -24, 16);
714 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
720 //=============================================================================
728 void Sbar_DrawFace (void)
732 // PGM 01/19/97 - team color drawing
733 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
734 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
740 s = &cl.scores[cl.viewentity - 1];
742 Sbar_DrawPic (112, 0, rsb_teambord);
743 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
744 DrawQ_Fill (sbar_x + 113, vid.conheight-SBAR_HEIGHT+3, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
745 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
746 DrawQ_Fill (sbar_x + 113, vid.conheight-SBAR_HEIGHT+12, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
750 sprintf (num, "%3i",f);
752 if ((s->colors & 0xf0)==0)
755 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
757 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
759 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
763 Sbar_DrawCharacter ( 109, 3, num[0]);
764 Sbar_DrawCharacter ( 116, 3, num[1]);
765 Sbar_DrawCharacter ( 123, 3, num[2]);
770 // PGM 01/19/97 - team color drawing
772 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
773 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
774 else if (cl.items & IT_QUAD)
775 Sbar_DrawPic (112, 0, sb_face_quad );
776 else if (cl.items & IT_INVISIBILITY)
777 Sbar_DrawPic (112, 0, sb_face_invis );
778 else if (cl.items & IT_INVULNERABILITY)
779 Sbar_DrawPic (112, 0, sb_face_invuln);
782 f = cl.stats[STAT_HEALTH] / 20;
784 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
788 void Sbar_ShowFPS(void)
794 float fps_x, fps_y, fps_scalex, fps_scaley;
795 if (showfps.integer > 1)
797 static double currtime, frametimes[32];
798 double newtime, total;
800 static int framecycle = 0;
802 newtime = Sys_DoubleTime();
803 frametimes[framecycle] = newtime - currtime;
806 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
808 total += frametimes[i];
813 if (showfps.integer == 2)
814 calc = (int) (((double) count / total) + 0.5);
815 else // showfps 3, rapid update
816 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
821 static double nexttime = 0, lasttime = 0;
822 static int framerate = 0, framecount = 0;
824 newtime = Sys_DoubleTime();
825 if (newtime < nexttime)
829 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
831 nexttime = lasttime + 0.2;
836 sprintf(temp, "%4i", calc);
839 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
840 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
841 if (fps_y > vid.conheight - fps_scaley)
842 fps_y = vid.conheight - fps_scaley;
843 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5, 0);
844 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
853 void Sbar_Draw (void)
855 if (scr_con_current == vid.conheight)
856 return; // console is full screen
858 if (cl.intermission == 1)
860 Sbar_IntermissionOverlay();
863 else if (cl.intermission == 2)
865 Sbar_FinaleOverlay();
869 if (gamemode == GAME_NEXUIZ)
871 sbar_y = vid.conheight - 47;
872 sbar_x = (vid.conwidth - 640)/2;
876 Sbar_DrawInventory();
881 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
883 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
884 Sbar_DrawScoreboard ();
888 Sbar_DrawPic (0, 0, sb_sbar);
891 if (cl.items & IT_INVULNERABILITY)
893 Sbar_DrawNum (36, 0, 666, 3, 1);
894 Sbar_DrawPic (0, 0, sb_disc);
898 Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
901 if(cl.stats[STAT_HEALTH] > 100)
902 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
903 else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
904 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
906 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
908 // AK dont draw ammo for the laser
909 if(cl.stats[STAT_ACTIVEWEAPON] != 12)
911 if (cl.items & NEX_IT_SHELLS)
912 Sbar_DrawPic (519, 0, sb_ammo[0]);
913 else if (cl.items & NEX_IT_BULLETS)
914 Sbar_DrawPic (519, 0, sb_ammo[1]);
915 else if (cl.items & NEX_IT_ROCKETS)
916 Sbar_DrawPic (519, 0, sb_ammo[2]);
917 else if (cl.items & NEX_IT_CELLS)
918 Sbar_DrawPic (519, 0, sb_ammo[3]);
920 if(cl.stats[STAT_AMMO] <= 10)
921 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
923 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
927 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
932 sbar_y = vid.conheight - SBAR_HEIGHT;
933 if (cl.gametype == GAME_DEATHMATCH)
936 sbar_x = (vid.conwidth - 320)/2;
940 if (gamemode != GAME_GOODVSBAD2)
941 Sbar_DrawInventory ();
946 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
948 if (gamemode != GAME_GOODVSBAD2)
949 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
950 Sbar_DrawScoreboard ();
954 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
956 // keys (hipnotic only)
957 //MED 01/04/97 moved keys here so they would not be overwritten
958 if (gamemode == GAME_HIPNOTIC)
960 if (cl.items & IT_KEY1)
961 Sbar_DrawPic (209, 3, sb_items[0]);
962 if (cl.items & IT_KEY2)
963 Sbar_DrawPic (209, 12, sb_items[1]);
966 if (gamemode != GAME_GOODVSBAD2)
968 if (cl.items & IT_INVULNERABILITY)
970 Sbar_DrawNum (24, 0, 666, 3, 1);
971 Sbar_DrawPic (0, 0, sb_disc);
975 if (gamemode == GAME_ROGUE)
977 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
978 if (cl.items & RIT_ARMOR3)
979 Sbar_DrawPic (0, 0, sb_armor[2]);
980 else if (cl.items & RIT_ARMOR2)
981 Sbar_DrawPic (0, 0, sb_armor[1]);
982 else if (cl.items & RIT_ARMOR1)
983 Sbar_DrawPic (0, 0, sb_armor[0]);
987 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
988 if (cl.items & IT_ARMOR3)
989 Sbar_DrawPic (0, 0, sb_armor[2]);
990 else if (cl.items & IT_ARMOR2)
991 Sbar_DrawPic (0, 0, sb_armor[1]);
992 else if (cl.items & IT_ARMOR1)
993 Sbar_DrawPic (0, 0, sb_armor[0]);
1002 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1005 if (gamemode == GAME_ROGUE)
1007 if (cl.items & RIT_SHELLS)
1008 Sbar_DrawPic (224, 0, sb_ammo[0]);
1009 else if (cl.items & RIT_NAILS)
1010 Sbar_DrawPic (224, 0, sb_ammo[1]);
1011 else if (cl.items & RIT_ROCKETS)
1012 Sbar_DrawPic (224, 0, sb_ammo[2]);
1013 else if (cl.items & RIT_CELLS)
1014 Sbar_DrawPic (224, 0, sb_ammo[3]);
1015 else if (cl.items & RIT_LAVA_NAILS)
1016 Sbar_DrawPic (224, 0, rsb_ammo[0]);
1017 else if (cl.items & RIT_PLASMA_AMMO)
1018 Sbar_DrawPic (224, 0, rsb_ammo[1]);
1019 else if (cl.items & RIT_MULTI_ROCKETS)
1020 Sbar_DrawPic (224, 0, rsb_ammo[2]);
1024 if (cl.items & IT_SHELLS)
1025 Sbar_DrawPic (224, 0, sb_ammo[0]);
1026 else if (cl.items & IT_NAILS)
1027 Sbar_DrawPic (224, 0, sb_ammo[1]);
1028 else if (cl.items & IT_ROCKETS)
1029 Sbar_DrawPic (224, 0, sb_ammo[2]);
1030 else if (cl.items & IT_CELLS)
1031 Sbar_DrawPic (224, 0, sb_ammo[3]);
1034 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1039 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1040 Sbar_MiniDeathmatchOverlay ();
1044 R_Draw2DCrosshair();
1047 //=============================================================================
1051 Sbar_DeathmatchOverlay
1055 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1058 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1060 // draw colors behind score
1061 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1062 DrawQ_Fill(x + 8, y+1, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
1063 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1064 DrawQ_Fill(x + 8, y+4, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f), 0);
1066 DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1, 0);
1073 void Sbar_DeathmatchOverlay (void)
1078 pic = Draw_CachePic ("gfx/ranking.lmp");
1079 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1, 0);
1084 x = (vid.conwidth - (6 + 15) * 8) / 2;
1086 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1087 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1092 Sbar_DeathmatchOverlay
1096 void Sbar_MiniDeathmatchOverlay (void)
1098 int i, x, y, numlines;
1100 // decide where to print
1101 // AK Nex wants its scores on the upper left
1102 if(gamemode == GAME_NEXUIZ)
1110 y = vid.conheight - sb_lines;
1113 numlines = (vid.conheight - y) / 8;
1114 // give up if there isn't room
1115 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1122 for (i = 0; i < scoreboardlines; i++)
1123 if (fragsort[i] == cl.playerentity - 1)
1126 if (i == scoreboardlines) // we're not there
1128 else // figure out start
1131 i = bound(0, i, scoreboardlines - numlines);
1134 for (;i < scoreboardlines && y < vid.conheight;i++)
1135 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1140 Sbar_IntermissionOverlay
1144 void Sbar_IntermissionOverlay (void)
1149 if (cl.gametype == GAME_DEATHMATCH)
1151 Sbar_DeathmatchOverlay ();
1155 sbar_x = (vid.conwidth - 320) >> 1;
1156 sbar_y = (vid.conheight - 200) >> 1;
1158 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1, 0);
1159 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1, 0);
1162 dig = cl.completed_time/60;
1163 Sbar_DrawNum (160, 64, dig, 3, 0);
1164 num = cl.completed_time - dig*60;
1165 Sbar_DrawPic (234,64,sb_colon);
1166 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1167 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1169 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1170 Sbar_DrawPic (232, 104, sb_slash);
1171 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1173 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1174 Sbar_DrawPic (232, 144, sb_slash);
1175 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1186 void Sbar_FinaleOverlay (void)
1190 pic = Draw_CachePic ("gfx/finale.lmp");
1191 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1, 0);