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
51 sbarpic_t *sb_sbar_minimal;
52 sbarpic_t *sb_sbar_overlay;
54 // AK changed the bound to 9
55 sbarpic_t *sb_weapons[7][9]; // 0 is active, 1 is owned, 2-5 are flashes
56 sbarpic_t *sb_ammo[4];
57 sbarpic_t *sb_sigil[4];
58 sbarpic_t *sb_armor[3];
59 sbarpic_t *sb_items[32];
61 // 0-4 are based on health (in 20 increments)
62 // 0 is static, 1 is temporary animation
63 sbarpic_t *sb_faces[5][2];
65 sbarpic_t *sb_face_invis;
66 sbarpic_t *sb_face_quad;
67 sbarpic_t *sb_face_invuln;
68 sbarpic_t *sb_face_invis_invuln;
70 qboolean sb_showscores;
72 int sb_lines; // scan lines to draw
74 sbarpic_t *rsb_invbar[2];
75 sbarpic_t *rsb_weapons[5];
76 sbarpic_t *rsb_items[2];
77 sbarpic_t *rsb_ammo[3];
78 sbarpic_t *rsb_teambord; // PGM 01/19/97 - team color border
80 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
81 sbarpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
82 //MED 01/04/97 added array to simplify weapon parsing
83 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
84 //MED 01/04/97 added hipnotic items array
85 sbarpic_t *hsb_items[2];
88 sbarpic_t *somsb_health;
89 sbarpic_t *somsb_ammo[4];
90 sbarpic_t *somsb_armor[3];
92 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
93 cvar_t sbar_alpha = {CVAR_SAVE, "sbar_alpha", "1"};
95 void Sbar_MiniDeathmatchOverlay (int x, int y);
96 void Sbar_DeathmatchOverlay (void);
97 void Sbar_IntermissionOverlay (void);
98 void Sbar_FinaleOverlay (void);
108 void Sbar_ShowScores (void)
112 sb_showscores = true;
122 void Sbar_DontShowScores (void)
124 sb_showscores = false;
127 void sbar_start(void)
133 sb_disc = Sbar_NewPic("gfx/disc");
135 for (i = 0;i < 10;i++)
137 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
138 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
141 sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
142 sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
144 sb_colon = Sbar_NewPic ("gfx/num_colon");
145 sb_slash = Sbar_NewPic ("gfx/num_slash");
147 if (gamemode == GAME_SOM)
149 somsb_health = Sbar_NewPic("gfx/hud_health");
150 somsb_ammo[0] = Sbar_NewPic("gfx/sb_shells");
151 somsb_ammo[1] = Sbar_NewPic("gfx/sb_nails");
152 somsb_ammo[2] = Sbar_NewPic("gfx/sb_rocket");
153 somsb_ammo[3] = Sbar_NewPic("gfx/sb_cells");
154 somsb_armor[0] = Sbar_NewPic("gfx/sb_armor1");
155 somsb_armor[1] = Sbar_NewPic("gfx/sb_armor2");
156 somsb_armor[2] = Sbar_NewPic("gfx/sb_armor3");
158 else if (gamemode == GAME_NEXUIZ)
160 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
161 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
162 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
163 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
165 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
166 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
167 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
168 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
170 sb_sbar = Sbar_NewPic("gfx/sbar");
171 sb_sbar_minimal = Sbar_NewPic("gfx/sbar_minimal");
172 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
174 for(i = 0; i < 9;i++)
175 sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
179 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
180 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
181 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
182 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
183 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
184 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
185 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
187 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
188 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
189 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
190 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
191 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
192 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
193 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
195 for (i = 0;i < 5;i++)
197 sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
198 sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
199 sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
200 sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
201 sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
202 sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
203 sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
206 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
207 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
208 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
209 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
211 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
212 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
213 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
215 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
216 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
217 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
218 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
219 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
220 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
222 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
223 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
224 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
225 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
227 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
228 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
229 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
230 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
231 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
232 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
233 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
234 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
235 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
236 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
238 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
239 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
240 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
241 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
243 sb_sbar = Sbar_NewPic ("gfx/sbar");
244 sb_ibar = Sbar_NewPic ("gfx/ibar");
245 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
247 //MED 01/04/97 added new hipnotic weapons
248 if (gamemode == GAME_HIPNOTIC)
250 hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
251 hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
252 hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
253 hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
254 hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
256 hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
257 hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
258 hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
259 hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
260 hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
262 for (i = 0;i < 5;i++)
264 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
265 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
266 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
267 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
268 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
271 hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
272 hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
274 else if (gamemode == GAME_ROGUE)
276 rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
277 rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
279 rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
280 rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
281 rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
282 rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
283 rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
285 rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
286 rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
288 // PGM 01/19/97 - team color border
289 rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
290 // PGM 01/19/97 - team color border
292 rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
293 rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
294 rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
299 void sbar_shutdown(void)
303 void sbar_newmap(void)
307 void Sbar_Init (void)
309 Cmd_AddCommand ("+showscores", Sbar_ShowScores);
310 Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
311 Cvar_RegisterVariable (&showfps);
312 Cvar_RegisterVariable (&sbar_alpha);
314 R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
318 //=============================================================================
320 // drawing routines are relative to the status bar location
329 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
331 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha.value, 0);
334 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
336 DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha * sbar_alpha.value, 0);
343 Draws one solid graphics character
346 void Sbar_DrawCharacter (int x, int y, int num)
348 DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
356 void Sbar_DrawString (int x, int y, char *str)
358 DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
366 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
371 l = sprintf(str, "%i", num);
385 Sbar_DrawPic (x, y, sb_nums[color][frame]);
398 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
403 l = sprintf(str, "%i", num);
408 x += (digits-l) * lettersize;
417 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha.value,flags);
424 //=============================================================================
432 static int fragsort[MAX_SCOREBOARD];
433 static int scoreboardlines;
434 void Sbar_SortFrags (void)
440 for (i=0 ; i<cl.maxclients ; i++)
442 if (cl.scores[i].name[0])
444 fragsort[scoreboardlines] = i;
449 for (i=0 ; i<scoreboardlines ; i++)
450 for (j=0 ; j<scoreboardlines-1-i ; j++)
451 if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
454 fragsort[j] = fragsort[j+1];
464 void Sbar_SoloScoreboard (void)
467 int minutes, seconds, tens, units;
470 sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
471 Sbar_DrawString (8, 4, str);
473 sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
474 Sbar_DrawString (8, 12, str);
477 minutes = cl.time / 60;
478 seconds = cl.time - 60*minutes;
480 units = seconds - 10*tens;
481 sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
482 Sbar_DrawString (184, 4, str);
485 l = strlen (cl.levelname);
486 Sbar_DrawString (232 - l*4, 12, cl.levelname);
494 void Sbar_DrawScoreboard (void)
496 Sbar_SoloScoreboard ();
497 if (cl.gametype == GAME_DEATHMATCH)
498 Sbar_DeathmatchOverlay ();
501 //=============================================================================
503 // AK to make DrawInventory smaller
504 static void Sbar_DrawWeapon(int nr, float fade, int active)
506 // width = 300, height = 100
507 const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
508 const float w_scale = 0.4;
510 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);
511 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);
514 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);
522 void Sbar_DrawInventory (void)
529 if (gamemode == GAME_ROGUE)
531 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
532 Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
534 Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
537 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
540 for (i=0 ; i<7 ; i++)
542 if (cl.items & (IT_SHOTGUN<<i) )
544 time = cl.item_gettime[i];
545 flashon = (int)((cl.time - time)*10);
548 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
554 flashon = (flashon%5) + 2;
556 Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
562 if (gamemode == GAME_HIPNOTIC)
564 int grenadeflashing=0;
565 for (i=0 ; i<4 ; i++)
567 if (cl.items & (1<<hipweapons[i]) )
569 time = cl.item_gettime[hipweapons[i]];
570 flashon = (int)((cl.time - time)*10);
573 if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
579 flashon = (flashon%5) + 2;
581 // check grenade launcher
584 if (cl.items & HIT_PROXIMITY_GUN)
589 Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
595 if (cl.items & (IT_SHOTGUN<<4))
597 if (!grenadeflashing)
598 Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
601 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
604 Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
609 if (gamemode == GAME_ROGUE)
611 // check for powered up weapon.
612 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
614 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
615 Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
619 for (i=0 ; i<4 ; i++)
621 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
623 Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
625 Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
627 Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
631 for (i=0 ; i<6 ; i++)
632 if (cl.items & (1<<(17+i)))
634 //MED 01/04/97 changed keys
635 if (gamemode != GAME_HIPNOTIC || (i>1))
636 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
639 //MED 01/04/97 added hipnotic items
641 if (gamemode == GAME_HIPNOTIC)
643 for (i=0 ; i<2 ; i++)
644 if (cl.items & (1<<(24+i)))
645 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
648 if (gamemode == GAME_ROGUE)
651 for (i=0 ; i<2 ; i++)
652 if (cl.items & (1<<(29+i)))
653 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
658 for (i=0 ; i<4 ; i++)
659 if (cl.items & (1<<(28+i)))
660 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
664 //=============================================================================
671 void Sbar_DrawFrags (void)
681 l = scoreboardlines <= 4 ? scoreboardlines : 4;
685 for (i = 0;i < l;i++)
693 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
694 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);
695 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
696 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);
700 sprintf (num, "%3i",f);
702 Sbar_DrawCharacter (x + 8, -24, num[0]);
703 Sbar_DrawCharacter (x + 16, -24, num[1]);
704 Sbar_DrawCharacter (x + 24, -24, num[2]);
706 if (k == cl.viewentity - 1)
708 Sbar_DrawCharacter ( x + 2, -24, 16);
709 Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
715 //=============================================================================
723 void Sbar_DrawFace (void)
727 // PGM 01/19/97 - team color drawing
728 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
729 if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
735 s = &cl.scores[cl.viewentity - 1];
737 Sbar_DrawPic (112, 0, rsb_teambord);
738 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
739 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);
740 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
741 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);
745 sprintf (num, "%3i",f);
747 if ((s->colors & 0xf0)==0)
750 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
752 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
754 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
758 Sbar_DrawCharacter ( 109, 3, num[0]);
759 Sbar_DrawCharacter ( 116, 3, num[1]);
760 Sbar_DrawCharacter ( 123, 3, num[2]);
765 // PGM 01/19/97 - team color drawing
767 if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
768 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
769 else if (cl.items & IT_QUAD)
770 Sbar_DrawPic (112, 0, sb_face_quad );
771 else if (cl.items & IT_INVISIBILITY)
772 Sbar_DrawPic (112, 0, sb_face_invis );
773 else if (cl.items & IT_INVULNERABILITY)
774 Sbar_DrawPic (112, 0, sb_face_invuln);
777 f = cl.stats[STAT_HEALTH] / 20;
779 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
783 void Sbar_ShowFPS(void)
789 float fps_x, fps_y, fps_scalex, fps_scaley;
790 if (showfps.integer > 1)
792 static double currtime, frametimes[32];
793 double newtime, total;
795 static int framecycle = 0;
797 newtime = Sys_DoubleTime();
798 frametimes[framecycle] = newtime - currtime;
801 while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
803 total += frametimes[i];
808 if (showfps.integer == 2)
809 calc = (int) (((double) count / total) + 0.5);
810 else // showfps 3, rapid update
811 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
816 static double nexttime = 0, lasttime = 0;
817 static int framerate = 0, framecount = 0;
819 newtime = Sys_DoubleTime();
820 if (newtime < nexttime)
824 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
826 nexttime = lasttime + 0.2;
831 sprintf(temp, "%4i", calc);
834 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
835 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
836 if (fps_y > vid.conheight - fps_scaley)
837 fps_y = vid.conheight - fps_scaley;
838 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
839 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
848 void Sbar_Draw (void)
850 if (scr_con_current == vid.conheight)
851 return; // console is full screen
853 if (cl.intermission == 1)
855 Sbar_IntermissionOverlay();
858 else if (cl.intermission == 2)
860 Sbar_FinaleOverlay();
864 if (gamemode == GAME_SOM)
866 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
867 Sbar_DrawScoreboard ();
870 // this is the top left of the sbar area
872 sbar_y = vid.conheight - 24*3;
875 if (cl.stats[STAT_ARMOR])
877 if (cl.items & IT_ARMOR3)
878 Sbar_DrawPic(0, 0, somsb_armor[2]);
879 else if (cl.items & IT_ARMOR2)
880 Sbar_DrawPic(0, 0, somsb_armor[1]);
881 else if (cl.items & IT_ARMOR1)
882 Sbar_DrawPic(0, 0, somsb_armor[0]);
883 Sbar_DrawNum(24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
887 Sbar_DrawPic(0, 24, somsb_health);
888 Sbar_DrawNum(24, 24, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
891 if (cl.items & IT_SHELLS)
892 Sbar_DrawPic(0, 48, somsb_ammo[0]);
893 else if (cl.items & IT_NAILS)
894 Sbar_DrawPic(0, 48, somsb_ammo[1]);
895 else if (cl.items & IT_ROCKETS)
896 Sbar_DrawPic(0, 48, somsb_ammo[2]);
897 else if (cl.items & IT_CELLS)
898 Sbar_DrawPic(0, 48, somsb_ammo[3]);
899 Sbar_DrawNum(24, 48, cl.stats[STAT_AMMO], 3, false);
900 if (cl.stats[STAT_SHELLS])
901 Sbar_DrawNum(24 + 3*24, 48, cl.stats[STAT_SHELLS], 1, true);
904 else if (gamemode == GAME_NEXUIZ)
906 sbar_y = vid.conheight - 47;
907 sbar_x = (vid.conwidth - 640)/2;
909 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
911 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
912 Sbar_DrawScoreboard ();
920 // we have a max time 2s (min time = 0)
921 if ((time = cl.time - cl.weapontime) < 2)
923 fade = (1.0 - 0.5 * time);
925 for (i = 0; i < 8;i++)
927 if (!(cl.items & (1 << i)))
929 Sbar_DrawWeapon(i + 1, fade, (i == cl.stats[STAT_ACTIVEWEAPON]));
932 if((cl.items & (1<<12)))
933 Sbar_DrawWeapon(0, fade, (cl.stats[STAT_ACTIVEWEAPON] == 12));
940 Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha.value);
942 Sbar_DrawAlphaPic (0, 0, sb_sbar_minimal, sbar_alpha.value);
945 if (cl.items & IT_INVULNERABILITY)
947 Sbar_DrawNum (36, 0, 666, 3, 1);
948 Sbar_DrawPic (0, 0, sb_disc);
952 Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
955 if(cl.stats[STAT_HEALTH] > 100)
956 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
957 else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
958 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
960 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
962 // AK dont draw ammo for the laser
963 if(cl.stats[STAT_ACTIVEWEAPON] != 12)
965 if (cl.items & NEX_IT_SHELLS)
966 Sbar_DrawPic (519, 0, sb_ammo[0]);
967 else if (cl.items & NEX_IT_BULLETS)
968 Sbar_DrawPic (519, 0, sb_ammo[1]);
969 else if (cl.items & NEX_IT_ROCKETS)
970 Sbar_DrawPic (519, 0, sb_ammo[2]);
971 else if (cl.items & NEX_IT_CELLS)
972 Sbar_DrawPic (519, 0, sb_ammo[3]);
974 if(cl.stats[STAT_AMMO] <= 10)
975 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
977 Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
982 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
985 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
986 Sbar_MiniDeathmatchOverlay (0, 0);
988 else // Quake and others
990 sbar_y = vid.conheight - SBAR_HEIGHT;
991 if (cl.gametype == GAME_DEATHMATCH)
994 sbar_x = (vid.conwidth - 320)/2;
998 if (gamemode != GAME_GOODVSBAD2)
999 Sbar_DrawInventory ();
1000 if (!cl.islocalgame)
1004 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
1006 if (gamemode != GAME_GOODVSBAD2)
1007 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
1008 Sbar_DrawScoreboard ();
1012 Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
1014 // keys (hipnotic only)
1015 //MED 01/04/97 moved keys here so they would not be overwritten
1016 if (gamemode == GAME_HIPNOTIC)
1018 if (cl.items & IT_KEY1)
1019 Sbar_DrawPic (209, 3, sb_items[0]);
1020 if (cl.items & IT_KEY2)
1021 Sbar_DrawPic (209, 12, sb_items[1]);
1024 if (gamemode != GAME_GOODVSBAD2)
1026 if (cl.items & IT_INVULNERABILITY)
1028 Sbar_DrawNum (24, 0, 666, 3, 1);
1029 Sbar_DrawPic (0, 0, sb_disc);
1033 if (gamemode == GAME_ROGUE)
1035 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1036 if (cl.items & RIT_ARMOR3)
1037 Sbar_DrawPic (0, 0, sb_armor[2]);
1038 else if (cl.items & RIT_ARMOR2)
1039 Sbar_DrawPic (0, 0, sb_armor[1]);
1040 else if (cl.items & RIT_ARMOR1)
1041 Sbar_DrawPic (0, 0, sb_armor[0]);
1045 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1046 if (cl.items & IT_ARMOR3)
1047 Sbar_DrawPic (0, 0, sb_armor[2]);
1048 else if (cl.items & IT_ARMOR2)
1049 Sbar_DrawPic (0, 0, sb_armor[1]);
1050 else if (cl.items & IT_ARMOR1)
1051 Sbar_DrawPic (0, 0, sb_armor[0]);
1060 Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1063 if (gamemode == GAME_ROGUE)
1065 if (cl.items & RIT_SHELLS)
1066 Sbar_DrawPic (224, 0, sb_ammo[0]);
1067 else if (cl.items & RIT_NAILS)
1068 Sbar_DrawPic (224, 0, sb_ammo[1]);
1069 else if (cl.items & RIT_ROCKETS)
1070 Sbar_DrawPic (224, 0, sb_ammo[2]);
1071 else if (cl.items & RIT_CELLS)
1072 Sbar_DrawPic (224, 0, sb_ammo[3]);
1073 else if (cl.items & RIT_LAVA_NAILS)
1074 Sbar_DrawPic (224, 0, rsb_ammo[0]);
1075 else if (cl.items & RIT_PLASMA_AMMO)
1076 Sbar_DrawPic (224, 0, rsb_ammo[1]);
1077 else if (cl.items & RIT_MULTI_ROCKETS)
1078 Sbar_DrawPic (224, 0, rsb_ammo[2]);
1082 if (cl.items & IT_SHELLS)
1083 Sbar_DrawPic (224, 0, sb_ammo[0]);
1084 else if (cl.items & IT_NAILS)
1085 Sbar_DrawPic (224, 0, sb_ammo[1]);
1086 else if (cl.items & IT_ROCKETS)
1087 Sbar_DrawPic (224, 0, sb_ammo[2]);
1088 else if (cl.items & IT_CELLS)
1089 Sbar_DrawPic (224, 0, sb_ammo[3]);
1092 Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1096 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1097 Sbar_MiniDeathmatchOverlay (324, vid.conheight - sb_lines);
1102 R_Draw2DCrosshair();
1105 //=============================================================================
1109 Sbar_DeathmatchOverlay
1113 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1116 if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1118 // draw colors behind score
1119 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1120 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);
1121 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1122 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);
1124 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);
1131 void Sbar_DeathmatchOverlay (void)
1136 pic = Draw_CachePic ("gfx/ranking.lmp");
1137 DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1142 x = (vid.conwidth - (6 + 15) * 8) / 2;
1144 for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1145 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1150 Sbar_DeathmatchOverlay
1154 void Sbar_MiniDeathmatchOverlay (int x, int y)
1158 // decide where to print
1160 numlines = (vid.conheight - y) / 8;
1161 // give up if there isn't room
1162 if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1169 for (i = 0; i < scoreboardlines; i++)
1170 if (fragsort[i] == cl.playerentity - 1)
1173 if (i == scoreboardlines) // we're not there
1175 else // figure out start
1178 i = bound(0, i, scoreboardlines - numlines);
1181 for (;i < scoreboardlines && y < vid.conheight;i++)
1182 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1187 Sbar_IntermissionOverlay
1191 void Sbar_IntermissionOverlay (void)
1196 if (cl.gametype == GAME_DEATHMATCH)
1198 Sbar_DeathmatchOverlay ();
1202 sbar_x = (vid.conwidth - 320) >> 1;
1203 sbar_y = (vid.conheight - 200) >> 1;
1205 DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1206 DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1209 dig = cl.completed_time/60;
1210 Sbar_DrawNum (160, 64, dig, 3, 0);
1211 num = cl.completed_time - dig*60;
1212 Sbar_DrawPic (234,64,sb_colon);
1213 Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1214 Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1216 Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1217 Sbar_DrawPic (232, 104, sb_slash);
1218 Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1220 Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1221 Sbar_DrawPic (232, 144, sb_slash);
1222 Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1233 void Sbar_FinaleOverlay (void)
1237 pic = Draw_CachePic ("gfx/finale.lmp");
1238 DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);