removed unused variable font_size
[divverent/darkplaces.git] / sbar.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
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.
8
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.
12
13 See the GNU General Public License for more details.
14
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.
18
19 */
20 // sbar.c -- status bar code
21
22 #include "quakedef.h"
23
24 typedef struct
25 {
26         char name[32];
27 }
28 sbarpic_t;
29
30 static sbarpic_t sbarpics[256];
31 static int numsbarpics;
32
33 static sbarpic_t *Sbar_NewPic(const char *name)
34 {
35         strcpy(sbarpics[numsbarpics].name, name);
36         // precache it
37         // FIXME: precache on every renderer restart (or move this to client)
38         Draw_CachePic(sbarpics[numsbarpics].name);
39         return sbarpics + (numsbarpics++);
40 }
41
42 sbarpic_t *sb_disc;
43
44 #define STAT_MINUS 10 // num frame for '-' stats digit
45 sbarpic_t *sb_nums[2][11];
46 sbarpic_t *sb_colon, *sb_slash;
47 sbarpic_t *sb_ibar;
48 sbarpic_t *sb_sbar;
49 sbarpic_t *sb_scorebar;
50 // AK only used by NEX
51 sbarpic_t *sb_sbar_minimal;
52 sbarpic_t *sb_sbar_overlay;
53
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];
60
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];
64
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;
69
70 qboolean sb_showscores;
71
72 int sb_lines;                   // scan lines to draw
73
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
79
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];
86
87 //GAME_SOM stuff:
88 sbarpic_t *somsb_health;
89 sbarpic_t *somsb_ammo[4];
90 sbarpic_t *somsb_armor[3];
91
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"};
99
100 void Sbar_MiniDeathmatchOverlay (int x, int y);
101 void Sbar_DeathmatchOverlay (void);
102 void Sbar_IntermissionOverlay (void);
103 void Sbar_FinaleOverlay (void);
104
105
106 /*
107 ===============
108 Sbar_ShowScores
109
110 Tab key down
111 ===============
112 */
113 void Sbar_ShowScores (void)
114 {
115         if (sb_showscores)
116                 return;
117         sb_showscores = true;
118 }
119
120 /*
121 ===============
122 Sbar_DontShowScores
123
124 Tab key up
125 ===============
126 */
127 void Sbar_DontShowScores (void)
128 {
129         sb_showscores = false;
130 }
131
132 void sbar_start(void)
133 {
134         int i;
135
136         numsbarpics = 0;
137
138         sb_disc = Sbar_NewPic("gfx/disc");
139
140         for (i = 0;i < 10;i++)
141         {
142                 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
143                 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
144         }
145
146         sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
147         sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
148
149         sb_colon = Sbar_NewPic ("gfx/num_colon");
150         sb_slash = Sbar_NewPic ("gfx/num_slash");
151
152         if (gamemode == GAME_SOM)
153         {
154                 somsb_health = Sbar_NewPic("gfx/hud_health");
155                 somsb_ammo[0] = Sbar_NewPic("gfx/sb_shells");
156                 somsb_ammo[1] = Sbar_NewPic("gfx/sb_nails");
157                 somsb_ammo[2] = Sbar_NewPic("gfx/sb_rocket");
158                 somsb_ammo[3] = Sbar_NewPic("gfx/sb_cells");
159                 somsb_armor[0] = Sbar_NewPic("gfx/sb_armor1");
160                 somsb_armor[1] = Sbar_NewPic("gfx/sb_armor2");
161                 somsb_armor[2] = Sbar_NewPic("gfx/sb_armor3");
162         }
163         else if (gamemode == GAME_NEXUIZ)
164         {
165                 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
166                 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
167                 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
168                 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
169
170                 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
171                 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
172                 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
173                 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
174
175                 sb_sbar = Sbar_NewPic("gfx/sbar");
176                 sb_sbar_minimal = Sbar_NewPic("gfx/sbar_minimal");
177                 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
178
179                 for(i = 0; i < 9;i++)
180                         sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
181         }
182         else
183         {
184                 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
185                 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
186                 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
187                 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
188                 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
189                 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
190                 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
191
192                 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
193                 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
194                 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
195                 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
196                 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
197                 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
198                 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
199
200                 for (i = 0;i < 5;i++)
201                 {
202                         sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
203                         sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
204                         sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
205                         sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
206                         sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
207                         sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
208                         sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
209                 }
210
211                 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
212                 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
213                 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
214                 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
215
216                 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
217                 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
218                 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
219
220                 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
221                 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
222                 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
223                 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
224                 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
225                 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
226
227                 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
228                 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
229                 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
230                 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
231
232                 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
233                 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
234                 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
235                 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
236                 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
237                 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
238                 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
239                 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
240                 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
241                 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
242
243                 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
244                 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
245                 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
246                 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
247
248                 sb_sbar = Sbar_NewPic ("gfx/sbar");
249                 sb_ibar = Sbar_NewPic ("gfx/ibar");
250                 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
251
252         //MED 01/04/97 added new hipnotic weapons
253                 if (gamemode == GAME_HIPNOTIC)
254                 {
255                         hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
256                         hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
257                         hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
258                         hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
259                         hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
260
261                         hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
262                         hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
263                         hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
264                         hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
265                         hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
266
267                         for (i = 0;i < 5;i++)
268                         {
269                                 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
270                                 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
271                                 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
272                                 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
273                                 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
274                         }
275
276                         hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
277                         hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
278                 }
279                 else if (gamemode == GAME_ROGUE)
280                 {
281                         rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
282                         rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
283
284                         rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
285                         rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
286                         rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
287                         rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
288                         rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
289
290                         rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
291                         rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
292
293         // PGM 01/19/97 - team color border
294                         rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
295         // PGM 01/19/97 - team color border
296
297                         rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
298                         rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
299                         rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
300                 }
301         }
302 }
303
304 void sbar_shutdown(void)
305 {
306 }
307
308 void sbar_newmap(void)
309 {
310 }
311
312 void Sbar_Init (void)
313 {
314         Cmd_AddCommand ("+showscores", Sbar_ShowScores);
315         Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
316         Cvar_RegisterVariable (&showfps);
317         Cvar_RegisterVariable (&showtime);
318         Cvar_RegisterVariable (&showtime_format);
319         Cvar_RegisterVariable (&showdate);
320         Cvar_RegisterVariable (&showdate_format);
321         Cvar_RegisterVariable (&sbar_alpha_bg);
322         Cvar_RegisterVariable (&sbar_alpha_fg);
323
324         R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
325 }
326
327
328 //=============================================================================
329
330 // drawing routines are relative to the status bar location
331
332 int sbar_x, sbar_y;
333
334 /*
335 =============
336 Sbar_DrawPic
337 =============
338 */
339 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
340 {
341         DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha_fg.value, 0);
342 }
343
344 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
345 {
346         DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha, 0);
347 }
348
349 /*
350 ================
351 Sbar_DrawCharacter
352
353 Draws one solid graphics character
354 ================
355 */
356 void Sbar_DrawCharacter (int x, int y, int num)
357 {
358         DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha_fg.value, 0);
359 }
360
361 /*
362 ================
363 Sbar_DrawString
364 ================
365 */
366 void Sbar_DrawString (int x, int y, char *str)
367 {
368         DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha_fg.value, 0);
369 }
370
371 /*
372 =============
373 Sbar_DrawNum
374 =============
375 */
376 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
377 {
378         char str[32], *ptr;
379         int l, frame;
380
381         l = sprintf(str, "%i", num);
382         ptr = str;
383         if (l > digits)
384                 ptr += (l-digits);
385         if (l < digits)
386                 x += (digits-l)*24;
387
388         while (*ptr)
389         {
390                 if (*ptr == '-')
391                         frame = STAT_MINUS;
392                 else
393                         frame = *ptr -'0';
394
395                 Sbar_DrawPic (x, y, sb_nums[color][frame]);
396                 x += 24;
397
398                 ptr++;
399         }
400 }
401
402 /*
403 =============
404 Sbar_DrawXNum
405 =============
406 */
407
408 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
409 {
410         char str[32], *ptr;
411         int l, frame;
412
413         l = sprintf(str, "%i", num);
414         ptr = str;
415         if (l > digits)
416                 ptr += (l-digits);
417         if (l < digits)
418                 x += (digits-l) * lettersize;
419
420         while (*ptr)
421         {
422                 if (*ptr == '-')
423                         frame = STAT_MINUS;
424                 else
425                         frame = *ptr -'0';
426
427                 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha_fg.value,flags);
428                 x += lettersize;
429
430                 ptr++;
431         }
432 }
433
434 //=============================================================================
435
436
437 /*
438 ===============
439 Sbar_SortFrags
440 ===============
441 */
442 static int fragsort[MAX_SCOREBOARD];
443 static int scoreboardlines;
444 void Sbar_SortFrags (void)
445 {
446         int             i, j, k;
447
448 // sort by frags
449         scoreboardlines = 0;
450         for (i=0 ; i<cl.maxclients ; i++)
451         {
452                 if (cl.scores[i].name[0])
453                 {
454                         fragsort[scoreboardlines] = i;
455                         scoreboardlines++;
456                 }
457         }
458
459         for (i=0 ; i<scoreboardlines ; i++)
460                 for (j=0 ; j<scoreboardlines-1-i ; j++)
461                         if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
462                         {
463                                 k = fragsort[j];
464                                 fragsort[j] = fragsort[j+1];
465                                 fragsort[j+1] = k;
466                         }
467 }
468
469 /*
470 ===============
471 Sbar_SoloScoreboard
472 ===============
473 */
474 void Sbar_SoloScoreboard (void)
475 {
476         char    str[80];
477         int             minutes, seconds, tens, units;
478         int             l;
479
480         if (gamemode != GAME_NEXUIZ) {
481                 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
482                 Sbar_DrawString (8, 4, str);
483
484                 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
485                 Sbar_DrawString (8, 12, str);
486         }
487
488 // time
489         minutes = cl.time / 60;
490         seconds = cl.time - 60*minutes;
491         tens = seconds / 10;
492         units = seconds - 10*tens;
493         sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
494         Sbar_DrawString (184, 4, str);
495
496 // draw level name
497         if (gamemode == GAME_NEXUIZ) {
498                 l = strlen (cl.worldmodel->name);
499                 Sbar_DrawString (232 - l*4, 12, cl.worldmodel->name);
500         } else {
501                 l = strlen (cl.levelname);
502                 Sbar_DrawString (232 - l*4, 12, cl.levelname);
503         }
504 }
505
506 /*
507 ===============
508 Sbar_DrawScoreboard
509 ===============
510 */
511 void Sbar_DrawScoreboard (void)
512 {
513         Sbar_SoloScoreboard ();
514         if (cl.gametype == GAME_DEATHMATCH)
515                 Sbar_DeathmatchOverlay ();
516 }
517
518 //=============================================================================
519
520 // AK to make DrawInventory smaller
521 static void Sbar_DrawWeapon(int nr, float fade, int active)
522 {
523         // width = 300, height = 100
524         const int w_width = 300, w_height = 100, w_space = 10;
525         const float w_scale = 0.4;
526
527         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 * sbar_alpha_fg.value, DRAWFLAG_ADDITIVE);
528         //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);
529
530         if (active)
531                 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 * sbar_alpha_fg.value, DRAWFLAG_ADDITIVE);
532 }
533
534 /*
535 ===============
536 Sbar_DrawInventory
537 ===============
538 */
539 void Sbar_DrawInventory (void)
540 {
541         int i;
542         char num[6];
543         float time;
544         int flashon;
545
546         if (gamemode == GAME_ROGUE)
547         {
548                 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
549                         Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], sbar_alpha_bg.value);
550                 else
551                         Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], sbar_alpha_bg.value);
552         }
553         else
554                 Sbar_DrawAlphaPic (0, -24, sb_ibar, sbar_alpha_bg.value);
555
556         // weapons
557         for (i=0 ; i<7 ; i++)
558         {
559                 if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN<<i) )
560                 {
561                         time = cl.item_gettime[i];
562                         flashon = (int)((cl.time - time)*10);
563                         if (flashon >= 10)
564                         {
565                                 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i)  )
566                                         flashon = 1;
567                                 else
568                                         flashon = 0;
569                         }
570                         else
571                                 flashon = (flashon%5) + 2;
572
573                         Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], sbar_alpha_bg.value);
574                 }
575         }
576
577         // MED 01/04/97
578         // hipnotic weapons
579         if (gamemode == GAME_HIPNOTIC)
580         {
581                 int grenadeflashing=0;
582                 for (i=0 ; i<4 ; i++)
583                 {
584                         if (cl.stats[STAT_ITEMS] & (1<<hipweapons[i]) )
585                         {
586                                 time = cl.item_gettime[hipweapons[i]];
587                                 flashon = (int)((cl.time - time)*10);
588                                 if (flashon >= 10)
589                                 {
590                                         if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i])  )
591                                                 flashon = 1;
592                                         else
593                                                 flashon = 0;
594                                 }
595                                 else
596                                         flashon = (flashon%5) + 2;
597
598                                 // check grenade launcher
599                                 if (i==2)
600                                 {
601                                         if (cl.stats[STAT_ITEMS] & HIT_PROXIMITY_GUN)
602                                         {
603                                                 if (flashon)
604                                                 {
605                                                         grenadeflashing = 1;
606                                                         Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
607                                                 }
608                                         }
609                                 }
610                                 else if (i==3)
611                                 {
612                                         if (cl.stats[STAT_ITEMS] & (IT_SHOTGUN<<4))
613                                         {
614                                                 if (!grenadeflashing)
615                                                         Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
616                                         }
617                                         else
618                                                 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
619                                 }
620                                 else
621                                         Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
622                         }
623                 }
624         }
625
626         if (gamemode == GAME_ROGUE)
627         {
628                 // check for powered up weapon.
629                 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
630                         for (i=0;i<5;i++)
631                                 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
632                                         Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
633         }
634
635         // ammo counts
636         for (i=0 ; i<4 ; i++)
637         {
638                 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
639                 if (num[0] != ' ')
640                         Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
641                 if (num[1] != ' ')
642                         Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
643                 if (num[2] != ' ')
644                         Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
645         }
646
647         // items
648         for (i=0 ; i<6 ; i++)
649                 if (cl.stats[STAT_ITEMS] & (1<<(17+i)))
650                 {
651                         //MED 01/04/97 changed keys
652                         if (gamemode != GAME_HIPNOTIC || (i>1))
653                                 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
654                 }
655
656         //MED 01/04/97 added hipnotic items
657         // hipnotic items
658         if (gamemode == GAME_HIPNOTIC)
659         {
660                 for (i=0 ; i<2 ; i++)
661                         if (cl.stats[STAT_ITEMS] & (1<<(24+i)))
662                                 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
663         }
664
665         if (gamemode == GAME_ROGUE)
666         {
667                 // new rogue items
668                 for (i=0 ; i<2 ; i++)
669                         if (cl.stats[STAT_ITEMS] & (1<<(29+i)))
670                                 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
671         }
672         else
673         {
674                 // sigils
675                 for (i=0 ; i<4 ; i++)
676                         if (cl.stats[STAT_ITEMS] & (1<<(28+i)))
677                                 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
678         }
679 }
680
681 //=============================================================================
682
683 /*
684 ===============
685 Sbar_DrawFrags
686 ===============
687 */
688 void Sbar_DrawFrags (void)
689 {
690         int i, k, l, x, f;
691         char num[12];
692         scoreboard_t *s;
693         qbyte *c;
694
695         Sbar_SortFrags ();
696
697         // draw the text
698         l = min(scoreboardlines, 4);
699
700         x = 23 * 8;
701
702         for (i = 0;i < l;i++)
703         {
704                 k = fragsort[i];
705                 s = &cl.scores[k];
706
707                 // draw background
708                 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
709                 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);
710                 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
711                 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);
712
713                 // draw number
714                 f = s->frags;
715                 sprintf (num, "%3i",f);
716
717                 Sbar_DrawCharacter (x +  8, -24, num[0]);
718                 Sbar_DrawCharacter (x + 16, -24, num[1]);
719                 Sbar_DrawCharacter (x + 24, -24, num[2]);
720
721                 if (k == cl.viewentity - 1)
722                 {
723                         Sbar_DrawCharacter ( x      + 2, -24, 16);
724                         Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
725                 }
726                 x += 32;
727         }
728 }
729
730 //=============================================================================
731
732
733 /*
734 ===============
735 Sbar_DrawFace
736 ===============
737 */
738 void Sbar_DrawFace (void)
739 {
740         int f;
741
742 // PGM 01/19/97 - team color drawing
743 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
744         if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
745         {
746                 char num[12];
747                 scoreboard_t *s;
748                 qbyte *c;
749
750                 s = &cl.scores[cl.viewentity - 1];
751                 // draw background
752                 Sbar_DrawPic (112, 0, rsb_teambord);
753                 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
754                 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) * sbar_alpha_fg.value, 0);
755                 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
756                 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) * sbar_alpha_fg.value, 0);
757
758                 // draw number
759                 f = s->frags;
760                 sprintf (num, "%3i",f);
761
762                 if ((s->colors & 0xf0)==0)
763                 {
764                         if (num[0] != ' ')
765                                 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
766                         if (num[1] != ' ')
767                                 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
768                         if (num[2] != ' ')
769                                 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
770                 }
771                 else
772                 {
773                         Sbar_DrawCharacter ( 109, 3, num[0]);
774                         Sbar_DrawCharacter ( 116, 3, num[1]);
775                         Sbar_DrawCharacter ( 123, 3, num[2]);
776                 }
777
778                 return;
779         }
780 // PGM 01/19/97 - team color drawing
781
782         if ( (cl.stats[STAT_ITEMS] & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
783                 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
784         else if (cl.stats[STAT_ITEMS] & IT_QUAD)
785                 Sbar_DrawPic (112, 0, sb_face_quad );
786         else if (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
787                 Sbar_DrawPic (112, 0, sb_face_invis );
788         else if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
789                 Sbar_DrawPic (112, 0, sb_face_invuln);
790         else
791         {
792                 f = cl.stats[STAT_HEALTH] / 20;
793                 f = bound(0, f, 4);
794                 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
795         }
796 }
797
798 void Sbar_ShowFPS(void)
799 {
800         float fps_x, fps_y, fps_scalex, fps_scaley, fps_height;
801         char fpsstring[32];
802         char timestring[32];
803         char datestring[32];
804         fpsstring[0] = 0;
805         timestring[0] = 0;
806         datestring[0] = 0;
807         if (showfps.integer)
808         {
809                 int calc;
810                 if (showfps.integer > 1)
811                 {
812                         static double currtime, frametimes[32];
813                         double newtime, total;
814                         int count, i;
815                         static int framecycle = 0;
816
817                         newtime = Sys_DoubleTime();
818                         frametimes[framecycle] = newtime - currtime;
819                         total = 0;
820                         count = 0;
821                         while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
822                         {
823                                 total += frametimes[i];
824                                 count++;
825                         }
826                         framecycle++;
827                         framecycle &= 31;
828                         if (showfps.integer == 2)
829                                 calc = (int) (((double) count / total) + 0.5);
830                         else // showfps 3, rapid update
831                                 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
832                         currtime = newtime;
833                 }
834                 else
835                 {
836                         static double nexttime = 0, lasttime = 0;
837                         static int framerate = 0, framecount = 0;
838                         double newtime;
839                         newtime = Sys_DoubleTime();
840                         if (newtime >= nexttime)
841                         {
842                                 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
843                                 lasttime = newtime;
844                                 nexttime = max(nexttime + 1, lasttime - 1);
845                                 framecount = 0;
846                         }
847                         framecount++;
848                         calc = framerate;
849                 }
850                 dpsnprintf(fpsstring, sizeof(fpsstring), "%4i fps", calc);
851         }
852         if (showtime.integer)
853                 strlcpy(timestring, Sys_TimeString(showtime_format.string), sizeof(timestring));
854         if (showdate.integer)
855                 strlcpy(datestring, Sys_TimeString(showdate_format.string), sizeof(datestring));
856         if (fpsstring[0] || timestring[0])
857         {
858                 fps_scalex = 12;
859                 fps_scaley = 12;
860                 fps_height = fps_scaley * ((fpsstring[0] != 0) + (timestring[0] != 0) + (datestring[0] != 0));
861                 //fps_y = vid.conheight - sb_lines; // yes this may draw over the sbar
862                 //fps_y = bound(0, fps_y, vid.conheight - fps_height);
863                 fps_y = vid.conheight - fps_height;
864                 if (fpsstring[0])
865                 {
866                         fps_x = vid.conwidth - fps_scalex * strlen(fpsstring);
867                         DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(fpsstring), fps_scaley, 0, 0, 0, 0.5, 0);
868                         DrawQ_String(fps_x, fps_y, fpsstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
869                         fps_y += fps_scaley;
870                 }
871                 if (timestring[0])
872                 {
873                         fps_x = vid.conwidth - fps_scalex * strlen(timestring);
874                         DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(timestring), fps_scaley, 0, 0, 0, 0.5, 0);
875                         DrawQ_String(fps_x, fps_y, timestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
876                         fps_y += fps_scaley;
877                 }
878                 if (datestring[0])
879                 {
880                         fps_x = vid.conwidth - fps_scalex * strlen(datestring);
881                         DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(datestring), fps_scaley, 0, 0, 0, 0.5, 0);
882                         DrawQ_String(fps_x, fps_y, datestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0);
883                         fps_y += fps_scaley;
884                 }
885         }
886 }
887
888 /*
889 ===============
890 Sbar_Draw
891 ===============
892 */
893 void Sbar_Draw (void)
894 {
895         if (cl.intermission == 1)
896         {
897                 Sbar_IntermissionOverlay();
898                 return;
899         }
900         else if (cl.intermission == 2)
901         {
902                 Sbar_FinaleOverlay();
903                 return;
904         }
905
906         if (gamemode == GAME_SOM)
907         {
908                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
909                         Sbar_DrawScoreboard ();
910                 else if (sb_lines)
911                 {
912                         // this is the top left of the sbar area
913                         sbar_x = 0;
914                         sbar_y = vid.conheight - 24*3;
915
916                         // armor
917                         if (cl.stats[STAT_ARMOR])
918                         {
919                                 if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
920                                         Sbar_DrawPic(0, 0, somsb_armor[2]);
921                                 else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
922                                         Sbar_DrawPic(0, 0, somsb_armor[1]);
923                                 else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
924                                         Sbar_DrawPic(0, 0, somsb_armor[0]);
925                                 Sbar_DrawNum(24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
926                         }
927
928                         // health
929                         Sbar_DrawPic(0, 24, somsb_health);
930                         Sbar_DrawNum(24, 24, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
931
932                         // ammo icon
933                         if (cl.stats[STAT_ITEMS] & IT_SHELLS)
934                                 Sbar_DrawPic(0, 48, somsb_ammo[0]);
935                         else if (cl.stats[STAT_ITEMS] & IT_NAILS)
936                                 Sbar_DrawPic(0, 48, somsb_ammo[1]);
937                         else if (cl.stats[STAT_ITEMS] & IT_ROCKETS)
938                                 Sbar_DrawPic(0, 48, somsb_ammo[2]);
939                         else if (cl.stats[STAT_ITEMS] & IT_CELLS)
940                                 Sbar_DrawPic(0, 48, somsb_ammo[3]);
941                         Sbar_DrawNum(24, 48, cl.stats[STAT_AMMO], 3, false);
942                         if (cl.stats[STAT_SHELLS])
943                                 Sbar_DrawNum(24 + 3*24, 48, cl.stats[STAT_SHELLS], 1, true);
944                 }
945         }
946         else if (gamemode == GAME_NEXUIZ)
947         {
948                 sbar_y = vid.conheight - 47;
949                 sbar_x = (vid.conwidth - 640)/2;
950
951                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
952                 {
953                         Sbar_DrawAlphaPic (0, 0, sb_scorebar, sbar_alpha_bg.value);
954                         Sbar_DrawScoreboard ();
955                 }
956                 else if (sb_lines)
957                 {
958                         int i;
959                         double time;
960                         float fade;
961
962                         // we have a max time 2s (min time = 0)
963                         if ((time = cl.time - cl.weapontime) < 2)
964                         {
965                                 fade = (1.0 - 0.5 * time);
966                                 fade *= fade;
967                                 for (i = 0; i < 8;i++)
968                                         if (cl.stats[STAT_ITEMS] & (1 << i))
969                                                 Sbar_DrawWeapon(i + 1, fade, (i + 2 == cl.stats[STAT_ACTIVEWEAPON]));
970
971                                 if((cl.stats[STAT_ITEMS] & (1<<12)))
972                                         Sbar_DrawWeapon(0, fade, (cl.stats[STAT_ACTIVEWEAPON] == 1));
973                         }
974
975                         //if (!cl.islocalgame)
976                         //      Sbar_DrawFrags ();
977
978                         if (sb_lines > 24)
979                                 Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha_fg.value);
980                         else
981                                 Sbar_DrawAlphaPic (0, 0, sb_sbar_minimal, sbar_alpha_fg.value);
982
983                         // special items
984                         if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
985                         {
986                                 Sbar_DrawNum (36, 0, 666, 3, 1);
987                                 Sbar_DrawPic (0, 0, sb_disc);
988                         }
989
990                         // armor
991                         Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
992
993                         // health
994                         if(cl.stats[STAT_HEALTH] > 100)
995                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
996                         else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
997                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
998                         else
999                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
1000
1001                         // AK dont draw ammo for the laser
1002                         if(cl.stats[STAT_ACTIVEWEAPON] != 12)
1003                         {
1004                                 if (cl.stats[STAT_ITEMS] & NEX_IT_SHELLS)
1005                                         Sbar_DrawPic (519, 0, sb_ammo[0]);
1006                                 else if (cl.stats[STAT_ITEMS] & NEX_IT_BULLETS)
1007                                         Sbar_DrawPic (519, 0, sb_ammo[1]);
1008                                 else if (cl.stats[STAT_ITEMS] & NEX_IT_ROCKETS)
1009                                         Sbar_DrawPic (519, 0, sb_ammo[2]);
1010                                 else if (cl.stats[STAT_ITEMS] & NEX_IT_CELLS)
1011                                         Sbar_DrawPic (519, 0, sb_ammo[3]);
1012
1013                                 if(cl.stats[STAT_AMMO] <= 10)
1014                                         Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
1015                                 else
1016                                         Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
1017
1018                         }
1019
1020                         if (sb_lines > 24)
1021                                 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
1022                 }
1023
1024                 //if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1025                 //      Sbar_MiniDeathmatchOverlay (0, 17);
1026         }
1027         else // Quake and others
1028         {
1029                 sbar_y = vid.conheight - SBAR_HEIGHT;
1030                 if (cl.gametype == GAME_DEATHMATCH && gamemode != GAME_TRANSFUSION)
1031                         sbar_x = 0;
1032                 else
1033                         sbar_x = (vid.conwidth - 320)/2;
1034
1035                 if (sb_lines > 24)
1036                 {
1037                         if (gamemode != GAME_GOODVSBAD2)
1038                                 Sbar_DrawInventory ();
1039                         if (!cl.islocalgame && gamemode != GAME_TRANSFUSION)
1040                                 Sbar_DrawFrags ();
1041                 }
1042
1043                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
1044                 {
1045                         if (gamemode != GAME_GOODVSBAD2)
1046                                 Sbar_DrawAlphaPic (0, 0, sb_scorebar, sbar_alpha_bg.value);
1047                         Sbar_DrawScoreboard ();
1048                 }
1049                 else if (sb_lines)
1050                 {
1051                         Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha_bg.value);
1052
1053                         // keys (hipnotic only)
1054                         //MED 01/04/97 moved keys here so they would not be overwritten
1055                         if (gamemode == GAME_HIPNOTIC)
1056                         {
1057                                 if (cl.stats[STAT_ITEMS] & IT_KEY1)
1058                                         Sbar_DrawPic (209, 3, sb_items[0]);
1059                                 if (cl.stats[STAT_ITEMS] & IT_KEY2)
1060                                         Sbar_DrawPic (209, 12, sb_items[1]);
1061                         }
1062                         // armor
1063                         if (gamemode != GAME_GOODVSBAD2)
1064                         {
1065                                 if (cl.stats[STAT_ITEMS] & IT_INVULNERABILITY)
1066                                 {
1067                                         Sbar_DrawNum (24, 0, 666, 3, 1);
1068                                         Sbar_DrawPic (0, 0, sb_disc);
1069                                 }
1070                                 else
1071                                 {
1072                                         if (gamemode == GAME_ROGUE)
1073                                         {
1074                                                 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1075                                                 if (cl.stats[STAT_ITEMS] & RIT_ARMOR3)
1076                                                         Sbar_DrawPic (0, 0, sb_armor[2]);
1077                                                 else if (cl.stats[STAT_ITEMS] & RIT_ARMOR2)
1078                                                         Sbar_DrawPic (0, 0, sb_armor[1]);
1079                                                 else if (cl.stats[STAT_ITEMS] & RIT_ARMOR1)
1080                                                         Sbar_DrawPic (0, 0, sb_armor[0]);
1081                                         }
1082                                         else
1083                                         {
1084                                                 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1085                                                 if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
1086                                                         Sbar_DrawPic (0, 0, sb_armor[2]);
1087                                                 else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
1088                                                         Sbar_DrawPic (0, 0, sb_armor[1]);
1089                                                 else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
1090                                                         Sbar_DrawPic (0, 0, sb_armor[0]);
1091                                         }
1092                                 }
1093                         }
1094
1095                         // face
1096                         Sbar_DrawFace ();
1097
1098                         // health
1099                         Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1100
1101                         // ammo icon
1102                         if (gamemode == GAME_ROGUE)
1103                         {
1104                                 if (cl.stats[STAT_ITEMS] & RIT_SHELLS)
1105                                         Sbar_DrawPic (224, 0, sb_ammo[0]);
1106                                 else if (cl.stats[STAT_ITEMS] & RIT_NAILS)
1107                                         Sbar_DrawPic (224, 0, sb_ammo[1]);
1108                                 else if (cl.stats[STAT_ITEMS] & RIT_ROCKETS)
1109                                         Sbar_DrawPic (224, 0, sb_ammo[2]);
1110                                 else if (cl.stats[STAT_ITEMS] & RIT_CELLS)
1111                                         Sbar_DrawPic (224, 0, sb_ammo[3]);
1112                                 else if (cl.stats[STAT_ITEMS] & RIT_LAVA_NAILS)
1113                                         Sbar_DrawPic (224, 0, rsb_ammo[0]);
1114                                 else if (cl.stats[STAT_ITEMS] & RIT_PLASMA_AMMO)
1115                                         Sbar_DrawPic (224, 0, rsb_ammo[1]);
1116                                 else if (cl.stats[STAT_ITEMS] & RIT_MULTI_ROCKETS)
1117                                         Sbar_DrawPic (224, 0, rsb_ammo[2]);
1118                         }
1119                         else
1120                         {
1121                                 if (cl.stats[STAT_ITEMS] & IT_SHELLS)
1122                                         Sbar_DrawPic (224, 0, sb_ammo[0]);
1123                                 else if (cl.stats[STAT_ITEMS] & IT_NAILS)
1124                                         Sbar_DrawPic (224, 0, sb_ammo[1]);
1125                                 else if (cl.stats[STAT_ITEMS] & IT_ROCKETS)
1126                                         Sbar_DrawPic (224, 0, sb_ammo[2]);
1127                                 else if (cl.stats[STAT_ITEMS] & IT_CELLS)
1128                                         Sbar_DrawPic (224, 0, sb_ammo[3]);
1129                         }
1130
1131                         Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1132
1133                 }
1134
1135                 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1136                 {
1137                         if (gamemode == GAME_TRANSFUSION)
1138                                 Sbar_MiniDeathmatchOverlay (0, 0);
1139                         else
1140                                 Sbar_MiniDeathmatchOverlay (324, vid.conheight - sb_lines);
1141                 }
1142         }
1143
1144         Sbar_ShowFPS();
1145
1146         R_Draw2DCrosshair();
1147
1148         if (cl_prydoncursor.integer)
1149                 DrawQ_Pic((cl.cmd.cursor_screen[0] + 1) * 0.5 * vid.conwidth, (cl.cmd.cursor_screen[1] + 1) * 0.5 * vid.conheight, va("gfx/prydoncursor%03i.lmp", cl_prydoncursor.integer), 0, 0, 1, 1, 1, 1, 0);
1150 }
1151
1152 //=============================================================================
1153
1154 /*
1155 ==================
1156 Sbar_DeathmatchOverlay
1157
1158 ==================
1159 */
1160 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1161 {
1162         qbyte *c;
1163         // draw colors behind score
1164         c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1165         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);
1166         c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1167         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);
1168         // print the text
1169         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);
1170         return 8;
1171 }
1172
1173 void Sbar_DeathmatchOverlay (void)
1174 {
1175         int i, x, y;
1176         cachepic_t *pic;
1177
1178         pic = Draw_CachePic ("gfx/ranking.lmp");
1179         DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1180
1181         // scores
1182         Sbar_SortFrags ();
1183         // draw the text
1184         x = (vid.conwidth - (6 + 15) * 8) / 2;
1185         y = 40;
1186         for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1187                 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1188 }
1189
1190 /*
1191 ==================
1192 Sbar_DeathmatchOverlay
1193
1194 ==================
1195 */
1196 void Sbar_MiniDeathmatchOverlay (int x, int y)
1197 {
1198         int i, numlines;
1199
1200         // decide where to print
1201         if (gamemode == GAME_TRANSFUSION)
1202                 numlines = (vid.conwidth - x + 127) / 128;
1203         else
1204                 numlines = (vid.conheight - y + 7) / 8;
1205
1206         // give up if there isn't room
1207         if (x >= vid.conwidth || y >= vid.conheight || numlines < 1)
1208                 return;
1209
1210         // scores
1211         Sbar_SortFrags ();
1212
1213         //find us
1214         for (i = 0; i < scoreboardlines; i++)
1215                 if (fragsort[i] == cl.playerentity - 1)
1216                         break;
1217
1218         // figure out start
1219         i -= numlines/2;
1220         i = min(i, scoreboardlines - numlines);
1221         i = max(i, 0);
1222
1223         if (gamemode == GAME_TRANSFUSION)
1224         {
1225                 for (;i < scoreboardlines && x < vid.conwidth;i++)
1226                         x += 128 + Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1227         }
1228         else
1229         {
1230                 for (;i < scoreboardlines && y < vid.conheight;i++)
1231                         y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1232         }
1233 }
1234
1235 /*
1236 ==================
1237 Sbar_IntermissionOverlay
1238
1239 ==================
1240 */
1241 void Sbar_IntermissionOverlay (void)
1242 {
1243         int             dig;
1244         int             num;
1245
1246         if (cl.gametype == GAME_DEATHMATCH)
1247         {
1248                 Sbar_DeathmatchOverlay ();
1249                 return;
1250         }
1251
1252         sbar_x = (vid.conwidth - 320) >> 1;
1253         sbar_y = (vid.conheight - 200) >> 1;
1254
1255         DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1256         DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1257
1258 // time
1259         dig = cl.completed_time/60;
1260         Sbar_DrawNum (160, 64, dig, 3, 0);
1261         num = cl.completed_time - dig*60;
1262         Sbar_DrawPic (234,64,sb_colon);
1263         Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1264         Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1265
1266         Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1267         Sbar_DrawPic (232, 104, sb_slash);
1268         Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1269
1270         Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1271         Sbar_DrawPic (232, 144, sb_slash);
1272         Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1273
1274 }
1275
1276
1277 /*
1278 ==================
1279 Sbar_FinaleOverlay
1280
1281 ==================
1282 */
1283 void Sbar_FinaleOverlay (void)
1284 {
1285         cachepic_t      *pic;
1286
1287         pic = Draw_CachePic ("gfx/finale.lmp");
1288         DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);
1289 }
1290