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 NEX 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]);
372 //=============================================================================
380 static int fragsort[MAX_SCOREBOARD];
381 static int scoreboardlines;
382 void Sbar_SortFrags (void)
388 for (i=0 ; i<cl.maxclients ; i++)
390 if (cl.scores[i].name[0])
392 fragsort[scoreboardlines] = i;
397 for (i=0 ; i<scoreboardlines ; i++)
398 for (j=0 ; j<scoreboardlines-1-i ; j++)
399 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
402 fragsort[j] = fragsort[j+1];
412 void Sbar_SoloScoreboard (void)
415 int minutes, seconds, tens, units;
418 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
419 Sbar_DrawString (8, 4, str);
421 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
422 Sbar_DrawString (8, 12, str);
425 minutes = cl.time / 60;
426 seconds = cl.time - 60*minutes;
428 units = seconds - 10*tens;
429 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
430 Sbar_DrawString (184, 4, str);
433 l = strlen (cl.levelname);
434 Sbar_DrawString (232 - l*4, 12, cl.levelname);
442 void Sbar_DrawScoreboard (void)
444 Sbar_SoloScoreboard ();
445 if (cl.gametype == GAME_DEATHMATCH)
446 Sbar_DeathmatchOverlay ();
449 //=============================================================================
451 // AK to make DrawInventory smaller
452 static void Sbar_DrawWeapon(int nr, float fade, int active)
454 // width = 300, height = 100
455 const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
456 const float w_scale = 0.4;
458 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);
459 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);
462 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);
470 void Sbar_DrawInventory (void)
479 if(gamemode == GAME_NEXUIZ)
481 num[0] = cl.stats[STAT_ACTIVEWEAPON];
482 // we have a max time 2s (min time = 0)
483 if ((time = cl.time - cl.weapontime) > 2)
486 fade = (1.0 - 0.5 * time);
488 for (i = 0; i < 8;i++)
490 if (!(cl.items & (1 << i)))
492 Sbar_DrawWeapon(i + 1, fade, (i == num[0]));
495 if(!(cl.items & (1<<12)))
497 Sbar_DrawWeapon(0, fade, (num[0] == 12));
501 if (gamemode == GAME_ROGUE)
503 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
504 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
506 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
509 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
512 for (i=0 ; i<7 ; i++)
514 if (cl.items & (IT_SHOTGUN<<i) )
516 time = cl.item_gettime[i];
517 flashon = (int)((cl.time - time)*10);
520 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
526 flashon = (flashon%5) + 2;
528 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
534 if (gamemode == GAME_HIPNOTIC)
536 int grenadeflashing=0;
537 for (i=0 ; i<4 ; i++)
539 if (cl.items & (1<<hipweapons[i]) )
541 time = cl.item_gettime[hipweapons[i]];
542 flashon = (int)((cl.time - time)*10);
545 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
551 flashon = (flashon%5) + 2;
553 // check grenade launcher
556 if (cl.items & HIT_PROXIMITY_GUN)
561 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
567 if (cl.items & (IT_SHOTGUN<<4))
569 if (!grenadeflashing)
570 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
573 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
576 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
581 if (gamemode == GAME_ROGUE)
583 // check for powered up weapon.
584 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
586 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
587 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
591 for (i=0 ; i<4 ; i++)
593 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
595 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
597 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
599 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
603 for (i=0 ; i<6 ; i++)
604 if (cl.items & (1<<(17+i)))
606 //MED 01/04/97 changed keys
607 if (gamemode != GAME_HIPNOTIC || (i>1))
608 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
611 //MED 01/04/97 added hipnotic items
613 if (gamemode == GAME_HIPNOTIC)
615 for (i=0 ; i<2 ; i++)
616 if (cl.items & (1<<(24+i)))
617 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
620 if (gamemode == GAME_ROGUE)
623 for (i=0 ; i<2 ; i++)
624 if (cl.items & (1<<(29+i)))
625 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
630 for (i=0 ; i<4 ; i++)
631 if (cl.items & (1<<(28+i)))
632 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
636 //=============================================================================
643 void Sbar_DrawFrags (void)
653 l = scoreboardlines <= 4 ? scoreboardlines : 4;
657 for (i = 0;i < l;i++)
665 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
666 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);
667 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
668 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);
672 sprintf (num, "%3i",f);
674 Sbar_DrawCharacter (x + 8, -24, num[0]);
675 Sbar_DrawCharacter (x + 16, -24, num[1]);
676 Sbar_DrawCharacter (x + 24, -24, num[2]);
678 if (k == cl.viewentity - 1)
680 Sbar_DrawCharacter ( x + 2, -24, 16);
681 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
687 //=============================================================================
695 void Sbar_DrawFace (void)
699 // PGM 01/19/97 - team color drawing
700 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
701 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
707 s = &cl.scores[cl.viewentity - 1];
709 Sbar_DrawPic (112, 0, rsb_teambord);
710 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
711 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);
712 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
713 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);
717 sprintf (num, "%3i",f);
719 if ((s->colors & 0xf0)==0)
722 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
724 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
726 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
730 Sbar_DrawCharacter ( 109, 3, num[0]);
731 Sbar_DrawCharacter ( 116, 3, num[1]);
732 Sbar_DrawCharacter ( 123, 3, num[2]);
737 // PGM 01/19/97 - team color drawing
739 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
740 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
741 else if (cl.items & IT_QUAD)
742 Sbar_DrawPic (112, 0, sb_face_quad );
743 else if (cl.items & IT_INVISIBILITY)
744 Sbar_DrawPic (112, 0, sb_face_invis );
745 else if (cl.items & IT_INVULNERABILITY)
746 Sbar_DrawPic (112, 0, sb_face_invuln);
749 f = cl.stats[STAT_HEALTH] / 20;
751 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
755 void Sbar_ShowFPS(void)
761 float fps_x, fps_y, fps_scalex, fps_scaley;
762 if (showfps.integer > 1)
764 static double currtime, frametimes[32];
765 double newtime, total;
767 static int framecycle = 0;
769 newtime = Sys_DoubleTime();
770 frametimes[framecycle] = newtime - currtime;
773 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
775 total += frametimes[i];
780 if (showfps.integer == 2)
781 calc = (int) (((double) count / total) + 0.5);
782 else // showfps 3, rapid update
783 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
788 static double nexttime = 0, lasttime = 0;
789 static int framerate = 0, framecount = 0;
791 newtime = Sys_DoubleTime();
792 if (newtime < nexttime)
796 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
798 nexttime = lasttime + 0.2;
803 sprintf(temp, "%4i", calc);
806 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
807 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
808 if (fps_y > vid.conheight - fps_scaley)
809 fps_y = vid.conheight - fps_scaley;
810 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5, 0);
811 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
820 void Sbar_Draw (void)
822 if (scr_con_current == vid.conheight)
823 return; // console is full screen
825 if (cl.intermission == 1)
827 Sbar_IntermissionOverlay();
830 else if (cl.intermission == 2)
832 Sbar_FinaleOverlay();
836 if (gamemode == GAME_NEXUIZ)
838 sbar_y = vid.conheight - 47;
839 sbar_x = (vid.conwidth - 640)/2;
844 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
846 if (gamemode != GAME_GOODVSBAD2)
847 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
848 Sbar_DrawScoreboard ();
852 Sbar_DrawPic (0, 0, sb_sbar);
855 if (cl.items & IT_INVULNERABILITY)
857 Sbar_DrawNum (24, 0, 666, 3, 1);
858 Sbar_DrawPic (0, 0, sb_disc);
862 Sbar_DrawNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
865 Sbar_DrawNum ((154-3*24), 12, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
867 if (cl.items & NEX_IT_SHELLS)
868 Sbar_DrawPic (519, 0, sb_ammo[0]);
869 else if (cl.items & NEX_IT_BULLETS)
870 Sbar_DrawPic (519, 0, sb_ammo[1]);
871 else if (cl.items & NEX_IT_ROCKETS)
872 Sbar_DrawPic (519, 0, sb_ammo[2]);
873 else if (cl.items & NEX_IT_CELLS)
874 Sbar_DrawPic (519, 0, sb_ammo[3]);
876 Sbar_DrawNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
878 //Sbar_DrawAlphaPic(0,0,sb_sbar_overlay,0.5);
879 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
884 sbar_y = vid.conheight - SBAR_HEIGHT;
885 if (cl.gametype == GAME_DEATHMATCH)
888 sbar_x = (vid.conwidth - 320)/2;
892 if (gamemode != GAME_GOODVSBAD2)
893 Sbar_DrawInventory ();
898 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
900 if (gamemode != GAME_GOODVSBAD2)
901 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
902 Sbar_DrawScoreboard ();
906 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
908 // keys (hipnotic only)
909 //MED 01/04/97 moved keys here so they would not be overwritten
910 if (gamemode == GAME_HIPNOTIC)
912 if (cl.items & IT_KEY1)
913 Sbar_DrawPic (209, 3, sb_items[0]);
914 if (cl.items & IT_KEY2)
915 Sbar_DrawPic (209, 12, sb_items[1]);
918 if (gamemode != GAME_GOODVSBAD2)
920 if (cl.items & IT_INVULNERABILITY)
922 Sbar_DrawNum (24, 0, 666, 3, 1);
923 Sbar_DrawPic (0, 0, sb_disc);
927 if (gamemode == GAME_ROGUE)
929 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
930 if (cl.items & RIT_ARMOR3)
931 Sbar_DrawPic (0, 0, sb_armor[2]);
932 else if (cl.items & RIT_ARMOR2)
933 Sbar_DrawPic (0, 0, sb_armor[1]);
934 else if (cl.items & RIT_ARMOR1)
935 Sbar_DrawPic (0, 0, sb_armor[0]);
939 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
940 if (cl.items & IT_ARMOR3)
941 Sbar_DrawPic (0, 0, sb_armor[2]);
942 else if (cl.items & IT_ARMOR2)
943 Sbar_DrawPic (0, 0, sb_armor[1]);
944 else if (cl.items & IT_ARMOR1)
945 Sbar_DrawPic (0, 0, sb_armor[0]);
954 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
957 if (gamemode == GAME_ROGUE)
959 if (cl.items & RIT_SHELLS)
960 Sbar_DrawPic (224, 0, sb_ammo[0]);
961 else if (cl.items & RIT_NAILS)
962 Sbar_DrawPic (224, 0, sb_ammo[1]);
963 else if (cl.items & RIT_ROCKETS)
964 Sbar_DrawPic (224, 0, sb_ammo[2]);
965 else if (cl.items & RIT_CELLS)
966 Sbar_DrawPic (224, 0, sb_ammo[3]);
967 else if (cl.items & RIT_LAVA_NAILS)
968 Sbar_DrawPic (224, 0, rsb_ammo[0]);
969 else if (cl.items & RIT_PLASMA_AMMO)
970 Sbar_DrawPic (224, 0, rsb_ammo[1]);
971 else if (cl.items & RIT_MULTI_ROCKETS)
972 Sbar_DrawPic (224, 0, rsb_ammo[2]);
976 if (cl.items & IT_SHELLS)
977 Sbar_DrawPic (224, 0, sb_ammo[0]);
978 else if (cl.items & IT_NAILS)
979 Sbar_DrawPic (224, 0, sb_ammo[1]);
980 else if (cl.items & IT_ROCKETS)
981 Sbar_DrawPic (224, 0, sb_ammo[2]);
982 else if (cl.items & IT_CELLS)
983 Sbar_DrawPic (224, 0, sb_ammo[3]);
986 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
992 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
993 Sbar_MiniDeathmatchOverlay ();
1000 //=============================================================================
1004 Sbar_DeathmatchOverlay
1008 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1011 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1013 // draw colors behind score
1014 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1015 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);
1016 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1017 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);
1019 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);
1026 void Sbar_DeathmatchOverlay (void)
1031 pic = Draw_CachePic ("gfx/ranking.lmp");
1032 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1, 0);
1037 x = (vid.conwidth - (6 + 15) * 8) / 2;
1039 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1040 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1045 Sbar_DeathmatchOverlay
1049 void Sbar_MiniDeathmatchOverlay (void)
1051 int i, x, y, numlines;
1053 // decide where to print
1055 y = vid.conheight - sb_lines;
1056 numlines = (vid.conheight - y) / 8;
1057 // give up if there isn't room
1058 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1065 for (i = 0; i < scoreboardlines; i++)
1066 if (fragsort[i] == cl.playerentity - 1)
1069 if (i == scoreboardlines) // we're not there
1071 else // figure out start
1074 i = bound(0, i, scoreboardlines - numlines);
1077 for (;i < scoreboardlines && y < vid.conheight;i++)
1078 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1083 Sbar_IntermissionOverlay
1087 void Sbar_IntermissionOverlay (void)
1092 if (cl.gametype == GAME_DEATHMATCH)
1094 Sbar_DeathmatchOverlay ();
1098 sbar_x = (vid.conwidth - 320) >> 1;
1099 sbar_y = (vid.conheight - 200) >> 1;
1101 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1, 0);
1102 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1, 0);
1105 dig = cl.completed_time/60;
1106 Sbar_DrawNum (160, 64, dig, 3, 0);
1107 num = cl.completed_time - dig*60;
1108 Sbar_DrawPic (234,64,sb_colon);
1109 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1110 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1112 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1113 Sbar_DrawPic (232, 104, sb_slash);
1114 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1116 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1117 Sbar_DrawPic (232, 144, sb_slash);
1118 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1129 void Sbar_FinaleOverlay (void)
1133 pic = Draw_CachePic ("gfx/finale.lmp");
1134 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1, 0);