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, true);
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
51 sbarpic_t *sb_sbar_minimal;
52 sbarpic_t *sb_sbar_overlay;
54 // AK changed the bound to 9
55 sbarpic_t *sb_weapons[7][9]; // 0 is active, 1 is owned, 2-5 are flashes
56 sbarpic_t *sb_ammo[4];
57 sbarpic_t *sb_sigil[4];
58 sbarpic_t *sb_armor[3];
59 sbarpic_t *sb_items[32];
61 // 0-4 are based on health (in 20 increments)
62 // 0 is static, 1 is temporary animation
63 sbarpic_t *sb_faces[5][2];
65 sbarpic_t *sb_face_invis;
66 sbarpic_t *sb_face_quad;
67 sbarpic_t *sb_face_invuln;
68 sbarpic_t *sb_face_invis_invuln;
70 qboolean sb_showscores;
72 int sb_lines; // scan lines to draw
74 sbarpic_t *rsb_invbar[2];
75 sbarpic_t *rsb_weapons[5];
76 sbarpic_t *rsb_items[2];
77 sbarpic_t *rsb_ammo[3];
78 sbarpic_t *rsb_teambord; // PGM 01/19/97 - team color border
80 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
81 sbarpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
82 //MED 01/04/97 added array to simplify weapon parsing
83 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
84 //MED 01/04/97 added hipnotic items array
85 sbarpic_t *hsb_items[2];
88 sbarpic_t *somsb_health;
89 sbarpic_t *somsb_ammo[4];
90 sbarpic_t *somsb_armor[3];
92 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
93 cvar_t showtime = {CVAR_SAVE, "showtime", "0"};
94 cvar_t showtime_format = {CVAR_SAVE, "showtime_format", "%H:%M:%S"};
95 cvar_t showdate = {CVAR_SAVE, "showdate", "0"};
96 cvar_t showdate_format = {CVAR_SAVE, "showdate_format", "%Y-%m-%d"};
97 cvar_t sbar_alpha_bg = {CVAR_SAVE, "sbar_alpha_bg", "0.4"};
98 cvar_t sbar_alpha_fg = {CVAR_SAVE, "sbar_alpha_fg", "1"};
100 void Sbar_MiniDeathmatchOverlay (int x, int y);
101 void Sbar_DeathmatchOverlay (void);
102 void Sbar_IntermissionOverlay (void);
103 void Sbar_FinaleOverlay (void);
113 void Sbar_ShowScores (void)
117 sb_showscores = true;
127 void Sbar_DontShowScores (void)
129 sb_showscores = false;
132 void sbar_start(void)
138 if (gamemode == GAME_SOM)
140 sb_disc = Sbar_NewPic("gfx/disc");
142 for (i = 0;i < 10;i++)
143 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
145 somsb_health = Sbar_NewPic("gfx/hud_health");
146 somsb_ammo[0] = Sbar_NewPic("gfx/sb_shells");
147 somsb_ammo[1] = Sbar_NewPic("gfx/sb_nails");
148 somsb_ammo[2] = Sbar_NewPic("gfx/sb_rocket");
149 somsb_ammo[3] = Sbar_NewPic("gfx/sb_cells");
150 somsb_armor[0] = Sbar_NewPic("gfx/sb_armor1");
151 somsb_armor[1] = Sbar_NewPic("gfx/sb_armor2");
152 somsb_armor[2] = Sbar_NewPic("gfx/sb_armor3");
154 else if (gamemode == GAME_NEXUIZ)
156 for (i = 0;i < 10;i++)
157 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
158 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
160 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
161 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
162 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
163 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
165 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
166 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
167 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
168 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
170 sb_sbar = Sbar_NewPic("gfx/sbar");
171 sb_sbar_minimal = Sbar_NewPic("gfx/sbar_minimal");
172 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
174 for(i = 0; i < 9;i++)
175 sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
179 sb_disc = Sbar_NewPic("gfx/disc");
181 for (i = 0;i < 10;i++)
183 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
184 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
187 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
188 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
190 sb_colon = Sbar_NewPic ("gfx/num_colon");
191 sb_slash = Sbar_NewPic ("gfx/num_slash");
193 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
194 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
195 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
196 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
197 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
198 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
199 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
201 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
202 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
203 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
204 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
205 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
206 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
207 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
209 for (i = 0;i < 5;i++)
211 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
212 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
213 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
214 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
215 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
216 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
217 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
220 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
221 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
222 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
223 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
225 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
226 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
227 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
229 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
230 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
231 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
232 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
233 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
234 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
236 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
237 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
238 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
239 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
241 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
242 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
243 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
244 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
245 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
246 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
247 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
248 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
249 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
250 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
252 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
253 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
254 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
255 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
257 sb_sbar = Sbar_NewPic ("gfx/sbar");
258 sb_ibar = Sbar_NewPic ("gfx/ibar");
259 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
261 //MED 01/04/97 added new hipnotic weapons
262 if (gamemode == GAME_HIPNOTIC)
264 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
265 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
266 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
267 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
268 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
270 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
271 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
272 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
273 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
274 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
276 for (i = 0;i < 5;i++)
278 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
279 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
280 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
281 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
282 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
285 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
286 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
288 else if (gamemode == GAME_ROGUE)
290 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
291 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
293 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
294 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
295 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
296 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
297 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
299 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
300 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
302 // PGM 01/19/97 - team color border
303 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
304 // PGM 01/19/97 - team color border
306 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
307 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
308 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
313 void sbar_shutdown(void)
317 void sbar_newmap(void)
321 void Sbar_Init (void)
323 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
324 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
325 Cvar_RegisterVariable (&showfps);
326 Cvar_RegisterVariable (&showtime);
327 Cvar_RegisterVariable (&showtime_format);
328 Cvar_RegisterVariable (&showdate);
329 Cvar_RegisterVariable (&showdate_format);
330 Cvar_RegisterVariable (&sbar_alpha_bg);
331 Cvar_RegisterVariable (&sbar_alpha_fg);
333 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
337 //=============================================================================
339 // drawing routines are relative to the status bar location
348 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
350 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha_fg.value, 0);
353 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
355 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha, 0);
362 Draws one solid graphics character
365 void Sbar_DrawCharacter (int x, int y, int num)
367 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha_fg.value, 0);
375 void Sbar_DrawString (int x, int y, char *str)
377 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha_fg.value, 0);
385 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
390 l = sprintf(str, "%i", num);
404 Sbar_DrawPic (x, y, sb_nums[color][frame]);
417 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
422 l = sprintf(str, "%i", num);
427 x += (digits-l) * lettersize;
436 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha_fg.value,flags);
443 //=============================================================================
451 static int fragsort[MAX_SCOREBOARD];
452 static int scoreboardlines;
453 void Sbar_SortFrags (void)
459 for (i=0 ; i<cl.maxclients ; i++)
461 if (cl.scores[i].name[0])
463 fragsort[scoreboardlines] = i;
468 for (i=0 ; i<scoreboardlines ; i++)
469 for (j=0 ; j<scoreboardlines-1-i ; j++)
470 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
473 fragsort[j] = fragsort[j+1];
483 void Sbar_SoloScoreboard (void)
486 int minutes, seconds, tens, units;
489 if (gamemode != GAME_NEXUIZ) {
490 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
491 Sbar_DrawString (8, 4, str);
493 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
494 Sbar_DrawString (8, 12, str);
498 minutes = cl.time / 60;
499 seconds = cl.time - 60*minutes;
501 units = seconds - 10*tens;
502 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
503 Sbar_DrawString (184, 4, str);
506 if (gamemode == GAME_NEXUIZ) {
507 l = (int) strlen (cl.worldmodel->name);
508 Sbar_DrawString (232 - l*4, 12, cl.worldmodel->name);
510 l = (int) strlen (cl.levelname);
511 Sbar_DrawString (232 - l*4, 12, cl.levelname);
520 void Sbar_DrawScoreboard (void)
522 Sbar_SoloScoreboard ();
523 if (cl.gametype == GAME_DEATHMATCH)
524 Sbar_DeathmatchOverlay ();
527 //=============================================================================
529 // AK to make DrawInventory smaller
530 static void Sbar_DrawWeapon(int nr, float fade, int active)
532 // width = 300, height = 100
533 const int w_width = 300, w_height = 100, w_space = 10;
534 const float w_scale = 0.4;
536 DrawQ_Pic(vid_conwidth.integer - (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 * sbar_alpha_fg.value, DRAWFLAG_ADDITIVE);
537 //DrawQ_String(vid_conwidth.integer - (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);
540 DrawQ_Fill(vid_conwidth.integer - (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 * sbar_alpha_fg.value, DRAWFLAG_ADDITIVE);
548 void Sbar_DrawInventory (void)
555 if (gamemode == GAME_ROGUE)
557 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
558 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], sbar_alpha_bg.value);
560 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], sbar_alpha_bg.value);
563 Sbar_DrawAlphaPic (0, -24, sb_ibar, sbar_alpha_bg.value);
566 for (i=0 ; i<7 ; i++)
568 if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN<<i) )
570 time = cl.item_gettime[i];
571 flashon = (int)((cl.time - time)*10);
574 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
580 flashon = (flashon%5) + 2;
582 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], sbar_alpha_bg.value);
588 if (gamemode == GAME_HIPNOTIC)
590 int grenadeflashing=0;
591 for (i=0 ; i<4 ; i++)
593 if (cl.stats[STAT_ITEMS] & (1<<hipweapons[i]) )
595 time = cl.item_gettime[hipweapons[i]];
596 flashon = (int)((cl.time - time)*10);
599 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
605 flashon = (flashon%5) + 2;
607 // check grenade launcher
610 if (cl.stats[STAT_ITEMS] & HIT_PROXIMITY_GUN)
615 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
621 if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN<<4))
623 if (!grenadeflashing)
624 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
627 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
630 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
635 if (gamemode == GAME_ROGUE)
637 // check for powered up weapon.
638 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
640 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
641 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
645 for (i=0 ; i<4 ; i++)
647 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
649 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
651 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
653 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
657 for (i=0 ; i<6 ; i++)
658 if (cl.stats[STAT_ITEMS] & (1<<(17+i)))
660 //MED 01/04/97 changed keys
661 if (gamemode != GAME_HIPNOTIC || (i>1))
662 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
665 //MED 01/04/97 added hipnotic items
667 if (gamemode == GAME_HIPNOTIC)
669 for (i=0 ; i<2 ; i++)
670 if (cl.stats[STAT_ITEMS] & (1<<(24+i)))
671 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
674 if (gamemode == GAME_ROGUE)
677 for (i=0 ; i<2 ; i++)
678 if (cl.stats[STAT_ITEMS] & (1<<(29+i)))
679 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
684 for (i=0 ; i<4 ; i++)
685 if (cl.stats[STAT_ITEMS] & (1<<(28+i)))
686 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
690 //=============================================================================
697 void Sbar_DrawFrags (void)
707 l = min(scoreboardlines, 4);
711 for (i = 0;i < l;i++)
717 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
718 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) * sbar_alpha_fg.value, 0);
719 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
720 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) * sbar_alpha_fg.value, 0);
724 sprintf (num, "%3i",f);
726 if (k == cl.viewentity - 1)
728 Sbar_DrawCharacter ( x + 2, -24, 16);
729 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
731 Sbar_DrawCharacter (x + 8, -24, num[0]);
732 Sbar_DrawCharacter (x + 16, -24, num[1]);
733 Sbar_DrawCharacter (x + 24, -24, num[2]);
738 //=============================================================================
746 void Sbar_DrawFace (void)
750 // PGM 01/19/97 - team color drawing
751 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
752 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
758 s = &cl.scores[cl.viewentity - 1];
760 Sbar_DrawPic (112, 0, rsb_teambord);
761 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
762 DrawQ_Fill (sbar_x + 113, vid_conheight.integer-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) * sbar_alpha_fg.value, 0);
763 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
764 DrawQ_Fill (sbar_x + 113, vid_conheight.integer-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) * sbar_alpha_fg.value, 0);
768 sprintf (num, "%3i",f);
770 if ((s->colors & 0xf0)==0)
773 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
775 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
777 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
781 Sbar_DrawCharacter ( 109, 3, num[0]);
782 Sbar_DrawCharacter ( 116, 3, num[1]);
783 Sbar_DrawCharacter ( 123, 3, num[2]);
788 // PGM 01/19/97 - team color drawing
790 if ( (cl.stats[STAT_ITEMS] & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
791 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
792 else if (cl.stats[STAT_ITEMS] & IT_QUAD)
793 Sbar_DrawPic (112, 0, sb_face_quad );
794 else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
795 Sbar_DrawPic (112, 0, sb_face_invis );
796 else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
797 Sbar_DrawPic (112, 0, sb_face_invuln);
800 f = cl.stats[STAT_HEALTH] / 20;
802 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
806 void Sbar_ShowFPS(void)
808 float fps_x, fps_y, fps_scalex, fps_scaley, fps_height;
818 if (showfps.integer > 1)
820 static double currtime, frametimes[32];
821 double newtime, total;
823 static int framecycle = 0;
825 newtime = Sys_DoubleTime();
826 frametimes[framecycle] = newtime - currtime;
829 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
831 total += frametimes[i];
836 if (showfps.integer == 2)
837 calc = (int) (((double) count / total) + 0.5);
838 else // showfps 3, rapid update
839 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
844 static double nexttime = 0, lasttime = 0;
845 static int framerate = 0, framecount = 0;
847 newtime = Sys_DoubleTime();
848 if (newtime >= nexttime)
850 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
852 nexttime = max(nexttime + 1, lasttime - 1);
858 dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", calc);
860 if (showtime.integer)
861 strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
862 if (showdate.integer)
863 strlcpy(datestring, Sys_TimeString(showdate_format.string), sizeof(datestring));
864 if (fpsstring[0] || timestring[0])
868 fps_height = fps_scaley * ((fpsstring[0] != 0) + (timestring[0] != 0) + (datestring[0] != 0));
869 //fps_y = vid_conheight.integer - sb_lines; // yes this may draw over the sbar
870 //fps_y = bound(0, fps_y, vid_conheight.integer - fps_height);
871 fps_y = vid_conheight.integer - fps_height;
874 fps_x = vid_conwidth.integer - fps_scalex * strlen(fpsstring);
875 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(fpsstring), fps_scaley, 0, 0, 0, 0.5, 0);
876 DrawQ_String(fps_x, fps_y, fpsstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
881 fps_x = vid_conwidth.integer - fps_scalex * strlen(timestring);
882 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(timestring), fps_scaley, 0, 0, 0, 0.5, 0);
883 DrawQ_String(fps_x, fps_y, timestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
888 fps_x = vid_conwidth.integer - fps_scalex * strlen(datestring);
889 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(datestring), fps_scaley, 0, 0, 0, 0.5, 0);
890 DrawQ_String(fps_x, fps_y, datestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
901 void Sbar_Draw (void)
903 if (cl.intermission == 1)
905 Sbar_IntermissionOverlay();
908 else if (cl.intermission == 2)
910 Sbar_FinaleOverlay();
914 if (gamemode == GAME_SOM)
916 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
917 Sbar_DrawScoreboard ();
920 // this is the top left of the sbar area
922 sbar_y = vid_conheight.integer - 24*3;
925 if (cl.stats[STAT_ARMOR])
927 if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
928 Sbar_DrawPic(0, 0, somsb_armor[2]);
929 else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
930 Sbar_DrawPic(0, 0, somsb_armor[1]);
931 else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
932 Sbar_DrawPic(0, 0, somsb_armor[0]);
933 Sbar_DrawNum(24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
937 Sbar_DrawPic(0, 24, somsb_health);
938 Sbar_DrawNum(24, 24, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
941 if (cl.stats[STAT_ITEMS] & IT_SHELLS)
942 Sbar_DrawPic(0, 48, somsb_ammo[0]);
943 else if (cl.stats[STAT_ITEMS] & IT_NAILS)
944 Sbar_DrawPic(0, 48, somsb_ammo[1]);
945 else if (cl.stats[STAT_ITEMS] & IT_ROCKETS)
946 Sbar_DrawPic(0, 48, somsb_ammo[2]);
947 else if (cl.stats[STAT_ITEMS] & IT_CELLS)
948 Sbar_DrawPic(0, 48, somsb_ammo[3]);
949 Sbar_DrawNum(24, 48, cl.stats[STAT_AMMO], 3, false);
950 if (cl.stats[STAT_SHELLS])
951 Sbar_DrawNum(24 + 3*24, 48, cl.stats[STAT_SHELLS], 1, true);
954 else if (gamemode == GAME_NEXUIZ)
956 sbar_y = vid_conheight.integer - 47;
957 sbar_x = (vid_conwidth.integer - 640)/2;
959 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
961 Sbar_DrawAlphaPic (0, 0, sb_scorebar, sbar_alpha_bg.value);
962 Sbar_DrawScoreboard ();
970 // we have a max time 2s (min time = 0)
971 if ((time = cl.time - cl.weapontime) < 2)
973 fade = (1.0 - 0.5 * time);
975 for (i = 0; i < 8;i++)
976 if (cl.stats[STAT_ITEMS] & (1 << i))
977 Sbar_DrawWeapon(i + 1, fade, (i + 2 == cl.stats[STAT_ACTIVEWEAPON]));
979 if((cl.stats[STAT_ITEMS] & (1<<12)))
980 Sbar_DrawWeapon(0, fade, (cl.stats[STAT_ACTIVEWEAPON] == 1));
983 //if (!cl.islocalgame)
984 // Sbar_DrawFrags ();
987 Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha_fg.value);
989 Sbar_DrawAlphaPic (0, 0, sb_sbar_minimal, sbar_alpha_fg.value);
992 if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
994 // Nexuiz has no anum pics
995 //Sbar_DrawNum (36, 0, 666, 3, 1);
996 // Nexuiz has no disc pic
997 //Sbar_DrawPic (0, 0, sb_disc);
1001 Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
1004 if(cl.stats[STAT_HEALTH] > 100)
1005 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
1006 else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
1007 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
1009 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
1011 // AK dont draw ammo for the laser
1012 if(cl.stats[STAT_ACTIVEWEAPON] != 12)
1014 if (cl.stats[STAT_ITEMS] & NEX_IT_SHELLS)
1015 Sbar_DrawPic (519, 0, sb_ammo[0]);
1016 else if (cl.stats[STAT_ITEMS] & NEX_IT_BULLETS)
1017 Sbar_DrawPic (519, 0, sb_ammo[1]);
1018 else if (cl.stats[STAT_ITEMS] & NEX_IT_ROCKETS)
1019 Sbar_DrawPic (519, 0, sb_ammo[2]);
1020 else if (cl.stats[STAT_ITEMS] & NEX_IT_CELLS)
1021 Sbar_DrawPic (519, 0, sb_ammo[3]);
1023 if(cl.stats[STAT_AMMO] <= 10)
1024 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
1026 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
1031 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
1034 //if (vid_conwidth.integer > 320 && cl.gametype == GAME_DEATHMATCH)
1035 // Sbar_MiniDeathmatchOverlay (0, 17);
1037 else // Quake and others
1039 sbar_y = vid_conheight.integer - SBAR_HEIGHT;
1040 if (cl.gametype == GAME_DEATHMATCH && gamemode != GAME_TRANSFUSION)
1043 sbar_x = (vid_conwidth.integer - 320)/2;
1047 if (gamemode != GAME_GOODVSBAD2)
1048 Sbar_DrawInventory ();
1049 if (!cl.islocalgame && gamemode != GAME_TRANSFUSION)
1053 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
1055 if (gamemode != GAME_GOODVSBAD2)
1056 Sbar_DrawAlphaPic (0, 0, sb_scorebar, sbar_alpha_bg.value);
1057 Sbar_DrawScoreboard ();
1061 Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha_bg.value);
1063 // keys (hipnotic only)
1064 //MED 01/04/97 moved keys here so they would not be overwritten
1065 if (gamemode == GAME_HIPNOTIC)
1067 if (cl.stats[STAT_ITEMS] & IT_KEY1)
1068 Sbar_DrawPic (209, 3, sb_items[0]);
1069 if (cl.stats[STAT_ITEMS] & IT_KEY2)
1070 Sbar_DrawPic (209, 12, sb_items[1]);
1073 if (gamemode != GAME_GOODVSBAD2)
1075 if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
1077 Sbar_DrawNum (24, 0, 666, 3, 1);
1078 Sbar_DrawPic (0, 0, sb_disc);
1082 if (gamemode == GAME_ROGUE)
1084 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1085 if (cl.stats[STAT_ITEMS] & RIT_ARMOR3)
1086 Sbar_DrawPic (0, 0, sb_armor[2]);
1087 else if (cl.stats[STAT_ITEMS] & RIT_ARMOR2)
1088 Sbar_DrawPic (0, 0, sb_armor[1]);
1089 else if (cl.stats[STAT_ITEMS] & RIT_ARMOR1)
1090 Sbar_DrawPic (0, 0, sb_armor[0]);
1094 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1095 if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
1096 Sbar_DrawPic (0, 0, sb_armor[2]);
1097 else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
1098 Sbar_DrawPic (0, 0, sb_armor[1]);
1099 else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
1100 Sbar_DrawPic (0, 0, sb_armor[0]);
1109 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1112 if (gamemode == GAME_ROGUE)
1114 if (cl.stats[STAT_ITEMS] & RIT_SHELLS)
1115 Sbar_DrawPic (224, 0, sb_ammo[0]);
1116 else if (cl.stats[STAT_ITEMS] & RIT_NAILS)
1117 Sbar_DrawPic (224, 0, sb_ammo[1]);
1118 else if (cl.stats[STAT_ITEMS] & RIT_ROCKETS)
1119 Sbar_DrawPic (224, 0, sb_ammo[2]);
1120 else if (cl.stats[STAT_ITEMS] & RIT_CELLS)
1121 Sbar_DrawPic (224, 0, sb_ammo[3]);
1122 else if (cl.stats[STAT_ITEMS] & RIT_LAVA_NAILS)
1123 Sbar_DrawPic (224, 0, rsb_ammo[0]);
1124 else if (cl.stats[STAT_ITEMS] & RIT_PLASMA_AMMO)
1125 Sbar_DrawPic (224, 0, rsb_ammo[1]);
1126 else if (cl.stats[STAT_ITEMS] & RIT_MULTI_ROCKETS)
1127 Sbar_DrawPic (224, 0, rsb_ammo[2]);
1131 if (cl.stats[STAT_ITEMS] & IT_SHELLS)
1132 Sbar_DrawPic (224, 0, sb_ammo[0]);
1133 else if (cl.stats[STAT_ITEMS] & IT_NAILS)
1134 Sbar_DrawPic (224, 0, sb_ammo[1]);
1135 else if (cl.stats[STAT_ITEMS] & IT_ROCKETS)
1136 Sbar_DrawPic (224, 0, sb_ammo[2]);
1137 else if (cl.stats[STAT_ITEMS] & IT_CELLS)
1138 Sbar_DrawPic (224, 0, sb_ammo[3]);
1141 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1145 if (vid_conwidth.integer > 320 && cl.gametype == GAME_DEATHMATCH)
1147 if (gamemode == GAME_TRANSFUSION)
1148 Sbar_MiniDeathmatchOverlay (0, 0);
1150 Sbar_MiniDeathmatchOverlay (324, vid_conheight.integer - sb_lines);
1156 R_Draw2DCrosshair();
1158 if (cl_prydoncursor.integer)
1159 DrawQ_Pic((cl.cmd.cursor_screen[0] + 1) * 0.5 * vid_conwidth.integer, (cl.cmd.cursor_screen[1] + 1) * 0.5 * vid_conheight.integer, va("gfx/prydoncursor%03i", cl_prydoncursor.integer), 0, 0, 1, 1, 1, 1, 0);
1162 //=============================================================================
1166 Sbar_DeathmatchOverlay
1170 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1173 // draw colors behind score
1174 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1175 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) * sbar_alpha_fg.value, 0);
1176 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1177 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) * sbar_alpha_fg.value, 0);
1179 //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 * sbar_alpha_fg.value, 0);
1180 // FIXME: use a constant for this color tag instead
1181 DrawQ_ColoredString(x, y, va("%c%4i %s" STRING_COLOR_DEFAULT_STR, (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL );
1185 void Sbar_DeathmatchOverlay (void)
1190 pic = Draw_CachePic ("gfx/ranking", true);
1191 DrawQ_Pic ((vid_conwidth.integer - pic->width)/2, 8, "gfx/ranking", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1196 x = (vid_conwidth.integer - (6 + 15) * 8) / 2;
1198 for (i = 0;i < scoreboardlines && y < vid_conheight.integer;i++)
1199 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1204 Sbar_DeathmatchOverlay
1208 void Sbar_MiniDeathmatchOverlay (int x, int y)
1212 // decide where to print
1213 if (gamemode == GAME_TRANSFUSION)
1214 numlines = (vid_conwidth.integer - x + 127) / 128;
1216 numlines = (vid_conheight.integer - y + 7) / 8;
1218 // give up if there isn't room
1219 if (x >= vid_conwidth.integer || y >= vid_conheight.integer || numlines < 1)
1226 for (i = 0; i < scoreboardlines; i++)
1227 if (fragsort[i] == cl.playerentity - 1)
1232 i = min(i, scoreboardlines - numlines);
1235 if (gamemode == GAME_TRANSFUSION)
1237 for (;i < scoreboardlines && x < vid_conwidth.integer;i++)
1238 x += 128 + Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1242 for (;i < scoreboardlines && y < vid_conheight.integer;i++)
1243 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1249 Sbar_IntermissionOverlay
1253 void Sbar_IntermissionOverlay (void)
1258 if (cl.gametype == GAME_DEATHMATCH)
1260 Sbar_DeathmatchOverlay ();
1264 sbar_x = (vid_conwidth.integer - 320) >> 1;
1265 sbar_y = (vid_conheight.integer - 200) >> 1;
1267 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1268 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1271 dig = cl.completed_time/60;
1272 Sbar_DrawNum (160, 64, dig, 3, 0);
1273 num = cl.completed_time - dig*60;
1274 if (gamemode != GAME_NEXUIZ)
1275 Sbar_DrawPic (234,64,sb_colon);
1276 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1277 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1279 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1280 if (gamemode != GAME_NEXUIZ)
1281 Sbar_DrawPic (232, 104, sb_slash);
1282 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1284 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1285 if (gamemode != GAME_NEXUIZ)
1286 Sbar_DrawPic (232, 144, sb_slash);
1287 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1298 void Sbar_FinaleOverlay (void)
1302 pic = Draw_CachePic ("gfx/finale", true);
1303 DrawQ_Pic((vid_conwidth.integer - pic->width)/2, 16, "gfx/finale", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);