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];
87 sbarpic_t *somsb_health;
88 sbarpic_t *somsb_ammo[4];
89 sbarpic_t *somsb_armor[3];
91 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
92 cvar_t sbar_alpha = {CVAR_SAVE, "sbar_alpha", "1"};
94 void Sbar_MiniDeathmatchOverlay (int x, int y);
95 void Sbar_DeathmatchOverlay (void);
96 void Sbar_IntermissionOverlay (void);
97 void Sbar_FinaleOverlay (void);
107 void Sbar_ShowScores (void)
111 sb_showscores = true;
121 void Sbar_DontShowScores (void)
123 sb_showscores = false;
126 void sbar_start(void)
132 sb_disc = Sbar_NewPic("gfx/disc");
134 for (i = 0;i < 10;i++)
136 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
137 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
140 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
141 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
143 sb_colon = Sbar_NewPic ("gfx/num_colon");
144 sb_slash = Sbar_NewPic ("gfx/num_slash");
146 if (gamemode == GAME_SOM)
148 somsb_health = Sbar_NewPic("gfx/hud_health");
149 somsb_ammo[0] = Sbar_NewPic("gfx/sb_shells");
150 somsb_ammo[1] = Sbar_NewPic("gfx/sb_nails");
151 somsb_ammo[2] = Sbar_NewPic("gfx/sb_rocket");
152 somsb_ammo[3] = Sbar_NewPic("gfx/sb_cells");
153 somsb_armor[0] = Sbar_NewPic("gfx/sb_armor1");
154 somsb_armor[1] = Sbar_NewPic("gfx/sb_armor2");
155 somsb_armor[2] = Sbar_NewPic("gfx/sb_armor3");
157 else if (gamemode == GAME_NEXUIZ)
159 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
160 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
161 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
162 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
164 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
165 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
166 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
167 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
169 sb_sbar = Sbar_NewPic("gfx/sbar");
170 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
172 for(i = 0; i < 9;i++)
173 sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
177 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
178 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
179 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
180 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
181 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
182 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
183 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
185 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
186 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
187 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
188 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
189 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
190 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
191 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
193 for (i = 0;i < 5;i++)
195 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
196 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
197 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
198 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
199 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
200 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
201 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
204 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
205 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
206 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
207 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
209 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
210 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
211 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
213 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
214 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
215 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
216 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
217 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
218 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
220 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
221 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
222 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
223 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
225 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
226 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
227 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
228 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
229 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
230 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
231 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
232 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
233 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
234 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
236 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
237 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
238 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
239 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
241 sb_sbar = Sbar_NewPic ("gfx/sbar");
242 sb_ibar = Sbar_NewPic ("gfx/ibar");
243 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
245 //MED 01/04/97 added new hipnotic weapons
246 if (gamemode == GAME_HIPNOTIC)
248 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
249 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
250 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
251 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
252 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
254 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
255 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
256 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
257 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
258 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
260 for (i = 0;i < 5;i++)
262 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
263 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
264 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
265 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
266 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
269 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
270 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
272 else if (gamemode == GAME_ROGUE)
274 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
275 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
277 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
278 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
279 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
280 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
281 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
283 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
284 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
286 // PGM 01/19/97 - team color border
287 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
288 // PGM 01/19/97 - team color border
290 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
291 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
292 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
297 void sbar_shutdown(void)
301 void sbar_newmap(void)
305 void Sbar_Init (void)
307 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
308 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
309 Cvar_RegisterVariable (&showfps);
310 Cvar_RegisterVariable (&sbar_alpha);
312 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
316 //=============================================================================
318 // drawing routines are relative to the status bar location
327 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
329 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha.value, 0);
332 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
334 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha * sbar_alpha.value, 0);
341 Draws one solid graphics character
344 void Sbar_DrawCharacter (int x, int y, int num)
346 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
354 void Sbar_DrawString (int x, int y, char *str)
356 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
364 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
369 l = sprintf(str, "%i", num);
383 Sbar_DrawPic (x, y, sb_nums[color][frame]);
396 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
401 l = sprintf(str, "%i", num);
406 x += (digits-l) * lettersize;
415 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha.value,flags);
422 //=============================================================================
430 static int fragsort[MAX_SCOREBOARD];
431 static int scoreboardlines;
432 void Sbar_SortFrags (void)
438 for (i=0 ; i<cl.maxclients ; i++)
440 if (cl.scores[i].name[0])
442 fragsort[scoreboardlines] = i;
447 for (i=0 ; i<scoreboardlines ; i++)
448 for (j=0 ; j<scoreboardlines-1-i ; j++)
449 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
452 fragsort[j] = fragsort[j+1];
462 void Sbar_SoloScoreboard (void)
465 int minutes, seconds, tens, units;
468 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
469 Sbar_DrawString (8, 4, str);
471 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
472 Sbar_DrawString (8, 12, str);
475 minutes = cl.time / 60;
476 seconds = cl.time - 60*minutes;
478 units = seconds - 10*tens;
479 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
480 Sbar_DrawString (184, 4, str);
483 l = strlen (cl.levelname);
484 Sbar_DrawString (232 - l*4, 12, cl.levelname);
492 void Sbar_DrawScoreboard (void)
494 Sbar_SoloScoreboard ();
495 if (cl.gametype == GAME_DEATHMATCH)
496 Sbar_DeathmatchOverlay ();
499 //=============================================================================
501 // AK to make DrawInventory smaller
502 static void Sbar_DrawWeapon(int nr, float fade, int active)
504 // width = 300, height = 100
505 const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
506 const float w_scale = 0.4;
508 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);
509 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);
512 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);
520 void Sbar_DrawInventory (void)
527 if (gamemode == GAME_ROGUE)
529 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
530 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
532 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
535 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
538 for (i=0 ; i<7 ; i++)
540 if (cl.items & (IT_SHOTGUN<<i) )
542 time = cl.item_gettime[i];
543 flashon = (int)((cl.time - time)*10);
546 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
552 flashon = (flashon%5) + 2;
554 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
560 if (gamemode == GAME_HIPNOTIC)
562 int grenadeflashing=0;
563 for (i=0 ; i<4 ; i++)
565 if (cl.items & (1<<hipweapons[i]) )
567 time = cl.item_gettime[hipweapons[i]];
568 flashon = (int)((cl.time - time)*10);
571 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
577 flashon = (flashon%5) + 2;
579 // check grenade launcher
582 if (cl.items & HIT_PROXIMITY_GUN)
587 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
593 if (cl.items & (IT_SHOTGUN<<4))
595 if (!grenadeflashing)
596 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
599 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
602 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
607 if (gamemode == GAME_ROGUE)
609 // check for powered up weapon.
610 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
612 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
613 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
617 for (i=0 ; i<4 ; i++)
619 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
621 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
623 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
625 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
629 for (i=0 ; i<6 ; i++)
630 if (cl.items & (1<<(17+i)))
632 //MED 01/04/97 changed keys
633 if (gamemode != GAME_HIPNOTIC || (i>1))
634 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
637 //MED 01/04/97 added hipnotic items
639 if (gamemode == GAME_HIPNOTIC)
641 for (i=0 ; i<2 ; i++)
642 if (cl.items & (1<<(24+i)))
643 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
646 if (gamemode == GAME_ROGUE)
649 for (i=0 ; i<2 ; i++)
650 if (cl.items & (1<<(29+i)))
651 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
656 for (i=0 ; i<4 ; i++)
657 if (cl.items & (1<<(28+i)))
658 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
662 //=============================================================================
669 void Sbar_DrawFrags (void)
679 l = scoreboardlines <= 4 ? scoreboardlines : 4;
683 for (i = 0;i < l;i++)
691 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
692 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);
693 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
694 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);
698 sprintf (num, "%3i",f);
700 Sbar_DrawCharacter (x + 8, -24, num[0]);
701 Sbar_DrawCharacter (x + 16, -24, num[1]);
702 Sbar_DrawCharacter (x + 24, -24, num[2]);
704 if (k == cl.viewentity - 1)
706 Sbar_DrawCharacter ( x + 2, -24, 16);
707 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
713 //=============================================================================
721 void Sbar_DrawFace (void)
725 // PGM 01/19/97 - team color drawing
726 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
727 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
733 s = &cl.scores[cl.viewentity - 1];
735 Sbar_DrawPic (112, 0, rsb_teambord);
736 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
737 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);
738 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
739 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);
743 sprintf (num, "%3i",f);
745 if ((s->colors & 0xf0)==0)
748 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
750 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
752 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
756 Sbar_DrawCharacter ( 109, 3, num[0]);
757 Sbar_DrawCharacter ( 116, 3, num[1]);
758 Sbar_DrawCharacter ( 123, 3, num[2]);
763 // PGM 01/19/97 - team color drawing
765 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
766 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
767 else if (cl.items & IT_QUAD)
768 Sbar_DrawPic (112, 0, sb_face_quad );
769 else if (cl.items & IT_INVISIBILITY)
770 Sbar_DrawPic (112, 0, sb_face_invis );
771 else if (cl.items & IT_INVULNERABILITY)
772 Sbar_DrawPic (112, 0, sb_face_invuln);
775 f = cl.stats[STAT_HEALTH] / 20;
777 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
781 void Sbar_ShowFPS(void)
787 float fps_x, fps_y, fps_scalex, fps_scaley;
788 if (showfps.integer > 1)
790 static double currtime, frametimes[32];
791 double newtime, total;
793 static int framecycle = 0;
795 newtime = Sys_DoubleTime();
796 frametimes[framecycle] = newtime - currtime;
799 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
801 total += frametimes[i];
806 if (showfps.integer == 2)
807 calc = (int) (((double) count / total) + 0.5);
808 else // showfps 3, rapid update
809 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
814 static double nexttime = 0, lasttime = 0;
815 static int framerate = 0, framecount = 0;
817 newtime = Sys_DoubleTime();
818 if (newtime < nexttime)
822 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
824 nexttime = lasttime + 0.2;
829 sprintf(temp, "%4i", calc);
832 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
833 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
834 if (fps_y > vid.conheight - fps_scaley)
835 fps_y = vid.conheight - fps_scaley;
836 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
837 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
846 void Sbar_Draw (void)
848 if (scr_con_current == vid.conheight)
849 return; // console is full screen
851 if (cl.intermission == 1)
853 Sbar_IntermissionOverlay();
856 else if (cl.intermission == 2)
858 Sbar_FinaleOverlay();
862 if (gamemode == GAME_SOM)
864 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
865 Sbar_DrawScoreboard ();
868 // this is the top left of the sbar area
870 sbar_y = vid.conheight - 24*3;
873 if (cl.stats[STAT_ARMOR])
875 if (cl.items & IT_ARMOR3)
876 Sbar_DrawPic(0, 0, somsb_armor[2]);
877 else if (cl.items & IT_ARMOR2)
878 Sbar_DrawPic(0, 0, somsb_armor[1]);
879 else if (cl.items & IT_ARMOR1)
880 Sbar_DrawPic(0, 0, somsb_armor[0]);
881 Sbar_DrawNum(24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
885 Sbar_DrawPic(0, 24, somsb_health);
886 Sbar_DrawNum(24, 24, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
889 if (cl.items & IT_SHELLS)
890 Sbar_DrawPic(0, 48, somsb_ammo[0]);
891 else if (cl.items & IT_NAILS)
892 Sbar_DrawPic(0, 48, somsb_ammo[1]);
893 else if (cl.items & IT_ROCKETS)
894 Sbar_DrawPic(0, 48, somsb_ammo[2]);
895 else if (cl.items & IT_CELLS)
896 Sbar_DrawPic(0, 48, somsb_ammo[3]);
897 Sbar_DrawNum(24, 48, cl.stats[STAT_AMMO], 3, false);
898 if (cl.stats[STAT_SHELLS])
899 Sbar_DrawNum(24 + 3*24, 48, cl.stats[STAT_SHELLS], 1, true);
902 else if (gamemode == GAME_NEXUIZ)
904 sbar_y = vid.conheight - 47;
905 sbar_x = (vid.conwidth - 640)/2;
912 // we have a max time 2s (min time = 0)
913 if ((time = cl.time - cl.weapontime) < 2)
915 fade = (1.0 - 0.5 * time);
917 for (i = 0; i < 8;i++)
919 if (!(cl.items & (1 << i)))
921 Sbar_DrawWeapon(i + 1, fade, (i == cl.stats[STAT_ACTIVEWEAPON]));
924 if((cl.items & (1<<12)))
925 Sbar_DrawWeapon(0, fade, (cl.stats[STAT_ACTIVEWEAPON] == 12));
931 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
933 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
934 Sbar_DrawScoreboard ();
938 Sbar_DrawPic (0, 0, sb_sbar);
941 if (cl.items & IT_INVULNERABILITY)
943 Sbar_DrawNum (36, 0, 666, 3, 1);
944 Sbar_DrawPic (0, 0, sb_disc);
948 Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
951 if(cl.stats[STAT_HEALTH] > 100)
952 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
953 else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
954 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
956 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
958 // AK dont draw ammo for the laser
959 if(cl.stats[STAT_ACTIVEWEAPON] != 12)
961 if (cl.items & NEX_IT_SHELLS)
962 Sbar_DrawPic (519, 0, sb_ammo[0]);
963 else if (cl.items & NEX_IT_BULLETS)
964 Sbar_DrawPic (519, 0, sb_ammo[1]);
965 else if (cl.items & NEX_IT_ROCKETS)
966 Sbar_DrawPic (519, 0, sb_ammo[2]);
967 else if (cl.items & NEX_IT_CELLS)
968 Sbar_DrawPic (519, 0, sb_ammo[3]);
970 if(cl.stats[STAT_AMMO] <= 10)
971 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
973 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
977 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
980 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
981 Sbar_MiniDeathmatchOverlay (0, 0);
983 else // Quake and others
985 sbar_y = vid.conheight - SBAR_HEIGHT;
986 if (cl.gametype == GAME_DEATHMATCH)
989 sbar_x = (vid.conwidth - 320)/2;
993 if (gamemode != GAME_GOODVSBAD2)
994 Sbar_DrawInventory ();
999 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
1001 if (gamemode != GAME_GOODVSBAD2)
1002 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
1003 Sbar_DrawScoreboard ();
1007 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
1009 // keys (hipnotic only)
1010 //MED 01/04/97 moved keys here so they would not be overwritten
1011 if (gamemode == GAME_HIPNOTIC)
1013 if (cl.items & IT_KEY1)
1014 Sbar_DrawPic (209, 3, sb_items[0]);
1015 if (cl.items & IT_KEY2)
1016 Sbar_DrawPic (209, 12, sb_items[1]);
1019 if (gamemode != GAME_GOODVSBAD2)
1021 if (cl.items & IT_INVULNERABILITY)
1023 Sbar_DrawNum (24, 0, 666, 3, 1);
1024 Sbar_DrawPic (0, 0, sb_disc);
1028 if (gamemode == GAME_ROGUE)
1030 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1031 if (cl.items & RIT_ARMOR3)
1032 Sbar_DrawPic (0, 0, sb_armor[2]);
1033 else if (cl.items & RIT_ARMOR2)
1034 Sbar_DrawPic (0, 0, sb_armor[1]);
1035 else if (cl.items & RIT_ARMOR1)
1036 Sbar_DrawPic (0, 0, sb_armor[0]);
1040 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1041 if (cl.items & IT_ARMOR3)
1042 Sbar_DrawPic (0, 0, sb_armor[2]);
1043 else if (cl.items & IT_ARMOR2)
1044 Sbar_DrawPic (0, 0, sb_armor[1]);
1045 else if (cl.items & IT_ARMOR1)
1046 Sbar_DrawPic (0, 0, sb_armor[0]);
1055 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1058 if (gamemode == GAME_ROGUE)
1060 if (cl.items & RIT_SHELLS)
1061 Sbar_DrawPic (224, 0, sb_ammo[0]);
1062 else if (cl.items & RIT_NAILS)
1063 Sbar_DrawPic (224, 0, sb_ammo[1]);
1064 else if (cl.items & RIT_ROCKETS)
1065 Sbar_DrawPic (224, 0, sb_ammo[2]);
1066 else if (cl.items & RIT_CELLS)
1067 Sbar_DrawPic (224, 0, sb_ammo[3]);
1068 else if (cl.items & RIT_LAVA_NAILS)
1069 Sbar_DrawPic (224, 0, rsb_ammo[0]);
1070 else if (cl.items & RIT_PLASMA_AMMO)
1071 Sbar_DrawPic (224, 0, rsb_ammo[1]);
1072 else if (cl.items & RIT_MULTI_ROCKETS)
1073 Sbar_DrawPic (224, 0, rsb_ammo[2]);
1077 if (cl.items & IT_SHELLS)
1078 Sbar_DrawPic (224, 0, sb_ammo[0]);
1079 else if (cl.items & IT_NAILS)
1080 Sbar_DrawPic (224, 0, sb_ammo[1]);
1081 else if (cl.items & IT_ROCKETS)
1082 Sbar_DrawPic (224, 0, sb_ammo[2]);
1083 else if (cl.items & IT_CELLS)
1084 Sbar_DrawPic (224, 0, sb_ammo[3]);
1087 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1091 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1092 Sbar_MiniDeathmatchOverlay (324, vid.conheight - sb_lines);
1097 R_Draw2DCrosshair();
1100 //=============================================================================
1104 Sbar_DeathmatchOverlay
1108 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1111 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1113 // draw colors behind score
1114 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1115 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);
1116 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1117 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);
1119 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);
1126 void Sbar_DeathmatchOverlay (void)
1131 pic = Draw_CachePic ("gfx/ranking.lmp");
1132 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1137 x = (vid.conwidth - (6 + 15) * 8) / 2;
1139 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1140 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1145 Sbar_DeathmatchOverlay
1149 void Sbar_MiniDeathmatchOverlay (int x, int y)
1153 // decide where to print
1155 numlines = (vid.conheight - y) / 8;
1156 // give up if there isn't room
1157 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1164 for (i = 0; i < scoreboardlines; i++)
1165 if (fragsort[i] == cl.playerentity - 1)
1168 if (i == scoreboardlines) // we're not there
1170 else // figure out start
1173 i = bound(0, i, scoreboardlines - numlines);
1176 for (;i < scoreboardlines && y < vid.conheight;i++)
1177 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1182 Sbar_IntermissionOverlay
1186 void Sbar_IntermissionOverlay (void)
1191 if (cl.gametype == GAME_DEATHMATCH)
1193 Sbar_DeathmatchOverlay ();
1197 sbar_x = (vid.conwidth - 320) >> 1;
1198 sbar_y = (vid.conheight - 200) >> 1;
1200 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1201 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1204 dig = cl.completed_time/60;
1205 Sbar_DrawNum (160, 64, dig, 3, 0);
1206 num = cl.completed_time - dig*60;
1207 Sbar_DrawPic (234,64,sb_colon);
1208 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1209 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1211 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1212 Sbar_DrawPic (232, 104, sb_slash);
1213 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1215 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1216 Sbar_DrawPic (232, 144, sb_slash);
1217 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1228 void Sbar_FinaleOverlay (void)
1232 pic = Draw_CachePic ("gfx/finale.lmp");
1233 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);