6 float sbar_hudselector;
8 float ps_primary, ps_secondary;
9 float ts_primary, ts_secondary;
12 vector element_offset = '0 6 0'; // global item offset from the bottom edge
18 void Sbar_FinaleOverlay()
21 pos_x = (vid_conwidth - 1)/2;
25 //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
27 //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
31 float weaponspace[10];
32 float weapon_first, weapon_last;
33 void Sbar_DrawWeapon_Clear()
38 for(idx = 0; idx < 10; ++idx)
40 for(idx = 0; idx <= 23; ++idx)
42 if(weaponimpulse[idx] >= 0)
50 void Sbar_DrawWeapon(float nr, float fade, float active)
53 float value, idx, imp, sp;
55 imp = weaponimpulse[nr];
61 value = (active) ? 1 : 0.6;
62 color_x = color_y = color_z = value;
64 // width = 300, height = 100
65 const float w_width = 25, w_height = 12, w_space = 2, font_size = 8;
67 sp = weaponspace[idx] + 1;
68 weaponspace[idx] = sp;
70 pos_x = (vid_conwidth + 10 - w_width * 9) * 0.5 + w_width * idx;
71 pos_y = (vid_conheight - w_height * sp) - 38; // move 38 pixels up
77 drawpic(pos, "gfx/hud/sb_ammobg", vsize, color, value * fade * sbar_alpha_fg, 0);
78 drawpic(pos, strcat("gfx/hud/inv_weapon", ftos(nr)), vsize, color, value * fade * sbar_alpha_fg, 0);
84 drawstring(pos, ftos(imp), vsize, '1 1 1', sbar_alpha_fg, 0);
87 void Sbar_DrawXNum (vector pos, float num, float digits, float lettersize, vector rgb, float highlighted, float a, float dflags)
90 string str, tmp, l_length;
94 vsize_x = vsize_y = lettersize;
109 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
118 str = substring(str, l-digits, 999);
120 } else if(l < digits)
121 pos_x += (digits-l) * lettersize;
123 if (highlighted == 1) {
125 hl_size_x = vsize_x * l + vsize_x * 0.2;
126 hl_size_y = vsize_y * 1.1;
129 hl_size_x = hl_size_x + vsize_x;
132 hl_pos_x = pos_x - lettersize/10;
133 hl_pos_y = pos_y - lettersize/30;
136 drawpic(hl_pos, strcat("gfx/hud/sb_highlight_", l_length), hl_size, '1 1 1', sbar_alpha_fg, dflags);
141 drawpic(pos, "gfx/hud/num_minus", vsize, rgb, a * sbar_alpha_fg, dflags);
145 for(i = 0; i < l; ++i)
147 drawpic(pos, strcat("gfx/hud/num_", substring(str, i, 1)), vsize, rgb, a * sbar_alpha_fg, dflags);
152 void Sbar_DrawXNum_Colored (vector pos, float x, float lettersize)
158 Sbar_DrawXNum(pos, x, 3, lettersize, color, 0, 1, 0);
161 color_x = 0.4 - ((x-150)*0.02 * 0.4); //red value between 0.4 -> 0
162 color_y = 0.9 + ((x-150)*0.02 * 0.1); // green value between 0.9 -> 1
164 Sbar_DrawXNum(pos, x, 3, lettersize, color, 0, 1, 0);
167 color_x = 0.6 - ((x-100)*0.02 * 0.2); //red value between 0.6 -> 0.4
168 color_y = 0.7 + ((x-100)*0.02 * 0.2); // green value between 0.7 -> 0.9
169 color_z = 0.8 - ((x-100)*0.02 * 0.8); // blue value between 0.8 -> 0
170 Sbar_DrawXNum(pos, x, 3, lettersize, color, 0, 1, 0);
173 color_x = 1 - ((x-50)*0.02 * 0.4); //red value between 1 -> 0.6
174 color_y = 1 - ((x-50)*0.02 * 0.3); // green value between 1 -> 0.7
175 color_z = 0.2 + ((x-50)*0.02 * 0.6); // blue value between 0.2 -> 0.8
176 Sbar_DrawXNum(pos, x, 3, lettersize, color, 0, 1, 0);
180 color_y = (x-20)*90/27/100; // green value between 0 -> 1
181 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
182 Sbar_DrawXNum(pos, x, 3, lettersize, color, 0, 1, 0);
185 Sbar_DrawXNum(pos, x, 3, lettersize, '1 0 0', 0, 1, 0);
188 void Cmd_Sbar_SetFields(float argc);
189 void Sbar_InitScores()
193 ps_primary = ps_secondary = ts_primary = ts_secondary = -1;
194 for(i = 0; i < MAX_SCORE; ++i)
196 f = (scores_flags[i] & SFL_SORT_PRIO_MASK);
197 if(f == SFL_SORT_PRIO_PRIMARY)
199 if(f == SFL_SORT_PRIO_SECONDARY)
202 if(ps_secondary == -1)
203 ps_secondary = ps_primary;
205 for(i = 0; i < MAX_TEAMSCORE; ++i)
207 f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);
208 if(f == SFL_SORT_PRIO_PRIMARY)
210 if(f == SFL_SORT_PRIO_SECONDARY)
213 if(ts_secondary == -1)
214 ts_secondary = ts_primary;
216 Cmd_Sbar_SetFields(0);
219 void Sbar_UpdatePlayerPos(entity pl);
220 float SetTeam(entity pl, float Team);
222 void Sbar_UpdatePlayerTeams()
229 for(pl = players.sort_next; pl; pl = pl.sort_next)
232 Team = GetPlayerColor(pl.sv_entnum);
233 if(SetTeam(pl, Team))
236 Sbar_UpdatePlayerPos(pl);
240 pl = players.sort_next;
245 print(strcat("PNUM: ", ftos(num), "\n"));
250 float Sbar_ComparePlayerScores(entity left, entity right)
253 vl = GetPlayerColor(left.sv_entnum);
254 vr = GetPlayerColor(right.sv_entnum);
257 vl = COLOR_SPECTATOR;
259 vr = COLOR_SPECTATOR;
266 if(vl == COLOR_SPECTATOR)
268 // FIRST the one with scores (spectators), THEN the ones without (downloaders)
270 if(!left.gotscores && right.gotscores)
275 vl = left.scores[ps_primary];
276 vr = right.scores[ps_primary];
277 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
279 if(vl == 0 && vr != 0)
281 if(vl != 0 && vr == 0)
285 return IS_INCREASING(scores_flags[ps_primary]);
287 return IS_DECREASING(scores_flags[ps_primary]);
289 vl = left.scores[ps_secondary];
290 vr = right.scores[ps_secondary];
291 if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)
293 if(vl == 0 && vr != 0)
295 if(vl != 0 && vr == 0)
299 return IS_INCREASING(scores_flags[ps_secondary]);
301 return IS_DECREASING(scores_flags[ps_secondary]);
306 void Sbar_UpdatePlayerPos(entity player)
308 for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)
310 SORT_SWAP(player, other);
312 for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)
314 SORT_SWAP(other, player);
318 float Sbar_CompareTeamScores(entity left, entity right)
322 if(left.team == COLOR_SPECTATOR)
324 if(right.team == COLOR_SPECTATOR)
327 vl = left.teamscores[ts_primary];
328 vr = right.teamscores[ts_primary];
330 return IS_INCREASING(teamscores_flags[ts_primary]);
332 return IS_DECREASING(teamscores_flags[ts_primary]);
334 vl = left.teamscores[ts_secondary];
335 vr = right.teamscores[ts_secondary];
337 return IS_INCREASING(teamscores_flags[ts_secondary]);
339 return IS_DECREASING(teamscores_flags[ts_secondary]);
344 void Sbar_UpdateTeamPos(entity Team)
346 for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)
348 SORT_SWAP(Team, other);
350 for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)
352 SORT_SWAP(other, Team);
356 void Cmd_Sbar_Help(float argc)
358 print("You can modify the scoreboard using the\n");
359 print("^3|---------------------------------------------------------------|\n");
360 print("^1 TO BE DONE\n");
362 print("^2sbar_columns_set default\n");
363 print("^2sbar_columns_set ^7filed1 field2 ...\n");
364 print("The following field names are recognized (case INsensitive):\n");
365 print("You can use a ^3|^7 to start the right-aligned fields.\n");
367 print("^3name^7 or ^3nick^7 Name of a player\n");
368 print("^3ping^7 Ping time\n\n");
369 print("^3kd^7 or ^3kdr^7 or ^3kdratio^7 or ^3k/d\n");
370 print(" The kill-death ratio\n");
372 print("Before a field you can put a + or - sign, then a comma separated list\n");
373 print("of game types, then a slash, to make the field show up only in these\n");
374 print("or in all but these game types.\n");
376 print("The special game type names 'teams' and 'noteams' can be used to\n");
377 print("include/exclude ALL teams/noteams game modes.\n");
380 print("Additional columns:\n");
381 for(i = 0; i < MAX_SCORE; ++i)
383 if(scores_label[i] != "")
384 print(strcat(scores_label[i], "\n"));
388 #define MIN_NAMELEN 24
389 #define MAX_NAMELEN 24
391 string Sbar_DefaultColumnLayout()
393 return strcat( // fteqcc sucks
395 "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"
396 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
397 "+lms/lives +lms/rank ",
398 "+/caps +kh/pushes +kh/destroyed ",
399 "?+race/laps ?+race/time ?+race/fastest ",
400 "+as/objectives +nexball/faults +nexball/goals ",
401 "-lms,race,nexball/score");
404 void Cmd_Sbar_SetFields(float argc)
409 float have_name, have_primary, have_secondary, have_separator;
412 // TODO: re enable with gametype dependant cvars?
413 if(argc < 2) // no arguments provided
414 argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");
417 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
421 if(argv(1) == "default")
422 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
423 else if(argv(1) == "all")
426 s = "ping pl color name |";
427 for(i = 0; i < MAX_SCORE; ++i)
430 if(i != ps_secondary)
431 if(scores_label[i] != "")
432 s = strcat(s, " ", scores_label[i]);
434 if(ps_secondary != ps_primary)
435 s = strcat(s, " ", scores_label[ps_secondary]);
436 s = strcat(s, " ", scores_label[ps_primary]);
437 argc = tokenizebyseparator(strcat("x ", s), " ");
444 drawfont = sbar_font;
445 digit = stringwidth("0123456789", FALSE) / 10;
447 for(i = 0; i < argc - 1; ++i)
453 if(substring(str, 0, 1) == "?")
456 str = substring(str, 1, strlen(str) - 1);
459 slash = strstrofs(str, "/", 0);
462 pattern = substring(str, 0, slash);
463 str = substring(str, slash + 1, strlen(str) - (slash + 1));
465 if not(isGametypeInFilter(gametype, teamplay, pattern))
469 strunzone(sbar_title[sbar_num_fields]);
470 sbar_title[sbar_num_fields] = strzone(str);
471 sbar_size[sbar_num_fields] = stringwidth(str, FALSE);
472 str = strtolower(str);
475 sbar_field[sbar_num_fields] = SP_PING;
476 } else if(str == "pl") {
477 sbar_field[sbar_num_fields] = SP_PL;
478 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
479 sbar_field[sbar_num_fields] = SP_KDRATIO;
480 } else if(str == "name" || str == "nick") {
481 sbar_field[sbar_num_fields] = SP_NAME;
482 sbar_size[sbar_num_fields] = MIN_NAMELEN; // minimum size? any use?
484 } else if(str == "|") {
485 sbar_field[sbar_num_fields] = SP_SEPARATOR;
488 for(j = 0; j < MAX_SCORE; ++j)
489 if(str == strtolower(scores_label[j]))
490 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
499 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
503 sbar_field[sbar_num_fields] = j;
506 if(j == ps_secondary)
510 if(sbar_num_fields >= MAX_SBAR_FIELDS)
514 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
516 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
518 if(ps_primary == ps_secondary)
520 missing = !have_primary + !have_secondary + !have_separator + !have_name;
522 if(sbar_num_fields+missing < MAX_SBAR_FIELDS)
526 strunzone(sbar_title[sbar_num_fields]);
527 for(i = sbar_num_fields; i > 0; --i)
529 sbar_title[i] = sbar_title[i-1];
530 sbar_size[i] = sbar_size[i-1];
531 sbar_field[i] = sbar_field[i-1];
533 sbar_title[0] = strzone("name");
534 sbar_field[0] = SP_NAME;
535 sbar_size[0] = MIN_NAMELEN; // minimum size? any use?
537 print("fixed missing field 'name'\n");
541 strunzone(sbar_title[sbar_num_fields]);
542 for(i = sbar_num_fields; i > 1; --i)
544 sbar_title[i] = sbar_title[i-1];
545 sbar_size[i] = sbar_size[i-1];
546 sbar_field[i] = sbar_field[i-1];
548 sbar_title[1] = strzone("|");
549 sbar_field[1] = SP_SEPARATOR;
550 sbar_size[1] = stringwidth("|", FALSE);
552 print("fixed missing field '|'\n");
555 else if(!have_separator)
557 strunzone(sbar_title[sbar_num_fields]);
558 sbar_title[sbar_num_fields] = strzone("|");
559 sbar_size[sbar_num_fields] = stringwidth("|", FALSE);
560 sbar_field[sbar_num_fields] = SP_SEPARATOR;
562 print("fixed missing field '|'\n");
567 strunzone(sbar_title[sbar_num_fields]);
568 sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);
569 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
570 sbar_field[sbar_num_fields] = ps_secondary;
572 print("fixed missing field '", scores_label[ps_secondary], "'\n");
577 strunzone(sbar_title[sbar_num_fields]);
578 sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);
579 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
580 sbar_field[sbar_num_fields] = ps_primary;
582 print("fixed missing field '", scores_label[ps_primary], "'\n");
586 sbar_field[sbar_num_fields] = SP_END;
590 vector sbar_field_rgb;
591 string sbar_field_icon0;
592 string sbar_field_icon1;
593 string sbar_field_icon2;
594 vector sbar_field_icon0_rgb;
595 vector sbar_field_icon1_rgb;
596 vector sbar_field_icon2_rgb;
597 float sbar_field_icon0_alpha;
598 float sbar_field_icon1_alpha;
599 float sbar_field_icon2_alpha;
600 string Sbar_GetField(entity pl, float field)
602 float tmp, num, denom, f;
604 sbar_field_rgb = '1 1 1';
605 sbar_field_icon0 = "";
606 sbar_field_icon1 = "";
607 sbar_field_icon2 = "";
608 sbar_field_icon0_rgb = '1 1 1';
609 sbar_field_icon1_rgb = '1 1 1';
610 sbar_field_icon2_rgb = '1 1 1';
611 sbar_field_icon0_alpha = 1;
612 sbar_field_icon1_alpha = 1;
613 sbar_field_icon2_alpha = 1;
618 return "\x8D\x8D\x8D"; // >>> sign
619 str = getplayerkey(pl.sv_entnum, "ping");
622 tmp = max(0, min(220, stof(str)-80)) / 220;
623 sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
629 str = getplayerkey(pl.sv_entnum, "pl");
632 tmp = bound(0, stof(str), 20) / 20; // 20% is REALLY BAD pl
633 sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
637 if(ready_waiting && pl.ready)
639 sbar_field_icon0 = "gfx/sb_player_ready";
643 f = stof(getplayerkey(pl.sv_entnum, "colors"));
645 sbar_field_icon0 = "gfx/sb_playercolor_base";
646 sbar_field_icon1 = "gfx/sb_playercolor_shirt";
647 sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
648 sbar_field_icon2 = "gfx/sb_playercolor_pants";
649 sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
652 return GetPlayerName(pl.sv_entnum);
655 f = pl.(scores[SP_KILLS]);
656 f -= pl.(scores[SP_SUICIDES]);
660 num = pl.(scores[SP_KILLS]);
661 denom = pl.(scores[SP_DEATHS]);
664 sbar_field_rgb = '0 1 0';
666 } else if(num <= 0) {
667 sbar_field_rgb = '1 0 0';
668 str = ftos(num/denom);
670 str = ftos(num/denom);
672 tmp = strstrofs(str, ".", 0);
674 str = substring(str, 0, tmp+2);
678 tmp = pl.(scores[field]);
679 f = scores_flags[field];
680 if(field == ps_primary)
681 sbar_field_rgb = '1 1 0';
682 else if(field == ps_secondary)
683 sbar_field_rgb = '0 1 1';
685 sbar_field_rgb = '1 1 1';
686 return ScoreString(f, tmp);
691 float xmin, xmax, ymin, ymax, sbwidth;
692 float sbar_fixscoreboardcolumnwidth_len;
693 float sbar_fixscoreboardcolumnwidth_iconlen;
694 float sbar_fixscoreboardcolumnwidth_marginlen;
696 float stringwidth_colors(string s)
698 return stringwidth(s, TRUE);
701 float stringwidth_nocolors(string s)
703 return stringwidth(s, FALSE);
706 string Sbar_FixScoreboardColumnWidth(float i, string str)
708 float field, maxsize, j, f;
710 field = sbar_field[i];
712 if(field == SP_NAME) // name gets all remaining space
714 maxsize = (xmax - xmin) / sbar_fontsize_x;
715 for(j = 0; j < sbar_num_fields; ++j) if(j != i) if(sbar_field[j] != SP_SEPARATOR)
716 maxsize -= sbar_size[j] + 1;
718 str = textShortenToWidth(str, maxsize, stringwidth_colors);
719 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE);
722 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE);
724 sbar_fixscoreboardcolumnwidth_iconlen = 0;
726 if(sbar_field_icon0 != "")
728 sz = drawgetimagesize(sbar_field_icon0);
730 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
731 sbar_fixscoreboardcolumnwidth_iconlen = f;
734 if(sbar_field_icon1 != "")
736 sz = drawgetimagesize(sbar_field_icon1);
738 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
739 sbar_fixscoreboardcolumnwidth_iconlen = f;
742 if(sbar_field_icon2 != "")
744 sz = drawgetimagesize(sbar_field_icon2);
746 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
747 sbar_fixscoreboardcolumnwidth_iconlen = f;
750 sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect
752 if(sbar_fixscoreboardcolumnwidth_iconlen != 0 && sbar_fixscoreboardcolumnwidth_len != 0)
753 sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE);
755 sbar_fixscoreboardcolumnwidth_marginlen = 0;
757 f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
764 void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self)
770 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
777 tmp_y = sbar_fontsize_y;
778 drawfill(pos - '1 1 0', tmp + '2 2 0', '1 1 1', 0.3, DRAWFLAG_NORMAL);
782 for(i = 0; i < sbar_num_fields; ++i)
784 field = sbar_field[i];
785 if(field == SP_SEPARATOR)
788 if(is_spec && field != SP_NAME && field != SP_PING) {
789 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
792 str = Sbar_GetField(pl, field);
793 str = Sbar_FixScoreboardColumnWidth(i, str);
795 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
797 if(field == SP_NAME) {
798 tmp_x = sbar_fontsize_x*(sbar_size[i] - sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen) + sbar_fontsize_x;
799 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
801 tmp_x = sbar_fixscoreboardcolumnwidth_len*sbar_fontsize_x + sbar_fontsize_x;
802 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
805 tmp_x = sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
806 if(sbar_field_icon0 != "")
807 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha, 0);
808 if(sbar_field_icon1 != "")
809 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha, 0);
810 if(sbar_field_icon2 != "")
811 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha, 0);
814 if(sbar_field[i] == SP_SEPARATOR)
817 for(i = sbar_num_fields-1; i > 0; --i)
819 field = sbar_field[i];
820 if(field == SP_SEPARATOR)
823 if(is_spec && field != SP_NAME && field != SP_PING) {
824 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
828 str = Sbar_GetField(pl, field);
829 str = Sbar_FixScoreboardColumnWidth(i, str);
831 if(field == SP_NAME) {
832 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
833 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
835 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; //strlen(str);
836 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
839 tmp_x = sbar_fontsize_x*sbar_size[i];
840 if(sbar_field_icon0 != "")
841 drawpic(pos - tmp, sbar_field_icon0, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon0_alpha, 0);
842 if(sbar_field_icon1 != "")
843 drawpic(pos - tmp, sbar_field_icon1, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon1_rgb, sbar_field_icon1_alpha, 0);
844 if(sbar_field_icon2 != "")
845 drawpic(pos - tmp, sbar_field_icon2, '0 1 0' * sbar_fontsize_y + '1 0 0' * sbar_fontsize_x * sbar_fixscoreboardcolumnwidth_iconlen, sbar_field_icon2_rgb, sbar_field_icon2_alpha, 0);
847 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
853 float scoreboard_bottom;
854 void Sbar_DrawScoreboard()
856 //float xmin, ymin, xmax, ymax;
857 vector rgb, pos, tmp, sbar_save;
862 if(time > lastpingstime + 10)
865 lastpingstime = time;
868 sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);
870 xmin = 0.5 * (vid_conwidth - sbwidth);
873 xmax = vid_conwidth - xmin;
874 ymax = vid_conheight - 0.2*vid_conheight;
876 center_x = xmin + 0.5*sbwidth;
878 //Sbar_UpdateFields();
880 // Initializes position
886 drawfont = sbar_bigfont;
887 pos_x = center_x - stringwidth("Scoreboard", TRUE)*0.5*24;
888 drawstring(pos, "Scoreboard", '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
892 // Titlebar background:
894 tmp_y = sbar_fontsize_y;
895 drawfill(pos - '1 1 0', tmp + '2 2 0', '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
897 drawfont = sbar_font;
899 for(i = 0; i < sbar_num_fields; ++i)
901 if(sbar_field[i] == SP_SEPARATOR)
903 drawstring(pos, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
904 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
907 if(sbar_field[i] == SP_SEPARATOR)
909 pos_x = xmax + sbar_fontsize_x;
911 for(i = sbar_num_fields-1; i > 0; --i)
913 if(sbar_field[i] == SP_SEPARATOR)
916 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
919 * Using the following line will mess it all up:
921 * tmp_x = sbar_size[i] - strlen(sbar_title[i])*8;
923 tmp_x = sbar_fontsize_x*sbar_size[i];
924 tmp_x -= stringwidth(sbar_title[i], FALSE)*sbar_fontsize_x;
925 drawstring(pos + tmp, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
930 pos_y += 1.5 * sbar_fontsize_y;
937 //for(tm = sortedTeams.sort_next; tm; tm = tm.sort_next)
938 for(tm = teams.sort_next; tm; tm = tm.sort_next)
940 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
943 rgb = GetTeamRGB(tm.team);
947 Sbar_DrawXNum(sbar + pos - '6.5 0 0' * sbar_fontsize_y, tm.(teamscores[ts_primary]), 4, sbar_fontsize_y * 1.5, rgb, 0, 1, DRAWFLAG_NORMAL);
949 if(ts_primary != ts_secondary)
950 Sbar_DrawXNum(sbar + pos - '4.5 0 0' * sbar_fontsize_y + '0 1.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 4, sbar_fontsize_y * 1, rgb, 0, 1, DRAWFLAG_NORMAL);
952 specs = tm.team_size;
958 tmp_y = 1.25 * sbar_fontsize_y * specs;
959 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, 0.2, DRAWFLAG_NORMAL);
961 for(pl = players.sort_next; pl; pl = pl.sort_next)
963 if(pl.team != tm.team)
965 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
966 pos_y += 1.25 * sbar_fontsize_y;
967 tmp_y -= 1.25 * sbar_fontsize_y;
969 pos_y += tmp_y + 1.5 * sbar_fontsize_y;
971 // rgb := tempvector :)
972 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
973 pos_y += 3 * sbar_fontsize_y;
975 for(pl = players.sort_next; pl; pl = pl.sort_next)
977 if(pl.team != COLOR_SPECTATOR)
979 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
980 pos += '0 1.25 0' * sbar_fontsize_y;
985 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
988 for(pl = players.sort_next; pl; pl = pl.sort_next)
990 if(pl.team == COLOR_SPECTATOR)
992 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
993 pos_y += 1.25 * sbar_fontsize_y;
994 tmp_y -= 1.25 * sbar_fontsize_y;
997 // rgb := tempvector :)
998 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
999 pos_y += 3 * sbar_fontsize_y;
1001 for(pl = players.sort_next; pl; pl = pl.sort_next)
1003 if(pl.team != COLOR_SPECTATOR)
1005 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
1006 pos += '0 1.25 0' * sbar_fontsize_y;
1011 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
1016 str = strcat("playing on ^2", shortmapname, "^7");
1017 tl = getstatf(STAT_TIMELIMIT);
1018 fl = getstatf(STAT_FRAGLIMIT);
1019 if(gametype == GAME_LMS)
1022 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
1027 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
1031 str = strcat(str, " or");
1034 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
1035 if(teamscores_label[ts_primary] == "score")
1036 str = strcat(str, " points^7");
1037 else if(teamscores_label[ts_primary] == "fastest")
1038 str = strcat(str, " is beaten^7");
1040 str = strcat(str, " ", teamscores_label[ts_primary]);
1044 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
1045 if(scores_label[ps_primary] == "score")
1046 str = strcat(str, " points^7");
1047 else if(scores_label[ps_primary] == "fastest")
1048 str = strcat(str, " is beaten^7");
1050 str = strcat(str, " ", scores_label[ps_primary]);
1056 pos_y += 1.2 * sbar_fontsize_y;
1057 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, 0);
1060 scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;
1063 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
1071 if(histime == 0) // goal hit
1075 timestr = strcat("+", ftos_decimals(+mytime, 1));
1078 else if(mytime == 0)
1085 timestr = strcat("-", ftos_decimals(-mytime, 1));
1091 lapstr = strcat(" (-", ftos(lapdelta), "L)");
1094 else if(lapdelta < 0)
1096 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
1100 else if(histime > 0) // anticipation
1102 if(mytime >= histime)
1103 timestr = strcat("+", ftos_decimals(mytime - histime, 1));
1105 timestr = mmsss(histime * 10);
1112 cpname = strcat("Intermediate ", ftos(cp));
1114 cpname = "Finish line";
1117 return strcat(col, cpname);
1118 else if(hisname == "")
1119 return strcat(col, cpname, " (", timestr, ")");
1121 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
1124 void Sbar_Score(float margin)
1126 float timelimit, minutes, seconds, timeleft, minutesLeft, secondsLeft, distribution, myplace, score, desiredPlayerId;
1127 vector sbar_save, place, timer_color, offset;
1132 bottomright_x = vid_conwidth;
1133 bottomright_y = vid_conheight;
1137 topright_x = vid_conwidth;
1141 sbar_alpha_bg = cvar("sbar_alpha_bg");
\r
1142 //get the ID (could be "me", or the player I'm spectating)
\r
1143 desiredPlayerId = player_localentnum - 1;
\r
1144 if (spectatee_status) {
\r
1145 if (spectatee_status != -1) {
\r
1146 desiredPlayerId = spectatee_status - 1;
\r
1150 myteam = GetPlayerColor(desiredPlayerId);
1152 sbar_y = vid_conheight - (32+12);
1161 // team1 team3 team4
1164 //for(i = 0; i < 4; ++i)
1165 if (cvar("vid_conwidth") >= 800) {
1175 float max_fragcount;
1176 max_fragcount = -999;
1178 for(tm = teams.sort_next; tm; tm = tm.sort_next)
1180 if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
1183 score = tm.(teamscores[ts_primary]);
1185 if (score > max_fragcount)
1186 max_fragcount = score;
1188 if(tm.team == myteam) {
1189 if (max_fragcount == score)
1190 Sbar_DrawXNum(bottomright - element_offset - place, score, 4, 34, GetTeamRGB(tm.team) * 0.8, 1, 1, DRAWFLAG_NORMAL);
1192 Sbar_DrawXNum(bottomright - element_offset - place, score, 4, 34, GetTeamRGB(tm.team) * 0.8, 0, 1, DRAWFLAG_NORMAL);
1196 if (max_fragcount == score)
1197 Sbar_DrawXNum(bottomright - element_offset - place + '132 -6 0' - offset, score, 4, 16, GetTeamRGB(tm.team) * 0.8, 1, 1, DRAWFLAG_NORMAL);
1199 Sbar_DrawXNum(bottomright - element_offset - place + '132 -6 0' - offset, score, 4, 16, GetTeamRGB(tm.team) * 0.8, 0, 1, DRAWFLAG_NORMAL);
1204 // me vector := [team/connected frags id]
1207 for(me = players.sort_next; me; me = me.sort_next)
1209 if(me.team != COLOR_SPECTATOR)
1211 if(me.sv_entnum == desiredPlayerId)
1215 pl = players.sort_next;
1220 distribution = me.(scores[ps_primary]);
1221 distribution -= pl.(scores[ps_primary]);
1225 if (cvar("vid_conwidth") >= 800) {
1230 else { // move the scores if vid_conwidth < 800
1234 score = me.(scores[ps_primary]);
1236 if(distribution >= 0)
1238 if (distribution != 0) {
1239 // draw a + sign in front of the score
1240 if (distribution < 10) { drawpic(bottomright - element_offset - place + '132 -5 0' + '32 0 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
1241 else if (distribution < 100) { drawpic(bottomright - element_offset - place + '132 -5 0' + '16 0 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
1242 else if (distribution < 1000) { drawpic(bottomright - element_offset - place + '132 -5 0', "gfx/hud/num_plus", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE); }
1245 Sbar_DrawXNum(bottomright - element_offset - place + '132 -6 0', distribution, 4, 16, ' 1 1 1', 0, 1, DRAWFLAG_NORMAL);
1246 Sbar_DrawXNum(bottomright - element_offset - place, score, 4, 34, '1 1 1', 1, 1, DRAWFLAG_NORMAL);
1248 else if(distribution >= -5)
1250 Sbar_DrawXNum(bottomright - element_offset - place + '132 -6 0', distribution, 4, 16, ' 1 1 0', 0, 1, DRAWFLAG_NORMAL);
1251 Sbar_DrawXNum(bottomright - element_offset - place, score, 4, 34, '1 1 0', 0, 1, DRAWFLAG_NORMAL);
1254 Sbar_DrawXNum(bottomright - element_offset - place + '132 -6 0', distribution, 4, 16, ' 1 0 0', 0, 1, DRAWFLAG_NORMAL);
1255 Sbar_DrawXNum(bottomright - element_offset - place, score, 4, 34, '1 0 0', 0, 1, DRAWFLAG_NORMAL);
1259 //draw the remaining or elapsed time
1260 timelimit = getstatf(STAT_TIMELIMIT);
1265 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1266 timeleft = ceil(timeleft);
1267 minutesLeft = floor(timeleft / 60);
1268 secondsLeft = timeleft - minutesLeft*60;
1270 if(minutesLeft >= 5) {
1271 timer_color = '1 1 1'; //white
1272 } else if(minutesLeft >= 1) {
1273 timer_color = '1 1 0'; //yellow
1275 timer_color = '1 0 0'; //red
1279 timer_color = '1 1 1'; //don't use red or yellow for timer during warmup
1282 if (cvar("sbar_increment_maptime")) {
1283 if (time < getstatf(STAT_GAMESTARTTIME)) {
1284 //while restart is still active, show negative counter
1286 seconds = ceil(getstatf(STAT_GAMESTARTTIME) - time);
1289 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
1290 minutes = floor(elapsedTime / 60);
1291 seconds = elapsedTime - minutes*60;
1294 minutes = minutesLeft;
1295 seconds = secondsLeft;
1299 bgpos_x = topright_x - 36 - 7 - 12;
1300 else if (minutes < 10) // nudge the timer background left if more digits are drawn
1301 bgpos_x = topright_x - 54 - 17 - 12;
1302 else if (minutes < 100)
1303 bgpos_x = topright_x - 72 - 17 - 12;
1305 bgpos_x = topright_x - 90 - 17 - 12;
1309 if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100
1311 drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', GetTeamRGB(myteam) * cvar("sbar_color_bg_team"), sbar_alpha_bg, 0); // timer bg color = myteam color
1313 color_x = cvar("sbar_color_bg_r");
1314 color_y = cvar("sbar_color_bg_g");
1315 color_z = cvar("sbar_color_bg_b");
1317 drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', color, sbar_alpha_bg, 0);
1321 if(minutesLeft >= 1 || (cvar("sbar_increment_maptime") && minutes >= 1) ) {
1322 Sbar_DrawXNum(topright - '103 0 0', minutes, 3, 18, timer_color, 0, sbar_alpha_fg, 0);
1323 drawpic(topright - '53 0 0', "gfx/hud/num_colon", '18 18 0', timer_color, sbar_alpha_fg, 0);
1325 Sbar_DrawXNum(topright - '36 0 0' - '3 0 0', seconds, -2, 18, timer_color, 0, 1, DRAWFLAG_NORMAL);
1328 timer_color = '1 1 1'; //white
1329 minutes = floor(time / 60);
1330 seconds = floor(time - minutes*60);
1333 bgpos_x = topright_x - 54 - 17 - 12;
1334 else if (minutes < 100) // nudge the timer background left if more digits are drawn
1335 bgpos_x = topright_x - 72 - 17 - 12;
1337 bgpos_x = topright_x - 90 - 17 - 12;
1341 if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100
1343 drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', GetTeamRGB(myteam), sbar_alpha_bg, 0); // timer bg color = myteam color
1345 color_x = cvar("sbar_color_bg_r");
1346 color_y = cvar("sbar_color_bg_g");
1347 color_z = cvar("sbar_color_bg_b");
1349 drawpic(bgpos, "gfx/hud/sb_timerbg", '120 30 0', color, sbar_alpha_bg, 0);
1353 Sbar_DrawXNum(topright - '103 0 0', minutes, 3, 18, timer_color, 0, 1, DRAWFLAG_NORMAL);
1354 drawpic(topright - '53 0 0', "gfx/hud/num_colon", '18 18 0', timer_color, sbar_alpha_fg, 0);
1355 Sbar_DrawXNum(topright - '36 0 0' - '3 0 0', seconds, -2, 18, timer_color, 0, 1, DRAWFLAG_NORMAL);
1358 if(gametype == GAME_RACE)
1360 drawfont = sbar_bigfont;
1363 string s, forcetime;
1365 m = '0.5 0 0' * vid_conwidth + '0 0.25 0' * vid_conheight;
1367 if(race_checkpointtime)
1369 a = bound(0, 2 - (time - race_checkpointtime), 1);
1372 if(a > 0) // just hit a checkpoint?
1374 if(race_time && race_previousbesttime)
1375 s = MakeRaceString(race_checkpoint, race_time / 10 - race_previousbesttime / 10, 0, 0, race_previousbestname);
1377 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
1379 forcetime = mmsss(race_time);
1383 if(race_laptime && race_nextbesttime)
1385 a = bound(0, 2 - ((race_laptime + race_nextbesttime/10) - time), 1);
1386 if(a > 0) // next one?
1388 s = MakeRaceString(race_nextcheckpoint, time - race_laptime, race_nextbesttime / 10, 0, race_nextbestname);
1393 if(s != "" && a > 0)
1395 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1396 drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1401 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
1402 drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);
1409 s = mmsss(10*(time - race_laptime));
1410 drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, 0);
1415 if(race_mycheckpointtime)
1417 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
1418 s = MakeRaceString(race_mycheckpoint, race_mycheckpointdelta / 10, -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
1419 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1420 drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1422 if(race_othercheckpointtime && race_othercheckpointenemy != "")
1424 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
1425 s = MakeRaceString(race_othercheckpoint, -race_othercheckpointdelta / 10, -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
1426 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1427 drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1431 drawfont = sbar_font;
1437 float Sbar_WouldDrawScoreboard ()
1441 else if (intermission == 1)
1443 else if (intermission == 2)
1445 else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
1447 else if(sb_showscores_force)
1452 void CSQC_Strength_Timer() {
1455 bottom_x = vid_conwidth/2;
1456 bottom_y = vid_conheight;
1459 float stat_items, dt;
1460 stat_items = getstati(STAT_ITEMS);
1462 if not(stat_items & IT_STRENGTH)
1463 if not(stat_items & IT_INVINCIBLE)
1467 if (getstati(STAT_HEALTH) <= 0)
1471 float strength_time, invincibility_time, countdown_fontsize;
1473 picsize = '22 22 0';
1474 countdown_fontsize = 18;
1477 strength_time = getstatf(STAT_STRENGTH_FINISHED);
1478 invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);
1480 if (strength_time) {
1481 dt = strength_time - time;
1486 drawpic_expanding_two(bottom + '192 -46 0', "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
1487 bound(0, (ceil(dt) - dt) / 0.5, 1));
1491 drawpic(bottom + '192 -46 0', "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
1493 Sbar_DrawXNum(bottom + '152 -44 0', ceil(dt), 2, countdown_fontsize, '1 1 1', 0, 1, DRAWFLAG_NORMAL);
1497 drawpic_expanding(bottom + '192 -46 0', "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
1498 bound(0, -dt / 0.5, 1));
1503 if (invincibility_time) {
1504 dt = invincibility_time - time;
1509 drawpic_expanding_two(bottom + '192 -24 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
1510 bound(0, (ceil(dt) - dt) / 0.5, 1));
1514 drawpic(bottom + '192 -24 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
1516 Sbar_DrawXNum(bottom + '152 -22 0', ceil(dt), 2, countdown_fontsize, '1 1 1', 0, 1, DRAWFLAG_NORMAL);
1520 drawpic_expanding(bottom + '192 -24 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
1521 bound(0, -dt / 0.5, 1));
1526 #define CENTERPRINT_MAX_LINES 30
1527 string centerprint_messages[CENTERPRINT_MAX_LINES];
1528 float centerprint_width[CENTERPRINT_MAX_LINES];
1529 vector centerprint_start;
1530 float centerprint_expire;
1531 float centerprint_num;
1532 float centerprint_offset_hint;
1533 vector centerprint_fontsize;
1535 void centerprint(string strMessage)
1537 float i, j, n, hcount;
1540 centerprint_fontsize = Sbar_GetFontsize("scr_centersize");
1542 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
1544 if(cvar("scr_centertime") <= 0)
1547 if(strMessage == "")
1550 // strip trailing newlines
1551 j = strlen(strMessage) - 1;
1552 while(substring(strMessage, j, 1) == "\n" && j >= 0)
1554 strMessage = substring(strMessage, 0, j + 1);
1556 if(strMessage == "")
1559 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
1561 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
1563 strMessage = substring(strMessage, j, strlen(strMessage) - j);
1564 centerprint_offset_hint = j;
1566 if(strMessage == "")
1569 // if we get here, we have a message. Initialize its height.
1570 centerprint_num = 0;
1572 n = tokenizebyseparator(strMessage, "\n");
1574 for(j = 0; j < n; ++j)
1576 getWrappedLine_remaining = argv(j);
1577 while(getWrappedLine_remaining)
1579 s = getWrappedLine(vid_conwidth * 0.75 / centerprint_fontsize_x, stringwidth_colors);
1580 if(centerprint_messages[i])
1581 strunzone(centerprint_messages[i]);
1582 centerprint_messages[i] = strzone(s);
1583 centerprint_width[i] = stringwidth(s, TRUE);
1586 // half height for empty lines looks better
1592 if(i >= CENTERPRINT_MAX_LINES)
1598 h = centerprint_fontsize_y*hcount;
1600 havail = vid_conheight;
1601 if(cvar("con_chatpos") < 0)
1602 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
1604 centerprint_start_x = 0;
1607 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
1609 // here, the centerprint would cover the crosshair. REALLY BAD.
1610 forbiddenmin = vid_conheight * 0.5 - h - 16;
1611 forbiddenmax = vid_conheight * 0.5 + 16;
1613 allowedmin = scoreboard_bottom;
1614 allowedmax = havail - h;
1615 preferred = (havail - h)/2;
1618 // possible orderings (total: 4! / 4 = 6)
1619 // allowedmin allowedmax forbiddenmin forbiddenmax
1620 // forbiddenmin forbiddenmax allowedmin allowedmax
1621 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
1623 // forbidden doesn't matter in this case
1624 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
1626 // allowedmin forbiddenmin allowedmax forbiddenmax
1627 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
1629 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
1631 // allowedmin forbiddenmin forbiddenmax allowedmax
1632 else if(allowedmin < forbiddenmin)
1634 // make sure the forbidden zone is not covered
1635 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
1636 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
1638 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
1640 // forbiddenmin allowedmin allowedmax forbiddenmax
1641 else if(allowedmax < forbiddenmax)
1643 // it's better to leave the allowed zone (overlap with scoreboard) than
1644 // to cover the forbidden zone (crosshair)
1645 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
1646 centerprint_start_y = forbiddenmax;
1648 centerprint_start_y = forbiddenmin;
1650 // forbiddenmin allowedmin forbiddenmax allowedmax
1653 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
1656 centerprint_start_y =
1659 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
1666 centerprint_num = i;
1667 centerprint_expire = time + cvar("scr_centertime");
1670 void Sbar_DrawCenterPrint (void)
1677 //if(time > centerprint_expire)
1680 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
1681 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
1682 //sz = 1.2 / (a + 0.2);
1687 pos = centerprint_start;
1688 for (i=0; i<centerprint_num; i = i + 1)
1690 pos_x = (vid_conwidth - centerprint_fontsize_x * centerprint_width[i]) * 0.5;
1691 ts = centerprint_messages[i];
1694 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1695 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
1696 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
1697 pos_y = pos_y + centerprint_fontsize_y;
1700 // half height for empty lines looks better
1701 pos_y = pos_y + centerprint_fontsize_y * 0.5;
1705 vector Sbar_DrawNoteLine(vector offset, string s)
1707 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1708 drawcolorcodedstring(
1709 offset - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
1715 return offset + sbar_fontsize_y * '0 1 0';
1718 void Sbar_DrawPressedKeys(void)
1723 pos = stov(cvar_string("cl_showpressedkeys_position"));
1725 bgsize = '126 75 0';
1727 pos = '1 0 0' * (vid_conwidth - bgsize_x) * pos_x
1728 + '0 1 0' * (vid_conheight - bgsize_y) * pos_y;
1729 pos -= '-15 -6 0'; // adjust to the origin of these numbers
1731 pressedkeys = getstatf(STAT_PRESSED_KEYS);
1732 drawpic(pos + '-15 -6 0', "gfx/hud/keys/key_bg.tga", bgsize, '1 1 1', .1, DRAWFLAG_NORMAL);
1733 drawpic(pos + ' 83.5 9 0', ((pressedkeys & KEY_CROUCH) ? "gfx/hud/keys/key_crouch_inv.tga" : "gfx/hud/keys/key_crouch.tga"), ' 24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1734 drawpic(pos + ' 32 -1.5 0', ((pressedkeys & KEY_FORWARD) ? "gfx/hud/keys/key_forward_inv.tga" : "gfx/hud/keys/key_forward.tga"), ' 32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1735 drawpic(pos + '-11.5 9 0', ((pressedkeys & KEY_JUMP) ? "gfx/hud/keys/key_jump_inv.tga" : "gfx/hud/keys/key_jump.tga"), ' 24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1736 drawpic(pos + ' -1 32 0', ((pressedkeys & KEY_LEFT) ? "gfx/hud/keys/key_left_inv.tga" : "gfx/hud/keys/key_left.tga"), ' 32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1737 drawpic(pos + ' 32 32 0', ((pressedkeys & KEY_BACKWARD) ? "gfx/hud/keys/key_backward_inv.tga" : "gfx/hud/keys/key_backward.tga"), ' 32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1738 drawpic(pos + ' 65 32 0', ((pressedkeys & KEY_RIGHT) ? "gfx/hud/keys/key_right_inv.tga" : "gfx/hud/keys/key_right.tga"), ' 32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1741 float GetAmmoStat(float i)
1745 case 0: return STAT_SHELLS;
1746 case 1: return STAT_NAILS;
1747 case 2: return STAT_ROCKETS;
1748 case 3: return STAT_CELLS;
1749 case 4: return STAT_FUEL;
1754 float GetAmmoItemCode(float i)
1758 case 0: return IT_SHELLS;
1759 case 1: return IT_NAILS;
1760 case 2: return IT_ROCKETS;
1761 case 3: return IT_CELLS;
1762 case 4: return IT_FUEL;
1767 string GetAmmoPicture(float i)
1771 case 0: return "gfx/hud/sb_shells";
1772 case 1: return "gfx/hud/sb_bullets";
1773 case 2: return "gfx/hud/sb_rocket";
1774 case 3: return "gfx/hud/sb_cells";
1775 case 4: return "gfx/hud/sb_fuel";
1780 void Sbar_Draw (void)
1782 // vectors for top right, bottom right, bottom and bottom left corners
1789 topright_x = vid_conwidth;
1793 bottom_x = vid_conwidth/2;
1794 bottom_y = vid_conheight;
1797 bottomright_x = vid_conwidth;
1798 bottomright_y = vid_conheight;
1802 bottomleft_y = vid_conheight;
1805 sbar_alpha_bg = cvar("sbar_alpha_bg");
1809 float stat_items, stat_weapons;
1811 vector o; o = '1 0 0' * vid_conwidth;
1812 o_y = 28; // move spectator text slightly down to prevent overlapping the timer
1816 sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
1818 if(spectatee_status && !intermission)
1820 if(spectatee_status == -1)
1823 s = strcat("^1Spectating ^7", GetPlayerName(spectatee_status - 1));
1824 o = Sbar_DrawNoteLine(o, s);
1826 if(spectatee_status == -1)
1827 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
1829 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
1830 o = Sbar_DrawNoteLine(o, s);
1832 if(spectatee_status == -1)
1833 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
1835 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
1836 o = Sbar_DrawNoteLine(o, s);
1838 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
1839 o = Sbar_DrawNoteLine(o, s);
1841 if(gametype == GAME_ARENA)
1842 s = "^1Wait for your turn to join";
1843 else if(gametype == GAME_LMS)
1846 sk = playerslots[player_localentnum - 1];
1847 if(sk.(scores[ps_primary]) >= 666)
1848 s = "^1Match has already begun";
1849 else if(sk.(scores[ps_primary]) > 0)
1850 s = "^1You have no more lives left";
1852 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1855 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1856 o = Sbar_DrawNoteLine(o, s);
1858 //show restart countdown:
1859 if (time < getstatf(STAT_GAMESTARTTIME)) {
1861 //we need to ceil, otherwise the countdown would be off by .5 when using round()
1862 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
1863 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
1864 o = Sbar_DrawNoteLine(o, s);
1867 if(warmup_stage && !intermission)
1869 s = "^2Currently in ^1warmup^2 stage!";
1870 o = Sbar_DrawNoteLine(o, s);
1873 // move more important stuff more to the middle so its more visible
1874 o_y = vid_conheight * 0.66;
1877 if(mod(time, 1) >= 0.5)
1882 if(ready_waiting && !intermission)
1884 if(ready_waiting_for_me)
1887 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
1889 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
1894 s = strcat("^2Waiting for others to ready up to end warmup...");
1896 s = strcat("^2Waiting for others to ready up...");
1898 o = Sbar_DrawNoteLine(o, s);
1900 else if(warmup_stage && !intermission)
1902 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
1903 o = Sbar_DrawNoteLine(o, s);
1907 s = strcat("^2A vote has been called for ^1", vote_called_vote);
1908 o = Sbar_DrawNoteLine(o, s);
1910 if(vote_waiting_for_me)
1912 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote yes", "vyes"), blinkcolor, " to accept");
1913 o = Sbar_DrawNoteLine(o, s);
1915 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote no", "vno"), blinkcolor, " to reject");
1916 o = Sbar_DrawNoteLine(o, s);
1918 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote abstain", "vabstain"), blinkcolor, " to abstain");
1919 o = Sbar_DrawNoteLine(o, s);
1923 s = strcat("^2Waiting for others to vote...");
1924 o = Sbar_DrawNoteLine(o, s);
1927 if(teamplay && !intermission)
1930 float ts_min, ts_max;
1931 tm = teams.sort_next;
1934 for(; tm.sort_next; tm = tm.sort_next)
1936 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
1938 if(!ts_min) ts_min = tm.team_size;
1939 else ts_min = min(ts_min, tm.team_size);
1940 if(!ts_max) ts_max = tm.team_size;
1941 else ts_max = max(ts_max, tm.team_size);
1943 if ((ts_max - ts_min) > 1)
1945 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
1946 tm = GetTeam(myteam, false);
1948 if (tm.team != COLOR_SPECTATOR)
1949 if (tm.team_size == ts_max)
1950 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
1952 o = Sbar_DrawNoteLine(o, s);
1957 Sbar_UpdatePlayerTeams();
1959 if (intermission == 1)
1961 Sbar_DrawScoreboard();
1962 Sbar_DrawCenterPrint();
1965 else if (intermission == 2)
1967 Sbar_FinaleOverlay();
1968 Sbar_DrawCenterPrint();
1972 if (sb_showscores_force || (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard")))
1974 sbar_x = (vid_conwidth - 640.0)*0.5;
1975 sbar_y = vid_conheight - 47;
1976 //Sbar_DrawAlphaPic (sbar_x, sbar_y, sb_scorebar, sbar_alpha_bg.value);
1977 //drawpic('0 0 0', "gfx/hud/scorebar", '0 0 0', '1 1 1', cvar("sbar_alpha_bg"), 0);
1978 Sbar_DrawScoreboard ();
1982 if (sb_showscores) // do not hide the hud if sb_showscores is shown
1984 Sbar_DrawScoreboard();
1985 Sbar_DrawCenterPrint();
1988 float armor, health;
1989 armor = getstati(STAT_ARMOR);
1990 health = getstati(STAT_HEALTH);
1992 stat_items = getstati(STAT_ITEMS);
1993 stat_weapons = getstati(STAT_WEAPONS);
1995 fade = 3.2 - 2 * (time - weapontime);
1996 fade = bound(0.7, fade, 1);
1998 vector bg_size; // hud background size
2000 if (vid_conwidth > 800) // if conwidth > 800, resize the background image
2001 bg_size_x = vid_conwidth;
2005 vector bgoffset; // hud background offset
2009 if (vid_conwidth < 800) // if conwidth < 800 we need to offset the background image to keep it centered, as it will be scaled up
2010 bgoffset_x = (vid_conwidth - 800) / 2;
2012 if (cvar("viewsize") <= 100) {
2014 //if (myteam == 13) // 13 = blue shirt color
2015 // drawpic(bottomleft - '0 58 0' + bgoffset, "gfx/hud/sbar", bg_size, '0 0.3 1', sbar_alpha_bg, 0); // blue hud is too dark at '0 0 1'
2017 drawpic(bottomleft - '0 58 0' + bgoffset, "gfx/hud/sbar", bg_size, GetTeamRGB(myteam) * cvar("sbar_color_bg_team"), sbar_alpha_bg, 0); // hud color = myteam color
2020 // allow for custom HUD colors in non-teamgames
2021 color_x = cvar("sbar_color_bg_r");
2022 color_y = cvar("sbar_color_bg_g");
2023 color_z = cvar("sbar_color_bg_b");
2025 drawpic(bottomleft - '0 58 0' + bgoffset, "gfx/hud/sbar", bg_size, color, sbar_alpha_bg, 0);
2031 if(sbar_hudselector == 2) // combined health and armor display
2033 // NOTE: we'll always choose the SMALLER value...
2034 float healthdamage, armordamage, armorideal;
2035 healthdamage = (health - 1) / (1 - armorblockpercent); // damage we can take if we could use more health
2036 armordamage = armor + (health - 1); // damage we can take if we could use more armor
2037 armorideal = healthdamage * armorblockpercent;
2040 num_pos = bottom - element_offset - '0 24 0' + '-96 0 0';
2042 if(armordamage < healthdamage)
2044 // here, armorideal > armor
2045 x = floor(armordamage + 1);
2046 drawpic(num_pos + '78 -3 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, 0);
2047 drawpic(num_pos + '108 -3 0', "gfx/hud/sb_armor", '20 20 0', '1 1 1', sbar_alpha_fg * armor / armorideal, 0);
2051 x = floor(healthdamage + 1);
2052 drawpic(num_pos + '108 -3 0', "gfx/hud/sb_health", '20 20 0', '1 1 1', sbar_alpha_fg * armorideal / armor, 0);
2053 drawpic(num_pos + '78 -3 0', "gfx/hud/sb_armor", '32 32 0', '1 1 1', sbar_alpha_fg, 0);
2055 Sbar_DrawXNum_Colored(num_pos, x, 24); // draw the combined health and armor
2060 vector health_pos, armor_pos;
2062 if (sbar_hudselector == 0) { // old style layout with armor left of health
2063 health_pos = bottom - element_offset - '0 24 0' + '14 0 0';
2064 armor_pos = bottom - element_offset - '0 24 0' + '-96 0 0';
2068 health_pos = bottom - element_offset - '0 24 0' + '-96 0 0';
2069 armor_pos = bottom - element_offset - '0 24 0' + '14 0 0';
2076 drawpic(armor_pos + '78 -3 0', "gfx/hud/sb_armor", '32 32 0', '1 1 1', sbar_alpha_fg, 0);
2078 Sbar_DrawXNum_Colored(armor_pos, x, 24);
2083 drawpic(health_pos + '78 -3 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, 0);
2085 Sbar_DrawXNum_Colored(health_pos, x, 24);
2090 Sbar_DrawWeapon_Clear();
2091 for(i = 1; i <= 24; ++i)
2093 if(weaponimpulse[i-1] >= 0)
2094 if(stat_weapons & x)
2096 Sbar_DrawWeapon(i-1, fade, (i == activeweapon));
2102 float a; // i will be the ammo type (already declared), a will contain how much ammo there is of type i
2106 for (i = 0; i < 4; ++i) {
2107 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
2111 if (cvar("vid_conwidth") >= 800)
2113 case 0: pos_x = 114; pos_y = -48; break; // shells
2114 case 1: pos_x = 114; pos_y = -26; break; // bullets
2115 case 2: pos_x = 200; pos_y = -48; break; // rockets
2116 case 3: pos_x = 200; pos_y = -26; break; // cells
2118 else // if vid_conwidth is lower than 800, ammo will overlap with weapon icons and health so we'll move it to the right
2120 case 0: pos_x = vid_conwidth - 158; pos_y = -150; break; // shells
2121 case 1: pos_x = vid_conwidth - 158; pos_y = -128; break; // bullets
2122 case 2: pos_x = vid_conwidth - 84; pos_y = -150; break; // rockets
2123 case 3: pos_x = vid_conwidth - 84; pos_y = -128; break; // cells
2126 if (stat_items & GetAmmoItemCode(i))
2127 drawpic(bottomleft + pos + '0 1.5 0', "gfx/hud/sb_ammobg", '80 22 0', '1 1 1', sbar_alpha_fg, 0);
2128 drawpic(bottomleft + pos + '56 3 0', GetAmmoPicture(i), '18 18 0', '1 1 1', sbar_alpha_fg, 0);
2130 Sbar_DrawXNum(bottomleft + pos + '6 4 0', a, 3, 16, '0.6 0.7 0.8', 0, 1, 0);
2132 Sbar_DrawXNum(bottomleft + pos + '6 4 0', a, 3, 16, '0.7 0 0', 0, 1, 0);
2137 a = getstati(GetAmmoStat(4)); // how much fuel do we have?
2139 if (a > 0) { // if we have fuel, draw the amount
2140 float invincibility_time, dt;
2141 invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);
2142 dt = invincibility_time - time;
2143 if (dt > 0) { // if the invincibility timer is active, draw fuel ammo elsewhere
2144 pos_x = bottom_x + 140;
2145 pos_y = bottom_y - 72;
2147 else { // if the invincibility timer is inactive, draw the fuel ammo there (it's rare to have invincibility + fuel anyway)
2148 pos_x = bottom_x + 140;
2149 pos_y = bottom_y - 22;
2151 drawpic(pos - '0 2 0' + '52 0 0', GetAmmoPicture(4), '20 20 0', '1 1 1', sbar_alpha_fg, 0);
2153 Sbar_DrawXNum(pos, a, 3, 16, '0.6 0.7 0.8', 0, 1, 0);
2155 Sbar_DrawXNum(pos, a, 3, 16, '0.7 0 0', 0, 1, 0);
2158 // draw scores and timer
2162 //show strength/invincibility ICON and timer:
2163 CSQC_Strength_Timer();
2165 if(gametype == GAME_KEYHUNT)
2168 } else if(gametype == GAME_CTF)
2171 } else if(gametype == GAME_NEXBALL)
2180 void CSQC_ctf_hud(void)
2184 bottomleft_y = vid_conheight;
2187 float redflag, blueflag;
2190 stat_items = getstati(STAT_ITEMS);
2191 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
2192 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
2194 if (myteam == COLOR_TEAM1) { // always draw own flag on left
2197 case 1: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_red_taken", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2198 case 2: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_red_lost", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2199 case 3: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_red_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2201 if(stat_items & IT_CTF_SHIELDED)
2202 if(myteam == COLOR_TEAM2)
2203 drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_red_shielded", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2208 case 1: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_blue_taken", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2209 case 2: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_blue_lost", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2210 case 3: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_blue_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2212 if(stat_items & IT_CTF_SHIELDED)
2213 if(myteam == COLOR_TEAM1)
2214 drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_blue_shielded", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2221 case 1: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_blue_taken", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2222 case 2: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_blue_lost", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2223 case 3: drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_blue_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, 0); break;
2225 if(stat_items & IT_CTF_SHIELDED)
2226 if(myteam == COLOR_TEAM1)
2227 drawpic(bottomleft - element_offset - '-4 36 0', "gfx/hud/sb_flag_blue_shielded", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2232 case 1: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_red_taken", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2233 case 2: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_red_lost", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2234 case 3: drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_red_carrying", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2236 if(stat_items & IT_CTF_SHIELDED)
2237 if(myteam == COLOR_TEAM2)
2238 drawpic(bottomleft - element_offset - '-72 36 0', "gfx/hud/sb_flag_red_shielded", '48 48 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); break;
2244 void CSQC_kh_hud(void)
2246 float kh_keys, kh_keys_status, kh_teams_set;
2247 vector red_pos, blue_pos, yellow_pos, pink_pos, kh_size;
2251 bottomleft_y = vid_conheight;
2255 red_pos_y = vid_conheight - 35 - 6;
2258 blue_pos_x = 6 + (24 * 1);
2259 blue_pos_y = vid_conheight - 35 - 6;
2262 yellow_pos_x = 6 + (24 * 2);
2263 yellow_pos_y = vid_conheight - 35 - 6;
2266 pink_pos_x = 6 + (24 * 3);
2267 pink_pos_y = vid_conheight - 35 - 6;
2270 kh_keys = getstati(STAT_KH_KEYS);
2271 kh_keys_status = kh_keys / 256;
2272 kh_teams_set = cvar("_teams_available"); // set in keyhunt.qc
2274 kh_size = '22 35 0';
2276 if (kh_keys_status & 1) // red
2277 drawpic (red_pos, "gfx/hud/sb_kh_red", kh_size, '1 1 1', 0.3, 0); // show 30% alpha key
2279 drawpic (red_pos, "gfx/hud/sb_kh_red", kh_size, '1 1 1', 1.0, 0); // show solid key 100% alpha
2281 if (kh_keys_status & 2) // blue
2282 drawpic (blue_pos, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', 0.3, 0);
2284 drawpic (blue_pos, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', 1.0, 0);
2286 if (kh_teams_set & 4) // yellow
2288 if (kh_keys_status & 4)
2289 drawpic (yellow_pos, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', 0.3, 0);
2291 drawpic (yellow_pos, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', 1.0, 0);
2294 if (kh_teams_set & 8) // pink
2296 if (kh_keys_status & 8)
2297 drawpic (pink_pos, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', 0.3, 0);
2299 drawpic (pink_pos, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', 1.0, 0);
2304 #define NBPB_SIZE '96 38 0'
2305 #define NBPB_BT 2 //thickness
2306 #define NBPB_BRGB '1 1 1'
2307 #define NBPB_BALPH 1 //alpha
2308 #define NBPB_BFLAG DRAWFLAG_NORMAL
2309 #define NBPB_IALPH 0.4
2310 #define NBPB_IFLAG DRAWFLAG_NORMAL
2311 #define NBPB_IRGB '0.7 0.1 0'
2313 void CSQC_nb_hud(void)
2315 float stat_items, nb_pb_starttime, dt, p;
2318 stat_items = getstati(STAT_ITEMS);
2319 nb_pb_starttime = getstatf(STAT_NB_METERSTART);
2322 pos_y = vid_conheight - 42;
2325 //Manage the progress bar if any
2326 if (nb_pb_starttime > 0)
2329 dt = mod(time - nb_pb_starttime, nb_pb_period);
2330 // one period of positive triangle
2331 p = 2 * dt / nb_pb_period;
2337 drawfill(pos, p * s_x * '1 0 0' + s_y * '0 1 0', NBPB_IRGB, NBPB_IALPH, NBPB_IFLAG);
2341 drawline(NBPB_BT, pos , pos + '1 0 0' * s_x, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2342 drawline(NBPB_BT, pos , pos + '0 1 0' * s_y, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2343 drawline(NBPB_BT, pos + s, pos + '1 0 0' * s_x, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2344 drawline(NBPB_BT, pos + s, pos + '0 1 0' * s_y, NBPB_BRGB, NBPB_BALPH, NBPB_BFLAG);
2347 pos_x += 12; //horizontal margin to the picture
2348 pos_y += 2; //vertical margin to the picture
2350 if (stat_items & IT_KEY1)
2351 drawpic(pos, "gfx/hud/sb_nexball_carrying", '80 34 0', '1 1 1', 1, DRAWFLAG_NORMAL);