2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // sbar.c -- status bar code
30 static sbarpic_t sbarpics[256];
31 static int numsbarpics;
33 static sbarpic_t *Sbar_NewPic(const char *name)
35 strcpy(sbarpics[numsbarpics].name, name);
37 // FIXME: precache on every renderer restart (or move this to client)
38 Draw_CachePic(sbarpics[numsbarpics].name);
39 return sbarpics + (numsbarpics++);
44 #define STAT_MINUS 10 // num frame for '-' stats digit
45 sbarpic_t *sb_nums[2][11];
46 sbarpic_t *sb_colon, *sb_slash;
49 sbarpic_t *sb_scorebar;
50 // AK only used by NEX(and only if everybody agrees)
51 sbarpic_t *sb_sbar_overlay;
53 // AK changed the bound to 9
54 sbarpic_t *sb_weapons[7][9]; // 0 is active, 1 is owned, 2-5 are flashes
55 sbarpic_t *sb_ammo[4];
56 sbarpic_t *sb_sigil[4];
57 sbarpic_t *sb_armor[3];
58 sbarpic_t *sb_items[32];
60 // 0-4 are based on health (in 20 increments)
61 // 0 is static, 1 is temporary animation
62 sbarpic_t *sb_faces[5][2];
64 sbarpic_t *sb_face_invis;
65 sbarpic_t *sb_face_quad;
66 sbarpic_t *sb_face_invuln;
67 sbarpic_t *sb_face_invis_invuln;
69 qboolean sb_showscores;
71 int sb_lines; // scan lines to draw
73 sbarpic_t *rsb_invbar[2];
74 sbarpic_t *rsb_weapons[5];
75 sbarpic_t *rsb_items[2];
76 sbarpic_t *rsb_ammo[3];
77 sbarpic_t *rsb_teambord; // PGM 01/19/97 - team color border
79 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
80 sbarpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
81 //MED 01/04/97 added array to simplify weapon parsing
82 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
83 //MED 01/04/97 added hipnotic items array
84 sbarpic_t *hsb_items[2];
86 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
87 cvar_t sbar_alpha = {CVAR_SAVE, "sbar_alpha", "1"};
89 void Sbar_MiniDeathmatchOverlay (void);
90 void Sbar_DeathmatchOverlay (void);
91 void Sbar_IntermissionOverlay (void);
92 void Sbar_FinaleOverlay (void);
102 void Sbar_ShowScores (void)
106 sb_showscores = true;
116 void Sbar_DontShowScores (void)
118 sb_showscores = false;
121 void sbar_start(void)
127 sb_disc = Sbar_NewPic("gfx/disc");
129 for (i = 0;i < 10;i++)
131 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
132 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
135 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
136 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
138 sb_colon = Sbar_NewPic ("gfx/num_colon");
139 sb_slash = Sbar_NewPic ("gfx/num_slash");
141 //AK NX uses its own hud
142 if(gamemode == GAME_NEXUIZ)
144 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
145 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
146 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
147 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
149 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
150 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
151 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
152 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
154 sb_sbar = Sbar_NewPic("gfx/sbar");
155 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
157 for(i = 0; i < 9;i++)
158 sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
163 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
164 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
165 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
166 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
167 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
168 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
169 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
171 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
172 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
173 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
174 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
175 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
176 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
177 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
179 for (i = 0;i < 5;i++)
181 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
182 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
183 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
184 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
185 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
186 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
187 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
190 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
191 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
192 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
193 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
195 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
196 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
197 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
199 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
200 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
201 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
202 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
203 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
204 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
206 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
207 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
208 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
209 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
211 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
212 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
213 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
214 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
215 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
216 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
217 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
218 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
219 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
220 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
222 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
223 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
224 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
225 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
227 sb_sbar = Sbar_NewPic ("gfx/sbar");
228 sb_ibar = Sbar_NewPic ("gfx/ibar");
229 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
231 //MED 01/04/97 added new hipnotic weapons
232 if (gamemode == GAME_HIPNOTIC)
234 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
235 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
236 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
237 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
238 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
240 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
241 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
242 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
243 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
244 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
246 for (i = 0;i < 5;i++)
248 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
249 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
250 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
251 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
252 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
255 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
256 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
258 else if (gamemode == GAME_ROGUE)
260 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
261 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
263 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
264 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
265 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
266 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
267 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
269 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
270 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
272 // PGM 01/19/97 - team color border
273 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
274 // PGM 01/19/97 - team color border
276 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
277 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
278 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
282 void sbar_shutdown(void)
286 void sbar_newmap(void)
290 void Sbar_Init (void)
292 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
293 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
294 Cvar_RegisterVariable (&showfps);
295 Cvar_RegisterVariable (&sbar_alpha);
297 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
301 //=============================================================================
303 // drawing routines are relative to the status bar location
312 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
314 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha.value, 0);
317 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
319 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha * sbar_alpha.value, 0);
326 Draws one solid graphics character
329 void Sbar_DrawCharacter (int x, int y, int num)
331 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
339 void Sbar_DrawString (int x, int y, char *str)
341 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
349 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
354 l = sprintf(str, "%i", num);
368 Sbar_DrawPic (x, y, sb_nums[color][frame]);
381 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
386 l = sprintf(str, "%i", num);
391 x += (digits-l) * lettersize;
400 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha.value,flags);
407 //=============================================================================
415 static int fragsort[MAX_SCOREBOARD];
416 static int scoreboardlines;
417 void Sbar_SortFrags (void)
423 for (i=0 ; i<cl.maxclients ; i++)
425 if (cl.scores[i].name[0])
427 fragsort[scoreboardlines] = i;
432 for (i=0 ; i<scoreboardlines ; i++)
433 for (j=0 ; j<scoreboardlines-1-i ; j++)
434 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
437 fragsort[j] = fragsort[j+1];
447 void Sbar_SoloScoreboard (void)
450 int minutes, seconds, tens, units;
453 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
454 Sbar_DrawString (8, 4, str);
456 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
457 Sbar_DrawString (8, 12, str);
460 minutes = cl.time / 60;
461 seconds = cl.time - 60*minutes;
463 units = seconds - 10*tens;
464 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
465 Sbar_DrawString (184, 4, str);
468 l = strlen (cl.levelname);
469 Sbar_DrawString (232 - l*4, 12, cl.levelname);
477 void Sbar_DrawScoreboard (void)
479 Sbar_SoloScoreboard ();
480 if (cl.gametype == GAME_DEATHMATCH)
481 Sbar_DeathmatchOverlay ();
484 //=============================================================================
486 // AK to make DrawInventory smaller
487 static void Sbar_DrawWeapon(int nr, float fade, int active)
489 // width = 300, height = 100
490 const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
491 const float w_scale = 0.4;
493 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.value, DRAWFLAG_ADDITIVE);
494 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);
497 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.value, DRAWFLAG_ADDITIVE);
505 void Sbar_DrawInventory (void)
514 if(gamemode == GAME_NEXUIZ)
516 num[0] = cl.stats[STAT_ACTIVEWEAPON];
517 // we have a max time 2s (min time = 0)
518 if ((time = cl.time - cl.weapontime) > 2)
521 fade = (1.0 - 0.5 * time);
523 for (i = 0; i < 8;i++)
525 if (!(cl.items & (1 << i)))
527 Sbar_DrawWeapon(i + 1, fade, (i == num[0]));
530 if(!(cl.items & (1<<12)))
532 Sbar_DrawWeapon(0, fade, (num[0] == 12));
536 if (gamemode == GAME_ROGUE)
538 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
539 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
541 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
544 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
547 for (i=0 ; i<7 ; i++)
549 if (cl.items & (IT_SHOTGUN<<i) )
551 time = cl.item_gettime[i];
552 flashon = (int)((cl.time - time)*10);
555 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
561 flashon = (flashon%5) + 2;
563 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
569 if (gamemode == GAME_HIPNOTIC)
571 int grenadeflashing=0;
572 for (i=0 ; i<4 ; i++)
574 if (cl.items & (1<<hipweapons[i]) )
576 time = cl.item_gettime[hipweapons[i]];
577 flashon = (int)((cl.time - time)*10);
580 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
586 flashon = (flashon%5) + 2;
588 // check grenade launcher
591 if (cl.items & HIT_PROXIMITY_GUN)
596 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
602 if (cl.items & (IT_SHOTGUN<<4))
604 if (!grenadeflashing)
605 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
608 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
611 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
616 if (gamemode == GAME_ROGUE)
618 // check for powered up weapon.
619 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
621 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
622 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
626 for (i=0 ; i<4 ; i++)
628 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
630 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
632 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
634 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
638 for (i=0 ; i<6 ; i++)
639 if (cl.items & (1<<(17+i)))
641 //MED 01/04/97 changed keys
642 if (gamemode != GAME_HIPNOTIC || (i>1))
643 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
646 //MED 01/04/97 added hipnotic items
648 if (gamemode == GAME_HIPNOTIC)
650 for (i=0 ; i<2 ; i++)
651 if (cl.items & (1<<(24+i)))
652 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
655 if (gamemode == GAME_ROGUE)
658 for (i=0 ; i<2 ; i++)
659 if (cl.items & (1<<(29+i)))
660 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
665 for (i=0 ; i<4 ; i++)
666 if (cl.items & (1<<(28+i)))
667 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
671 //=============================================================================
678 void Sbar_DrawFrags (void)
688 l = scoreboardlines <= 4 ? scoreboardlines : 4;
692 for (i = 0;i < l;i++)
700 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
701 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.value, 0);
702 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
703 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.value, 0);
707 sprintf (num, "%3i",f);
709 Sbar_DrawCharacter (x + 8, -24, num[0]);
710 Sbar_DrawCharacter (x + 16, -24, num[1]);
711 Sbar_DrawCharacter (x + 24, -24, num[2]);
713 if (k == cl.viewentity - 1)
715 Sbar_DrawCharacter ( x + 2, -24, 16);
716 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
722 //=============================================================================
730 void Sbar_DrawFace (void)
734 // PGM 01/19/97 - team color drawing
735 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
736 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
742 s = &cl.scores[cl.viewentity - 1];
744 Sbar_DrawPic (112, 0, rsb_teambord);
745 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
746 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.value, 0);
747 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
748 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.value, 0);
752 sprintf (num, "%3i",f);
754 if ((s->colors & 0xf0)==0)
757 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
759 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
761 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
765 Sbar_DrawCharacter ( 109, 3, num[0]);
766 Sbar_DrawCharacter ( 116, 3, num[1]);
767 Sbar_DrawCharacter ( 123, 3, num[2]);
772 // PGM 01/19/97 - team color drawing
774 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
775 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
776 else if (cl.items & IT_QUAD)
777 Sbar_DrawPic (112, 0, sb_face_quad );
778 else if (cl.items & IT_INVISIBILITY)
779 Sbar_DrawPic (112, 0, sb_face_invis );
780 else if (cl.items & IT_INVULNERABILITY)
781 Sbar_DrawPic (112, 0, sb_face_invuln);
784 f = cl.stats[STAT_HEALTH] / 20;
786 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
790 void Sbar_ShowFPS(void)
796 float fps_x, fps_y, fps_scalex, fps_scaley;
797 if (showfps.integer > 1)
799 static double currtime, frametimes[32];
800 double newtime, total;
802 static int framecycle = 0;
804 newtime = Sys_DoubleTime();
805 frametimes[framecycle] = newtime - currtime;
808 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
810 total += frametimes[i];
815 if (showfps.integer == 2)
816 calc = (int) (((double) count / total) + 0.5);
817 else // showfps 3, rapid update
818 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
823 static double nexttime = 0, lasttime = 0;
824 static int framerate = 0, framecount = 0;
826 newtime = Sys_DoubleTime();
827 if (newtime < nexttime)
831 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
833 nexttime = lasttime + 0.2;
838 sprintf(temp, "%4i", calc);
841 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
842 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
843 if (fps_y > vid.conheight - fps_scaley)
844 fps_y = vid.conheight - fps_scaley;
845 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
846 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
855 void Sbar_Draw (void)
857 if (scr_con_current == vid.conheight)
858 return; // console is full screen
860 if (cl.intermission == 1)
862 Sbar_IntermissionOverlay();
865 else if (cl.intermission == 2)
867 Sbar_FinaleOverlay();
871 if (gamemode == GAME_NEXUIZ)
873 sbar_y = vid.conheight - 47;
874 sbar_x = (vid.conwidth - 640)/2;
878 Sbar_DrawInventory();
883 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
885 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
886 Sbar_DrawScoreboard ();
890 Sbar_DrawPic (0, 0, sb_sbar);
893 if (cl.items & IT_INVULNERABILITY)
895 Sbar_DrawNum (36, 0, 666, 3, 1);
896 Sbar_DrawPic (0, 0, sb_disc);
900 Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
903 if(cl.stats[STAT_HEALTH] > 100)
904 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
905 else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
906 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
908 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
910 // AK dont draw ammo for the laser
911 if(cl.stats[STAT_ACTIVEWEAPON] != 12)
913 if (cl.items & NEX_IT_SHELLS)
914 Sbar_DrawPic (519, 0, sb_ammo[0]);
915 else if (cl.items & NEX_IT_BULLETS)
916 Sbar_DrawPic (519, 0, sb_ammo[1]);
917 else if (cl.items & NEX_IT_ROCKETS)
918 Sbar_DrawPic (519, 0, sb_ammo[2]);
919 else if (cl.items & NEX_IT_CELLS)
920 Sbar_DrawPic (519, 0, sb_ammo[3]);
922 if(cl.stats[STAT_AMMO] <= 10)
923 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
925 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
929 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
934 sbar_y = vid.conheight - SBAR_HEIGHT;
935 if (cl.gametype == GAME_DEATHMATCH)
938 sbar_x = (vid.conwidth - 320)/2;
942 if (gamemode != GAME_GOODVSBAD2)
943 Sbar_DrawInventory ();
948 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
950 if (gamemode != GAME_GOODVSBAD2)
951 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
952 Sbar_DrawScoreboard ();
956 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
958 // keys (hipnotic only)
959 //MED 01/04/97 moved keys here so they would not be overwritten
960 if (gamemode == GAME_HIPNOTIC)
962 if (cl.items & IT_KEY1)
963 Sbar_DrawPic (209, 3, sb_items[0]);
964 if (cl.items & IT_KEY2)
965 Sbar_DrawPic (209, 12, sb_items[1]);
968 if (gamemode != GAME_GOODVSBAD2)
970 if (cl.items & IT_INVULNERABILITY)
972 Sbar_DrawNum (24, 0, 666, 3, 1);
973 Sbar_DrawPic (0, 0, sb_disc);
977 if (gamemode == GAME_ROGUE)
979 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
980 if (cl.items & RIT_ARMOR3)
981 Sbar_DrawPic (0, 0, sb_armor[2]);
982 else if (cl.items & RIT_ARMOR2)
983 Sbar_DrawPic (0, 0, sb_armor[1]);
984 else if (cl.items & RIT_ARMOR1)
985 Sbar_DrawPic (0, 0, sb_armor[0]);
989 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
990 if (cl.items & IT_ARMOR3)
991 Sbar_DrawPic (0, 0, sb_armor[2]);
992 else if (cl.items & IT_ARMOR2)
993 Sbar_DrawPic (0, 0, sb_armor[1]);
994 else if (cl.items & IT_ARMOR1)
995 Sbar_DrawPic (0, 0, sb_armor[0]);
1004 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1007 if (gamemode == GAME_ROGUE)
1009 if (cl.items & RIT_SHELLS)
1010 Sbar_DrawPic (224, 0, sb_ammo[0]);
1011 else if (cl.items & RIT_NAILS)
1012 Sbar_DrawPic (224, 0, sb_ammo[1]);
1013 else if (cl.items & RIT_ROCKETS)
1014 Sbar_DrawPic (224, 0, sb_ammo[2]);
1015 else if (cl.items & RIT_CELLS)
1016 Sbar_DrawPic (224, 0, sb_ammo[3]);
1017 else if (cl.items & RIT_LAVA_NAILS)
1018 Sbar_DrawPic (224, 0, rsb_ammo[0]);
1019 else if (cl.items & RIT_PLASMA_AMMO)
1020 Sbar_DrawPic (224, 0, rsb_ammo[1]);
1021 else if (cl.items & RIT_MULTI_ROCKETS)
1022 Sbar_DrawPic (224, 0, rsb_ammo[2]);
1026 if (cl.items & IT_SHELLS)
1027 Sbar_DrawPic (224, 0, sb_ammo[0]);
1028 else if (cl.items & IT_NAILS)
1029 Sbar_DrawPic (224, 0, sb_ammo[1]);
1030 else if (cl.items & IT_ROCKETS)
1031 Sbar_DrawPic (224, 0, sb_ammo[2]);
1032 else if (cl.items & IT_CELLS)
1033 Sbar_DrawPic (224, 0, sb_ammo[3]);
1036 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1041 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1042 Sbar_MiniDeathmatchOverlay ();
1046 R_Draw2DCrosshair();
1049 //=============================================================================
1053 Sbar_DeathmatchOverlay
1057 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1060 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1062 // draw colors behind score
1063 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1064 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.value, 0);
1065 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1066 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.value, 0);
1068 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.value, 0);
1075 void Sbar_DeathmatchOverlay (void)
1080 pic = Draw_CachePic ("gfx/ranking.lmp");
1081 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1086 x = (vid.conwidth - (6 + 15) * 8) / 2;
1088 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1089 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1094 Sbar_DeathmatchOverlay
1098 void Sbar_MiniDeathmatchOverlay (void)
1100 int i, x, y, numlines;
1102 // decide where to print
1103 // AK Nex wants its scores on the upper left
1104 if(gamemode == GAME_NEXUIZ)
1112 y = vid.conheight - sb_lines;
1115 numlines = (vid.conheight - y) / 8;
1116 // give up if there isn't room
1117 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1124 for (i = 0; i < scoreboardlines; i++)
1125 if (fragsort[i] == cl.playerentity - 1)
1128 if (i == scoreboardlines) // we're not there
1130 else // figure out start
1133 i = bound(0, i, scoreboardlines - numlines);
1136 for (;i < scoreboardlines && y < vid.conheight;i++)
1137 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1142 Sbar_IntermissionOverlay
1146 void Sbar_IntermissionOverlay (void)
1151 if (cl.gametype == GAME_DEATHMATCH)
1153 Sbar_DeathmatchOverlay ();
1157 sbar_x = (vid.conwidth - 320) >> 1;
1158 sbar_y = (vid.conheight - 200) >> 1;
1160 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1161 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1164 dig = cl.completed_time/60;
1165 Sbar_DrawNum (160, 64, dig, 3, 0);
1166 num = cl.completed_time - dig*60;
1167 Sbar_DrawPic (234,64,sb_colon);
1168 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1169 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1171 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1172 Sbar_DrawPic (232, 104, sb_slash);
1173 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1175 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1176 Sbar_DrawPic (232, 144, sb_slash);
1177 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1188 void Sbar_FinaleOverlay (void)
1192 pic = Draw_CachePic ("gfx/finale.lmp");
1193 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);