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;
51 sbarpic_t *sb_weapons[7][8]; // 0 is active, 1 is owned, 2-5 are flashes
52 sbarpic_t *sb_ammo[4];
53 sbarpic_t *sb_sigil[4];
54 sbarpic_t *sb_armor[3];
55 sbarpic_t *sb_items[32];
57 // 0-4 are based on health (in 20 increments)
58 // 0 is static, 1 is temporary animation
59 sbarpic_t *sb_faces[5][2];
61 sbarpic_t *sb_face_invis;
62 sbarpic_t *sb_face_quad;
63 sbarpic_t *sb_face_invuln;
64 sbarpic_t *sb_face_invis_invuln;
66 qboolean sb_showscores;
68 int sb_lines; // scan lines to draw
70 sbarpic_t *rsb_invbar[2];
71 sbarpic_t *rsb_weapons[5];
72 sbarpic_t *rsb_items[2];
73 sbarpic_t *rsb_ammo[3];
74 sbarpic_t *rsb_teambord; // PGM 01/19/97 - team color border
76 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
77 sbarpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
78 //MED 01/04/97 added array to simplify weapon parsing
79 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
80 //MED 01/04/97 added hipnotic items array
81 sbarpic_t *hsb_items[2];
83 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
85 void Sbar_MiniDeathmatchOverlay (void);
86 void Sbar_DeathmatchOverlay (void);
87 void Sbar_IntermissionOverlay (void);
88 void Sbar_FinaleOverlay (void);
98 void Sbar_ShowScores (void)
102 sb_showscores = true;
112 void Sbar_DontShowScores (void)
114 sb_showscores = false;
117 void sbar_start(void)
123 sb_disc = Sbar_NewPic("gfx/disc");
125 for (i = 0;i < 10;i++)
127 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
128 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
131 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
132 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
134 sb_colon = Sbar_NewPic ("gfx/num_colon");
135 sb_slash = Sbar_NewPic ("gfx/num_slash");
137 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
138 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
139 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
140 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
141 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
142 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
143 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
145 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
146 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
147 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
148 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
149 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
150 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
151 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
153 for (i = 0;i < 5;i++)
155 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
156 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
157 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
158 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
159 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
160 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
161 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
164 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
165 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
166 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
167 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
169 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
170 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
171 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
173 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
174 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
175 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
176 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
177 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
178 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
180 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
181 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
182 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
183 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
185 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
186 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
187 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
188 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
189 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
190 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
191 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
192 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
193 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
194 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
196 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
197 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
198 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
199 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
201 sb_sbar = Sbar_NewPic ("gfx/sbar");
202 sb_ibar = Sbar_NewPic ("gfx/ibar");
203 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
205 //MED 01/04/97 added new hipnotic weapons
206 if (gamemode == GAME_HIPNOTIC)
208 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
209 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
210 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
211 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
212 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
214 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
215 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
216 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
217 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
218 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
220 for (i = 0;i < 5;i++)
222 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
223 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
224 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
225 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
226 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
229 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
230 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
232 else if (gamemode == GAME_ROGUE)
234 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
235 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
237 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
238 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
239 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
240 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
241 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
243 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
244 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
246 // PGM 01/19/97 - team color border
247 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
248 // PGM 01/19/97 - team color border
250 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
251 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
252 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
256 void sbar_shutdown(void)
260 void sbar_newmap(void)
264 void Sbar_Init (void)
266 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
267 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
268 Cvar_RegisterVariable (&showfps);
270 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
274 //=============================================================================
276 // drawing routines are relative to the status bar location
285 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
287 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, 1, 0);
290 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
292 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha, 0);
299 Draws one solid graphics character
302 void Sbar_DrawCharacter (int x, int y, int num)
304 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, 1, 0);
312 void Sbar_DrawString (int x, int y, char *str)
314 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, 1, 0);
322 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
327 l = sprintf(str, "%i", num);
341 Sbar_DrawPic (x, y, sb_nums[color][frame]);
347 //=============================================================================
355 static int fragsort[MAX_SCOREBOARD];
356 static int scoreboardlines;
357 void Sbar_SortFrags (void)
363 for (i=0 ; i<cl.maxclients ; i++)
365 if (cl.scores[i].name[0])
367 fragsort[scoreboardlines] = i;
372 for (i=0 ; i<scoreboardlines ; i++)
373 for (j=0 ; j<scoreboardlines-1-i ; j++)
374 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
377 fragsort[j] = fragsort[j+1];
387 void Sbar_SoloScoreboard (void)
390 int minutes, seconds, tens, units;
393 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
394 Sbar_DrawString (8, 4, str);
396 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
397 Sbar_DrawString (8, 12, str);
400 minutes = cl.time / 60;
401 seconds = cl.time - 60*minutes;
403 units = seconds - 10*tens;
404 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
405 Sbar_DrawString (184, 4, str);
408 l = strlen (cl.levelname);
409 Sbar_DrawString (232 - l*4, 12, cl.levelname);
417 void Sbar_DrawScoreboard (void)
419 Sbar_SoloScoreboard ();
420 if (cl.gametype == GAME_DEATHMATCH)
421 Sbar_DeathmatchOverlay ();
424 //=============================================================================
431 void Sbar_DrawInventory (void)
438 if (gamemode == GAME_ROGUE)
440 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
441 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
443 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
446 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
449 for (i=0 ; i<7 ; i++)
451 if (cl.items & (IT_SHOTGUN<<i) )
453 time = cl.item_gettime[i];
454 flashon = (int)((cl.time - time)*10);
457 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
463 flashon = (flashon%5) + 2;
465 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
471 if (gamemode == GAME_HIPNOTIC)
473 int grenadeflashing=0;
474 for (i=0 ; i<4 ; i++)
476 if (cl.items & (1<<hipweapons[i]) )
478 time = cl.item_gettime[hipweapons[i]];
479 flashon = (int)((cl.time - time)*10);
482 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
488 flashon = (flashon%5) + 2;
490 // check grenade launcher
493 if (cl.items & HIT_PROXIMITY_GUN)
498 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
504 if (cl.items & (IT_SHOTGUN<<4))
506 if (!grenadeflashing)
507 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
510 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
513 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
518 if (gamemode == GAME_ROGUE)
520 // check for powered up weapon.
521 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
523 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
524 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
528 for (i=0 ; i<4 ; i++)
530 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
532 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
534 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
536 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
540 for (i=0 ; i<6 ; i++)
541 if (cl.items & (1<<(17+i)))
543 //MED 01/04/97 changed keys
544 if (gamemode != GAME_HIPNOTIC || (i>1))
545 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
548 //MED 01/04/97 added hipnotic items
550 if (gamemode == GAME_HIPNOTIC)
552 for (i=0 ; i<2 ; i++)
553 if (cl.items & (1<<(24+i)))
554 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
557 if (gamemode == GAME_ROGUE)
560 for (i=0 ; i<2 ; i++)
561 if (cl.items & (1<<(29+i)))
562 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
567 for (i=0 ; i<4 ; i++)
568 if (cl.items & (1<<(28+i)))
569 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
573 //=============================================================================
580 void Sbar_DrawFrags (void)
590 l = scoreboardlines <= 4 ? scoreboardlines : 4;
594 for (i = 0;i < l;i++)
602 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
603 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);
604 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
605 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);
609 sprintf (num, "%3i",f);
611 Sbar_DrawCharacter (x + 8, -24, num[0]);
612 Sbar_DrawCharacter (x + 16, -24, num[1]);
613 Sbar_DrawCharacter (x + 24, -24, num[2]);
615 if (k == cl.viewentity - 1)
617 Sbar_DrawCharacter ( x + 2, -24, 16);
618 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
624 //=============================================================================
632 void Sbar_DrawFace (void)
636 // PGM 01/19/97 - team color drawing
637 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
638 if (gamemode == GAME_ROGUE && (cl.maxclients != 1) && (teamplay.integer > 3) && (teamplay.integer < 7))
644 s = &cl.scores[cl.viewentity - 1];
646 Sbar_DrawPic (112, 0, rsb_teambord);
647 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
648 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);
649 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
650 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);
654 sprintf (num, "%3i",f);
656 if ((s->colors & 0xf0)==0)
659 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
661 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
663 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
667 Sbar_DrawCharacter ( 109, 3, num[0]);
668 Sbar_DrawCharacter ( 116, 3, num[1]);
669 Sbar_DrawCharacter ( 123, 3, num[2]);
674 // PGM 01/19/97 - team color drawing
676 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
677 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
678 else if (cl.items & IT_QUAD)
679 Sbar_DrawPic (112, 0, sb_face_quad );
680 else if (cl.items & IT_INVISIBILITY)
681 Sbar_DrawPic (112, 0, sb_face_invis );
682 else if (cl.items & IT_INVULNERABILITY)
683 Sbar_DrawPic (112, 0, sb_face_invuln);
686 f = cl.stats[STAT_HEALTH] / 20;
688 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
692 void Sbar_ShowFPS(void)
698 float fps_x, fps_y, fps_scalex, fps_scaley;
699 if (showfps.integer > 1)
701 static double currtime, frametimes[32];
702 double newtime, total;
704 static int framecycle = 0;
706 newtime = Sys_DoubleTime();
707 frametimes[framecycle] = newtime - currtime;
710 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
712 total += frametimes[i];
717 if (showfps.integer == 2)
718 calc = (int) (((double) count / total) + 0.5);
719 else // showfps 3, rapid update
720 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
725 static double nexttime = 0, lasttime = 0;
726 static int framerate = 0, framecount = 0;
728 newtime = Sys_DoubleTime();
729 if (newtime < nexttime)
733 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
735 nexttime = lasttime + 0.2;
740 sprintf(temp, "%4i", calc);
743 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
744 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
745 if (fps_y > vid.conheight - fps_scaley)
746 fps_y = vid.conheight - fps_scaley;
747 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5, 0);
748 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
757 void Sbar_Draw (void)
759 if (scr_con_current == vid.conheight)
760 return; // console is full screen
762 if (cl.intermission == 1)
764 Sbar_IntermissionOverlay();
767 else if (cl.intermission == 2)
769 Sbar_FinaleOverlay();
773 sbar_y = vid.conheight - SBAR_HEIGHT;
774 if (cl.gametype == GAME_DEATHMATCH)
777 sbar_x = (vid.conwidth - 320)/2;
781 if (gamemode != GAME_GOODVSBAD2)
782 Sbar_DrawInventory ();
783 if (cl.maxclients != 1)
787 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
789 if (gamemode != GAME_GOODVSBAD2)
790 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
791 Sbar_DrawScoreboard ();
795 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
797 // keys (hipnotic only)
798 //MED 01/04/97 moved keys here so they would not be overwritten
799 if (gamemode == GAME_HIPNOTIC)
801 if (cl.items & IT_KEY1)
802 Sbar_DrawPic (209, 3, sb_items[0]);
803 if (cl.items & IT_KEY2)
804 Sbar_DrawPic (209, 12, sb_items[1]);
807 if (gamemode != GAME_GOODVSBAD2)
809 if (cl.items & IT_INVULNERABILITY)
811 Sbar_DrawNum (24, 0, 666, 3, 1);
812 Sbar_DrawPic (0, 0, sb_disc);
816 if (gamemode == GAME_ROGUE)
818 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
819 if (cl.items & RIT_ARMOR3)
820 Sbar_DrawPic (0, 0, sb_armor[2]);
821 else if (cl.items & RIT_ARMOR2)
822 Sbar_DrawPic (0, 0, sb_armor[1]);
823 else if (cl.items & RIT_ARMOR1)
824 Sbar_DrawPic (0, 0, sb_armor[0]);
828 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
829 if (cl.items & IT_ARMOR3)
830 Sbar_DrawPic (0, 0, sb_armor[2]);
831 else if (cl.items & IT_ARMOR2)
832 Sbar_DrawPic (0, 0, sb_armor[1]);
833 else if (cl.items & IT_ARMOR1)
834 Sbar_DrawPic (0, 0, sb_armor[0]);
843 Sbar_DrawNum (136, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
846 if (gamemode == GAME_ROGUE)
848 if (cl.items & RIT_SHELLS)
849 Sbar_DrawPic (224, 0, sb_ammo[0]);
850 else if (cl.items & RIT_NAILS)
851 Sbar_DrawPic (224, 0, sb_ammo[1]);
852 else if (cl.items & RIT_ROCKETS)
853 Sbar_DrawPic (224, 0, sb_ammo[2]);
854 else if (cl.items & RIT_CELLS)
855 Sbar_DrawPic (224, 0, sb_ammo[3]);
856 else if (cl.items & RIT_LAVA_NAILS)
857 Sbar_DrawPic (224, 0, rsb_ammo[0]);
858 else if (cl.items & RIT_PLASMA_AMMO)
859 Sbar_DrawPic (224, 0, rsb_ammo[1]);
860 else if (cl.items & RIT_MULTI_ROCKETS)
861 Sbar_DrawPic (224, 0, rsb_ammo[2]);
865 if (cl.items & IT_SHELLS)
866 Sbar_DrawPic (224, 0, sb_ammo[0]);
867 else if (cl.items & IT_NAILS)
868 Sbar_DrawPic (224, 0, sb_ammo[1]);
869 else if (cl.items & IT_ROCKETS)
870 Sbar_DrawPic (224, 0, sb_ammo[2]);
871 else if (cl.items & IT_CELLS)
872 Sbar_DrawPic (224, 0, sb_ammo[3]);
875 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
878 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
879 Sbar_MiniDeathmatchOverlay ();
886 //=============================================================================
890 Sbar_DeathmatchOverlay
894 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
897 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
899 // draw colors behind score
900 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
901 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);
902 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
903 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);
905 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);
912 void Sbar_DeathmatchOverlay (void)
917 pic = Draw_CachePic ("gfx/ranking.lmp");
918 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1, 0);
923 x = (vid.conwidth - (6 + 15) * 8) / 2;
925 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
926 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
931 Sbar_DeathmatchOverlay
935 void Sbar_MiniDeathmatchOverlay (void)
937 int i, x, y, numlines;
939 // decide where to print
941 y = vid.conheight - sb_lines;
942 numlines = (vid.conheight - y) / 8;
943 // give up if there isn't room
944 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
951 for (i = 0; i < scoreboardlines; i++)
952 if (fragsort[i] == cl.playerentity - 1)
955 if (i == scoreboardlines) // we're not there
957 else // figure out start
960 i = bound(0, i, scoreboardlines - numlines);
963 for (;i < scoreboardlines && y < vid.conheight;i++)
964 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
969 Sbar_IntermissionOverlay
973 void Sbar_IntermissionOverlay (void)
978 if (cl.gametype == GAME_DEATHMATCH)
980 Sbar_DeathmatchOverlay ();
984 sbar_x = (vid.conwidth - 320) >> 1;
985 sbar_y = (vid.conheight - 200) >> 1;
987 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1, 0);
988 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1, 0);
991 dig = cl.completed_time/60;
992 Sbar_DrawNum (160, 64, dig, 3, 0);
993 num = cl.completed_time - dig*60;
994 Sbar_DrawPic (234,64,sb_colon);
995 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
996 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
998 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
999 Sbar_DrawPic (232, 104, sb_slash);
1000 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1002 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1003 Sbar_DrawPic (232, 144, sb_slash);
1004 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1015 void Sbar_FinaleOverlay (void)
1019 pic = Draw_CachePic ("gfx/finale.lmp");
1020 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1, 0);