5 float sb_lines; // still don't know what to do with that NOTE: check dp's sbar.c to see what that should be
9 float sbar_hudselector;
11 float ps_primary, ps_secondary;
12 float ts_primary, ts_secondary;
17 void Sbar_FinaleOverlay()
20 pos_x = (vid_conwidth - 1)/2;
24 //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
26 //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
30 float weaponspace[10];
31 float weapon_first, weapon_last;
32 void Sbar_DrawWeapon_Clear()
37 for(idx = 0; idx < 10; ++idx)
39 for(idx = 0; idx <= 23; ++idx)
41 if(weaponimpulse[idx] >= 0)
49 void Sbar_DrawWeapon(float nr, float fade, float active)
51 vector pos, vsize, color;
52 float value, idx, imp, sp;
54 imp = weaponimpulse[nr];
60 value = (active) ? 1 : 0.6;
61 color_x = color_y = color_z = value;
63 if(sbar_hudselector == 1)
65 // width = 300, height = 100
66 const float w_width = 32, w_height = 12, w_space = 2, font_size = 8;
68 sp = weaponspace[idx] + 1;
69 weaponspace[idx] = sp;
71 pos_x = (vid_conwidth - w_width * 9) * 0.5 + w_width * idx;
72 pos_y = (vid_conheight - w_height * sp);
77 drawpic(pos, strcat("gfx/inv_weapon", ftos(nr)), vsize, color, value * fade * sbar_alpha_fg, 0);
83 drawstring(pos, ftos(imp), vsize, '1 1 0', sbar_alpha_fg, 0);
87 // width = 300, height = 100
88 const float w2_width = 300, w2_height = 100, w2_space = 10;
89 const float w2_scale = 0.4;
92 f = 9 / (weapon_last + 1 - weapon_first);
94 pos_x = vid_conwidth - (w2_width + w2_space) * w2_scale * f;
95 pos_y = (w2_height + w2_space) * w2_scale * nr * f + w2_space;
97 vsize_x = w2_width * w2_scale * f;
98 vsize_y = w2_height * w2_scale * f;
101 drawpic(pos, strcat("gfx/inv_weapon", ftos(nr)), vsize, color, value * fade * sbar_alpha_fg, 0);
104 void Sbar_DrawXNum (vector pos, float num, float digits, float lettersize, vector rgb, float a, float dflags)
111 vsize_x = vsize_y = lettersize;
126 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
134 str = substring(str, l-digits, 999);
136 } else if(l < digits)
137 pos_x += (digits-l) * lettersize;
141 drawpic(sbar + pos, "gfx/num_minus", vsize, rgb, a * sbar_alpha_fg, dflags);
145 for(i = 0; i < l; ++i)
147 drawpic(sbar + pos, strcat("gfx/num_", substring(str, i, 1)), vsize, rgb, a * sbar_alpha_fg, dflags);
152 void Cmd_Sbar_SetFields(float argc);
153 void Sbar_InitScores()
157 ps_primary = ps_secondary = ts_primary = ts_secondary = -1;
158 for(i = 0; i < MAX_SCORE; ++i)
160 f = (scores_flags[i] & SFL_SORT_PRIO_MASK);
161 if(f == SFL_SORT_PRIO_PRIMARY)
163 if(f == SFL_SORT_PRIO_SECONDARY)
166 if(ps_secondary == -1)
167 ps_secondary = ps_primary;
169 for(i = 0; i < MAX_TEAMSCORE; ++i)
171 f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);
172 if(f == SFL_SORT_PRIO_PRIMARY)
174 if(f == SFL_SORT_PRIO_SECONDARY)
177 if(ts_secondary == -1)
178 ts_secondary = ts_primary;
180 Cmd_Sbar_SetFields(0);
183 void Sbar_UpdatePlayerPos(entity pl);
184 float SetTeam(entity pl, float Team);
186 void Sbar_UpdatePlayerTeams()
193 for(pl = players.sort_next; pl; pl = pl.sort_next)
196 Team = GetPlayerColor(pl.sv_entnum);
197 if(SetTeam(pl, Team))
200 Sbar_UpdatePlayerPos(pl);
204 pl = players.sort_next;
209 print(strcat("PNUM: ", ftos(num), "\n"));
214 float Sbar_ComparePlayerScores(entity left, entity right)
217 vl = GetPlayerColor(left.sv_entnum);
218 vr = GetPlayerColor(right.sv_entnum);
221 vl = COLOR_SPECTATOR;
223 vr = COLOR_SPECTATOR;
230 if(vl == COLOR_SPECTATOR)
232 // FIRST the one with scores (spectators), THEN the ones without (downloaders)
234 if(!left.gotscores && right.gotscores)
239 vl = left.scores[ps_primary];
240 vr = right.scores[ps_primary];
241 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
243 if(vl == 0 && vr != 0)
245 if(vl != 0 && vr == 0)
249 return IS_INCREASING(scores_flags[ps_primary]);
251 return IS_DECREASING(scores_flags[ps_primary]);
253 vl = left.scores[ps_secondary];
254 vr = right.scores[ps_secondary];
255 if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)
257 if(vl == 0 && vr != 0)
259 if(vl != 0 && vr == 0)
263 return IS_INCREASING(scores_flags[ps_secondary]);
265 return IS_DECREASING(scores_flags[ps_secondary]);
270 void Sbar_UpdatePlayerPos(entity player)
272 for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)
274 SORT_SWAP(player, other);
276 for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)
278 SORT_SWAP(other, player);
282 float Sbar_CompareTeamScores(entity left, entity right)
286 if(left.team == COLOR_SPECTATOR)
288 if(right.team == COLOR_SPECTATOR)
291 vl = left.teamscores[ts_primary];
292 vr = right.teamscores[ts_primary];
294 return IS_INCREASING(teamscores_flags[ts_primary]);
296 return IS_DECREASING(teamscores_flags[ts_primary]);
298 vl = left.teamscores[ts_secondary];
299 vr = right.teamscores[ts_secondary];
301 return IS_INCREASING(teamscores_flags[ts_secondary]);
303 return IS_DECREASING(teamscores_flags[ts_secondary]);
308 void Sbar_UpdateTeamPos(entity Team)
310 for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)
312 SORT_SWAP(Team, other);
314 for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)
316 SORT_SWAP(other, Team);
320 void Cmd_Sbar_Help(float argc)
322 print("You can modify the scoreboard using the\n");
323 print("^3|---------------------------------------------------------------|\n");
324 print("^1 TO BE DONE\n");
326 print("^2sbar_columns_set default\n");
327 print("^2sbar_columns_set ^7filed1 field2 ...\n");
328 print("The following field names are recognized (case INsensitive):\n");
329 print("You can use a ^3|^7 to start the right-aligned fields.\n");
331 print("^3name^7 or ^3nick^7 Name of a player\n");
332 print("^3ping^7 Ping time\n\n");
333 print("^3kd^7 or ^3kdr^7 or ^3kdratio^7 or ^3k/d\n");
334 print(" The kill-death ratio\n");
336 print("Before a field you can put a + or - sign, then a comma separated list\n");
337 print("of game types, then a slash, to make the field show up only in these\n");
338 print("or in all but these game types.\n");
340 print("The special game type names 'teams' and 'noteams' can be used to\n");
341 print("include/exclude ALL teams/noteams game modes.\n");
344 print("Additional columns:\n");
345 for(i = 0; i < MAX_SCORE; ++i)
347 if(scores_label[i] != "")
348 print(strcat(scores_label[i], "\n"));
352 #define MIN_NAMELEN 24
353 #define MAX_NAMELEN 24
355 string Sbar_DefaultColumnLayout()
357 return strcat( // fteqcc sucks
358 "ping pl color name | ",
359 "+noteams/kills +noteams/deaths +noteams/suicides -noteams,tdm/frags ", // tdm already has this in "score"
360 "+kh/caps +kh/pushes +kh/destroyed ",
361 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
365 void Cmd_Sbar_SetFields(float argc)
368 string str, pattern, subpattern, subpattern2;
370 float have_name, have_primary, have_secondary, have_separator;
373 // TODO: re enable with gametype dependant cvars?
374 if(argc < 2) // no arguments provided
375 argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");
378 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
382 if(argv(1) == "default")
383 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
384 else if(argv(1) == "all")
387 s = "ping pl color name |";
388 for(i = 0; i < MAX_SCORE; ++i)
391 if(i != ps_secondary)
392 if(scores_label[i] != "")
393 s = strcat(s, " ", scores_label[i]);
395 if(ps_secondary != ps_primary)
396 s = strcat(s, " ", scores_label[ps_secondary]);
397 s = strcat(s, " ", scores_label[ps_primary]);
398 argc = tokenizebyseparator(strcat("x ", s), " ");
403 argc = min(MAX_SBAR_FIELDS, argc);
406 drawfont = sbar_font;
407 digit = stringwidth("0123456789", FALSE) / 10;
409 subpattern = strcat(",", GametypeNameFromType(gametype), ",");
411 subpattern2 = ",teams,";
413 subpattern2 = ",noteams,";
415 argc = min(argc-1, MAX_SBAR_FIELDS-1);
416 for(i = 0; i < argc; ++i)
420 slash = strstrofs(str, "/", 0);
423 pattern = substring(str, 0, slash);
424 str = substring(str, slash + 1, strlen(str) - (slash + 1));
426 if(substring(pattern, 0, 1) == "-")
428 pattern = substring(pattern, 1, strlen(pattern) - 1);
429 if(strstrofs(strcat(",", pattern, ","), subpattern, 0) >= 0)
431 if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) >= 0)
436 if(substring(pattern, 0, 1) == "+")
437 pattern = substring(pattern, 1, strlen(pattern) - 1);
438 if(strstrofs(strcat(",", pattern, ","), subpattern, 0) < 0)
439 if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) < 0)
444 strunzone(sbar_title[sbar_num_fields]);
445 sbar_title[sbar_num_fields] = strzone(str);
446 sbar_size[sbar_num_fields] = stringwidth(str, FALSE);
447 str = strtolower(str);
450 sbar_field[sbar_num_fields] = SP_PING;
451 } else if(str == "pl") {
452 sbar_field[sbar_num_fields] = SP_PL;
453 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
454 sbar_field[sbar_num_fields] = SP_KDRATIO;
455 } else if(str == "color") {
457 sbar_field[sbar_num_fields] = SP_COLOR;
459 continue; // can't put this column in teamplay, it is redundant and stupid
460 } else if(str == "name" || str == "nick") {
461 sbar_field[sbar_num_fields] = SP_NAME;
462 sbar_size[sbar_num_fields] = MIN_NAMELEN; // minimum size? any use?
464 } else if(str == "|") {
465 sbar_field[sbar_num_fields] = SP_SEPARATOR;
468 for(j = 0; j < MAX_SCORE; ++j)
469 if(str == strtolower(scores_label[j]))
470 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
478 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
482 sbar_field[sbar_num_fields] = j;
485 if(j == ps_secondary)
491 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
493 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
495 if(ps_primary == ps_secondary)
497 missing = !have_primary + !have_secondary + !have_separator + !have_name;
499 if(sbar_num_fields+missing < MAX_SBAR_FIELDS)
503 strunzone(sbar_title[sbar_num_fields]);
504 for(i = sbar_num_fields; i > 0; --i)
506 sbar_title[i] = sbar_title[i-1];
507 sbar_size[i] = sbar_size[i-1];
508 sbar_field[i] = sbar_field[i-1];
510 sbar_title[0] = strzone("name");
511 sbar_field[0] = SP_NAME;
512 sbar_size[0] = MIN_NAMELEN; // minimum size? any use?
514 print("fixed missing field 'name'\n");
518 strunzone(sbar_title[sbar_num_fields]);
519 for(i = sbar_num_fields; i > 1; --i)
521 sbar_title[i] = sbar_title[i-1];
522 sbar_size[i] = sbar_size[i-1];
523 sbar_field[i] = sbar_field[i-1];
525 sbar_title[1] = strzone("|");
526 sbar_field[1] = SP_SEPARATOR;
527 sbar_size[1] = stringwidth("|", FALSE);
529 print("fixed missing field '|'\n");
532 else if(!have_separator)
534 strunzone(sbar_title[sbar_num_fields]);
535 sbar_title[sbar_num_fields] = strzone("|");
536 sbar_size[sbar_num_fields] = stringwidth("|", FALSE);
537 sbar_field[sbar_num_fields] = SP_SEPARATOR;
539 print("fixed missing field '|'\n");
544 strunzone(sbar_title[sbar_num_fields]);
545 sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);
546 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
547 sbar_field[sbar_num_fields] = ps_secondary;
549 print("fixed missing field '", scores_label[ps_secondary], "'\n");
554 strunzone(sbar_title[sbar_num_fields]);
555 sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);
556 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
557 sbar_field[sbar_num_fields] = ps_primary;
559 print("fixed missing field '", scores_label[ps_primary], "'\n");
563 sbar_field[sbar_num_fields] = SP_END;
567 vector sbar_field_rgb;
568 string sbar_field_icon0;
569 string sbar_field_icon1;
570 string sbar_field_icon2;
571 vector sbar_field_icon0_rgb;
572 vector sbar_field_icon1_rgb;
573 vector sbar_field_icon2_rgb;
574 float sbar_field_icon0_alpha;
575 float sbar_field_icon1_alpha;
576 float sbar_field_icon2_alpha;
577 string Sbar_GetField(entity pl, float field)
579 float tmp, num, denom, f;
581 sbar_field_rgb = '1 1 1';
582 sbar_field_icon0 = "";
583 sbar_field_icon1 = "";
584 sbar_field_icon2 = "";
585 sbar_field_icon0_rgb = '1 1 1';
586 sbar_field_icon1_rgb = '1 1 1';
587 sbar_field_icon2_rgb = '1 1 1';
588 sbar_field_icon0_alpha = 1;
589 sbar_field_icon1_alpha = 1;
590 sbar_field_icon2_alpha = 1;
595 return "\x8D\x8D\x8D"; // >>> sign
596 str = getplayerkey(pl.sv_entnum, "ping");
599 tmp = max(0, min(220, stof(str)-80)) / 220;
600 sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
606 str = getplayerkey(pl.sv_entnum, "pl");
609 tmp = bound(0, stof(str), 20) / 20; // 20% is REALLY BAD pl
610 sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
614 return getplayerkey(pl.sv_entnum, "name");
617 f = pl.(scores[SP_KILLS]);
618 f -= pl.(scores[SP_SUICIDES]);
622 f = stof(getplayerkey(pl.sv_entnum, "colors"));
623 sbar_field_icon0 = "gfx/sb_playercolor_base";
624 sbar_field_icon1 = "gfx/sb_playercolor_shirt";
625 sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
626 sbar_field_icon2 = "gfx/sb_playercolor_pants";
627 sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
631 num = pl.(scores[SP_KILLS]);
632 denom = pl.(scores[SP_DEATHS]);
635 sbar_field_rgb = '0 1 0';
637 } else if(num <= 0) {
638 sbar_field_rgb = '1 0 0';
639 str = ftos(num/denom);
641 str = ftos(num/denom);
643 tmp = strstrofs(str, ".", 0);
645 str = substring(str, 0, tmp+2);
649 tmp = pl.(scores[field]);
650 f = scores_flags[field];
651 if(field == ps_primary)
652 sbar_field_rgb = '1 1 0';
653 else if(field == ps_secondary)
654 sbar_field_rgb = '0 1 1';
656 sbar_field_rgb = '1 1 1';
657 return ScoreString(f, tmp);
662 // shamelessly stolen from menu QC :P <- as if I would steal YOUR code pfft ;)
663 float textLengthUpToWidth(string theText, float maxWidth, float handleColors)
666 // The following function is SLOW.
667 // For your safety and for the protection of those around you...
668 // DO NOT CALL THIS AT HOME.
670 if(stringwidth(theText, handleColors) <= maxWidth)
671 return strlen(theText); // yeah!
673 // binary search for right place to cut string
674 float left, right, middle; // this always works
676 right = strlen(theText); // this always fails
679 middle = floor((left + right) / 2);
680 if(stringwidth(substring(theText, 0, middle), handleColors) <= maxWidth)
685 while(left < right - 1);
687 // NOTE: when color codes are involved, this binary search is,
688 // mathematically, BROKEN. However, it is obviously guaranteed to
689 // terminate, as the range still halves each time - but nevertheless, it is
690 // guaranteed that it finds ONE valid cutoff place (where "left" is in
691 // range, and "right" is outside).
695 string textShortenToWidth(string theText, float maxWidth, float handleColors)
697 if(stringwidth(theText, handleColors) <= maxWidth)
700 return strcat(substring(theText, 0, textLengthUpToWidth(theText, maxWidth - stringwidth("...", handleColors), handleColors)), "...");
703 float xmin, xmax, ymin, ymax, sbwidth;
704 float sbar_fixscoreboardcolumnwidth_len;
705 float sbar_fixscoreboardcolumnwidth_iconlen;
707 string Sbar_FixScoreboardColumnWidth(float i, string str)
709 float field, maxsize, j;
711 field = sbar_field[i];
713 if(field == SP_NAME) // name gets all remaining space
715 maxsize = (xmax - xmin) / sbar_fontsize_x;
716 for(j = 0; j < sbar_num_fields; ++j) if(j != i) if(sbar_field[j] != SP_SEPARATOR)
717 maxsize -= sbar_size[j] + 1;
719 str = textShortenToWidth(str, maxsize, TRUE);
720 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE);
723 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE);
725 sbar_fixscoreboardcolumnwidth_iconlen = 0;
727 if(sbar_field_icon0 != "")
729 sz = drawgetimagesize(sbar_field_icon0);
730 if(sbar_fixscoreboardcolumnwidth_iconlen < sz_x / sz_y)
731 sbar_fixscoreboardcolumnwidth_iconlen = sz_x / sz_y;
734 if(sbar_field_icon1 != "")
736 sz = drawgetimagesize(sbar_field_icon1);
737 if(sbar_fixscoreboardcolumnwidth_iconlen < sz_x / sz_y)
738 sbar_fixscoreboardcolumnwidth_iconlen = sz_x / sz_y;
741 if(sbar_field_icon2 != "")
743 sz = drawgetimagesize(sbar_field_icon2);
744 if(sbar_fixscoreboardcolumnwidth_iconlen < sz_x / sz_y)
745 sbar_fixscoreboardcolumnwidth_iconlen = sz_x / sz_y;
748 sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect
750 if(sbar_size[i] < sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_iconlen)
752 print("size: extended from ", ftos(sbar_size[i]), " to ");
753 sbar_size[i] = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_iconlen;
754 print(ftos(sbar_size[i]), "\n");
760 void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self)
766 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
773 tmp_y = sbar_fontsize_y;
774 drawfill(pos - '1 1 0', tmp + '2 2 0', '1 1 1', 0.3, DRAWFLAG_NORMAL);
778 for(i = 0; i < sbar_num_fields; ++i)
780 field = sbar_field[i];
781 if(field == SP_SEPARATOR)
784 if(is_spec && field != SP_NAME && field != SP_PING) {
785 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
788 str = Sbar_GetField(pl, field);
789 str = Sbar_FixScoreboardColumnWidth(i, str);
791 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
793 if(field == SP_NAME) {
794 tmp_x = sbar_fontsize_x*(sbar_size[i] - sbar_fixscoreboardcolumnwidth_iconlen) + sbar_fontsize_x;
795 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
797 tmp_x = sbar_fixscoreboardcolumnwidth_len*sbar_fontsize_x + sbar_fontsize_x;
798 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
801 tmp_x = sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
802 if(sbar_field_icon0 != "")
803 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);
804 if(sbar_field_icon1 != "")
805 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);
806 if(sbar_field_icon2 != "")
807 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);
810 if(sbar_field[i] == SP_SEPARATOR)
813 for(i = sbar_num_fields-1; i > 0; --i)
815 field = sbar_field[i];
816 if(field == SP_SEPARATOR)
819 if(is_spec && field != SP_NAME && field != SP_PING) {
820 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
824 str = Sbar_GetField(pl, field);
825 str = Sbar_FixScoreboardColumnWidth(i, str);
827 if(field == SP_NAME) {
828 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
829 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
831 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; //strlen(str);
832 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
835 tmp_x = sbar_fontsize_x*sbar_size[i];
836 if(sbar_field_icon0 != "")
837 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);
838 if(sbar_field_icon1 != "")
839 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);
840 if(sbar_field_icon2 != "")
841 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);
843 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
849 void Sbar_DrawScoreboard()
851 //float xmin, ymin, xmax, ymax;
852 vector rgb, pos, tmp, sbar_save;
857 if(time > lastpingstime + 10)
860 lastpingstime = time;
863 sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);
865 xmin = 0.5 * (vid_conwidth - sbwidth);
868 xmax = vid_conwidth - xmin;
869 ymax = vid_conheight - 0.2*vid_conheight;
871 center_x = xmin + 0.5*sbwidth;
873 //Sbar_UpdateFields();
875 // Initializes position
881 drawfont = sbar_bigfont;
882 pos_x = center_x - stringwidth("Scoreboard", TRUE)*0.5*24;
883 drawstring(pos, "Scoreboard", '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
887 // Titlebar background:
889 tmp_y = sbar_fontsize_y;
890 drawfill(pos - '1 1 0', tmp + '2 2 0', '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
892 drawfont = sbar_font;
894 for(i = 0; i < sbar_num_fields; ++i)
896 if(sbar_field[i] == SP_SEPARATOR)
898 drawstring(pos, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
899 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
902 if(sbar_field[i] == SP_SEPARATOR)
904 pos_x = xmax + sbar_fontsize_x;
906 for(i = sbar_num_fields-1; i > 0; --i)
908 if(sbar_field[i] == SP_SEPARATOR)
911 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
914 * Using the following line will mess it all up:
916 * tmp_x = sbar_size[i] - strlen(sbar_title[i])*8;
918 tmp_x = sbar_fontsize_x*sbar_size[i];
919 tmp_x -= stringwidth(sbar_title[i], FALSE)*sbar_fontsize_x;
920 drawstring(pos + tmp, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
925 pos_y += 1.5 * sbar_fontsize_y;
932 //for(tm = sortedTeams.sort_next; tm; tm = tm.sort_next)
933 for(tm = teams.sort_next; tm; tm = tm.sort_next)
935 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
938 rgb = GetTeamRGB(tm.team);
943 pos - '6.5 0 0' * sbar_fontsize_y,
944 tm.(teamscores[ts_primary]),
945 4, sbar_fontsize_y * 1.5, rgb, 1, DRAWFLAG_NORMAL);
947 if(ts_primary != ts_secondary)
949 pos - '4.5 0 0' * sbar_fontsize_y + '0 1.5 0' * sbar_fontsize_y,
950 tm.(teamscores[ts_secondary]),
951 4, sbar_fontsize_y * 1, rgb, 1, DRAWFLAG_NORMAL);
953 specs = tm.team_size;
959 tmp_y = 1.25 * sbar_fontsize_y * specs;
960 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, 0.2, DRAWFLAG_NORMAL);
962 for(pl = players.sort_next; pl; pl = pl.sort_next)
964 if(pl.team != tm.team)
966 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
967 pos_y += 1.25 * sbar_fontsize_y;
968 tmp_y -= 1.25 * sbar_fontsize_y;
970 pos_y += tmp_y + 1.5 * sbar_fontsize_y;
972 // rgb := tempvector :)
973 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
974 pos_y += 3 * sbar_fontsize_y;
976 for(pl = players.sort_next; pl; pl = pl.sort_next)
978 if(pl.team != COLOR_SPECTATOR)
980 //drawcolorcodedstring(pos, getplayerkey(pl.sb_player, "name"), '8 8 0', 1, 0);
981 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
982 pos += '0 1.25 0' * sbar_fontsize_y;
987 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
990 for(pl = players.sort_next; pl; pl = pl.sort_next)
992 if(pl.team == COLOR_SPECTATOR)
994 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
995 pos_y += 1.25 * sbar_fontsize_y;
996 tmp_y -= 1.25 * sbar_fontsize_y;
999 // rgb := tempvector :)
1000 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
1001 pos_y += 3 * sbar_fontsize_y;
1003 for(pl = players.sort_next; pl; pl = pl.sort_next)
1005 if(pl.team != COLOR_SPECTATOR)
1007 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
1008 pos += '0 1.25 0' * sbar_fontsize_y;
1013 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
1018 str = strcat("playing on ^2", shortmapname, "^7");
1019 tl = getstatf(STAT_TIMELIMIT);
1020 fl = getstatf(STAT_FRAGLIMIT);
1021 if(gametype == GAME_LMS)
1024 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
1029 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
1033 str = strcat(str, " or");
1036 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
1037 if(teamscores_label[ts_primary] == "score")
1038 str = strcat(str, " points^7");
1039 else if(teamscores_label[ts_primary] == "fastest")
1040 str = strcat(str, " is beaten^7");
1042 str = strcat(str, " ", teamscores_label[ts_primary]);
1046 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
1047 if(scores_label[ps_primary] == "score")
1048 str = strcat(str, " points^7");
1049 else if(scores_label[ps_primary] == "fastest")
1050 str = strcat(str, " is beaten^7");
1052 str = strcat(str, " ", scores_label[ps_primary]);
1058 pos_y += 1.5 * sbar_fontsize_y;
1059 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, 0);
1064 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
1072 if(histime == 0) // goal hit
1076 timestr = strcat("+", ftos_decimals(+mytime, 1));
1079 else if(mytime == 0)
1086 timestr = strcat("-", ftos_decimals(-mytime, 1));
1092 lapstr = strcat(" (-", ftos(lapdelta), "L)");
1095 else if(lapdelta < 0)
1097 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
1101 else if(histime > 0) // anticipation
1103 if(mytime >= histime)
1104 timestr = strcat("+", ftos_decimals(mytime - histime, 1));
1106 timestr = mmsss(histime * 10);
1113 cpname = strcat("Intermediate ", ftos(cp));
1115 cpname = "Finish line";
1118 return strcat(col, cpname);
1119 else if(hisname == "")
1120 return strcat(col, cpname, " (", timestr, ")");
1122 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
1125 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
1129 void Sbar_Score(float margin)
1131 float timelimit, timeleft, minutes, seconds, distribution, myplace, score;
1132 vector sbar_save, place;
1136 myteam = GetPlayerColor(player_localentnum - 1);
1138 sbar_y = vid_conheight - (32+12);
1141 place = '-48 -12 0';
1146 // team1 team3 team4
1149 //for(i = 0; i < 4; ++i)
1150 for(tm = teams.sort_next; tm; tm = tm.sort_next)
1152 if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
1155 score = tm.(teamscores[ts_primary]);
1156 if(tm.team == myteam)
1157 Sbar_DrawXNum('-128 0 0', score, 4, 32, GetTeamRGB(tm.team), 1, DRAWFLAG_NORMAL);
1160 Sbar_DrawXNum(place, score, 4, 12, GetTeamRGB(tm.team), 1, DRAWFLAG_NORMAL);
1165 // me vector := [team/connected frags id]
1167 for(me = players.sort_next; me; me = me.sort_next)
1169 if(me.team != COLOR_SPECTATOR)
1171 if(me.sv_entnum == player_localentnum - 1)
1179 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
1184 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1185 else if(myplace == 2)
1186 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 1 0', 1, DRAWFLAG_NORMAL);
1188 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 0 0', 1, DRAWFLAG_NORMAL);
1190 score = me.(scores[ps_primary]);
1191 if(distribution >= 0)
1193 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 1 1', 1, DRAWFLAG_NORMAL);
1194 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 1 1', 1, DRAWFLAG_NORMAL);
1195 } else if(distribution >= -5)
1197 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 1 0', 1, DRAWFLAG_NORMAL);
1198 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 1 0', 1, DRAWFLAG_NORMAL);
1200 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 0 0', 1, DRAWFLAG_NORMAL);
1201 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 0 0', 1, DRAWFLAG_NORMAL);
1204 timelimit = getstatf(STAT_TIMELIMIT);
1207 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1208 timeleft = ceil(timeleft);
1209 minutes = floor(timeleft / 60);
1210 seconds = timeleft - minutes*60;
1213 Sbar_DrawXNum('-72 32 0', minutes, 3, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1214 drawpic(sbar + '-36 32 0', "gfx/num_colon", '12 12 0', '1 1 1', sbar_alpha_fg, 0);
1215 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1216 } else if(minutes >= 1)
1218 Sbar_DrawXNum('-72 32 0', minutes, 3, 12, '1 1 0', 1, DRAWFLAG_NORMAL);
1219 drawpic(sbar + '-36 32 0', "gfx/num_colon", '12 12 0', '1 1 0', sbar_alpha_fg, 0);
1220 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, '1 1 0', 1, DRAWFLAG_NORMAL);
1222 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, '1 0 0', 1, DRAWFLAG_NORMAL);
1225 minutes = floor(time / 60);
1226 seconds = floor(time - minutes*60);
1227 Sbar_DrawXNum('-72 32 0', minutes, 3, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1228 drawpic(sbar + '-36 32 0', "gfx/num_colon", '12 12 0', '1 1 1', sbar_alpha_fg, 0);
1229 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1232 if(gametype == GAME_RACE)
1234 drawfont = sbar_bigfont;
1237 string s, forcetime;
1239 m = '0.5 0 0' * vid_conwidth + '0 0.25 0' * vid_conheight;
1241 if(race_checkpointtime)
1244 a = bound(0, 2 - (time - race_checkpointtime), 1);
1247 if(a > 0) // just hit a checkpoint?
1249 if(race_time && race_previousbesttime)
1250 s = MakeRaceString(race_checkpoint, race_time / 10 - race_previousbesttime / 10, 0, 0, race_previousbestname);
1252 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
1254 forcetime = mmsss(race_time);
1258 if(race_laptime && race_nextbesttime)
1260 a = bound(0, 2 - ((race_laptime + race_nextbesttime/10) - time), 1);
1261 if(a > 0) // next one?
1263 s = MakeRaceString(race_nextcheckpoint, time - race_laptime, race_nextbesttime / 10, 0, race_nextbestname);
1268 if(s != "" && a > 0)
1270 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1271 drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1277 a = bound(0, 1 - 2 * (time - race_checkpointtime), 1);
1278 sz = 1.2 / (a + 0.2);
1279 drawstring(m - '0 0 0' - '0 16 0' * (sz - 1) - '16 0 0' * sz * stringwidth(forcetime, FALSE), forcetime, '32 32 0' * sz, '1 1 1', sbar_alpha_fg * a, 0);
1287 s = mmsss(10*(time - race_laptime));
1288 drawstring(m - '0 0 0' - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, 0);
1293 if(race_mycheckpointtime)
1295 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
1296 s = MakeRaceString(race_mycheckpoint, race_mycheckpointdelta / 10, -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
1297 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1298 drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1300 if(race_othercheckpointtime && race_othercheckpointenemy != "")
1302 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
1303 s = MakeRaceString(race_othercheckpoint, -race_othercheckpointdelta / 10, -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
1304 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1305 drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, 0);
1309 drawfont = sbar_font;
1315 void Sbar_MiniscoreItem(vector pos, entity pl, float is_self)
1321 drawfill(pos + '0 1 0', '40 6 0', GetTeamRGB(pl.team)*0.5, 1, DRAWFLAG_NORMAL);
1323 drawfill(pos + '0 1 0', '40 6 0', '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
1326 score = pl.(scores[ps_primary]);
1327 pos_x -= stringwidth(ftos(score), FALSE)*8;
1328 drawstring(pos, ftos(score), '8 8 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1333 drawstring(pos, "\x0D", '8 8 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1337 drawcolorcodedstring(pos, getplayerkey(pl.sv_entnum, "name"), '8 8 0', 1, 0);
1340 void Sbar_MiniscoreTeamItem(vector pos, float color, float frags, float is_self)
1346 drawfill(pos + '0 1 0', '40 6 0', GetTeamRGB(color)*0.5, 1, DRAWFLAG_NORMAL);
1348 drawfill(pos + '0 1 0', '40 6 0', '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
1351 pos_x -= stringwidth(ftos(frags), FALSE)*8;
1352 drawstring(pos, ftos(frags), '8 8 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1357 drawstring(pos, "\x0D", '8 8 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1361 drawstring(pos, GetTeamName(color), '8 8 0', '1 1 1', 1, DRAWFLAG_NORMAL);
1364 void Sbar_MiniDeathmatchOverlay(vector pos)
1366 float numlines, up, down, score;
1368 float miniscoreboard_size;
1369 miniscoreboard_size = cvar("sbar_miniscoreboard_size");
1371 if(miniscoreboard_size == 0)
1373 pos_y = vid_conheight - 8;
1375 if(miniscoreboard_size < 0)
1376 numlines = (vid_conheight - sbar_y + 7) / 8;
1378 numlines = miniscoreboard_size;
1380 // give up if there isn't enough room
1381 if(pos_x >= vid_conwidth || pos_y >= vid_conheight || numlines < 1)
1384 // me vector := [team/connected frags id]
1385 for(me = players.sort_next; me; me = me.sort_next)
1387 if(me.sv_entnum == player_localentnum - 1)
1392 numlines -= numteams;
1394 // figure out how many players above and below we can show
1395 up = floor(numlines/2);
1397 if((up + down) > numlines)
1398 down = numlines - up;
1401 for(pl = me.sort_next; pl && down > 0; pl = pl.sort_next)
1403 if(pl.team == COLOR_SPECTATOR)
1405 Sbar_MiniscoreItem(pos, pl, false);
1409 Sbar_MiniscoreItem(pos, me, true);
1411 up += down; // if there weren't enough lines below... add them
1412 for(pl = me.sort_prev; pl && up > 0; pl = pl.sort_prev)
1414 if(pl.team == COLOR_SPECTATOR)
1416 Sbar_MiniscoreItem(pos, pl, false);
1423 for(tm = teams.sort_next; tm.sort_next; tm = tm.sort_next);
1424 for(; tm; tm = tm.sort_prev)
1426 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
1428 score = tm.(teamscores[ts_primary]);
1429 Sbar_MiniscoreTeamItem(pos, tm.team, score, (tm.team == me.team));
1435 float Sbar_WouldDrawScoreboard ()
1439 else if (intermission == 1)
1441 else if (intermission == 2)
1443 else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
1445 else if(sb_showscores_force)
1450 vector Sbar_DrawNoteLine(vector offset, string s)
1452 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1453 drawcolorcodedstring(
1454 offset - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
1460 return offset + sbar_fontsize_y * '0 1 0';
1463 void Sbar_Draw (void)
1467 float stat_items, stat_weapons;
1468 vector o; o = '1 0 0' * vid_conwidth;
1471 sbar_fontsize = Sbar_GetFontsize();
1473 if(spectatee_status)
1475 if(spectatee_status == -1)
1478 s = strcat("^1Spectating ^7", getplayerkey(spectatee_status - 1, "name"));
1479 o = Sbar_DrawNoteLine(o, s);
1481 if(spectatee_status == -1)
1482 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
1484 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
1485 o = Sbar_DrawNoteLine(o, s);
1487 if(spectatee_status == -1)
1488 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
1490 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
1491 o = Sbar_DrawNoteLine(o, s);
1493 if(gametype == GAME_ARENA)
1494 s = "^1Wait for your turn to join";
1495 else if(gametype == GAME_LMS)
1498 sk = playerslots[player_localentnum - 1];
1499 if(sk.(scores[ps_primary]) >= 666)
1500 s = "^1Match has already begun";
1501 else if(sk.(scores[ps_primary]) > 0)
1502 s = "^1You have no more lives left";
1504 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1507 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1508 o = Sbar_DrawNoteLine(o, s);
1512 if(mod(time, 1) >= 0.5)
1519 s = "^2Currently in ^1warmup^2 stage!";
1520 o = Sbar_DrawNoteLine(o, s);
1524 if(ready_waiting_for_me)
1527 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
1529 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
1534 s = strcat("^2Waiting for others to ready up to end warmup...");
1536 s = strcat("^2Waiting for others to ready up...");
1538 o = Sbar_DrawNoteLine(o, s);
1540 else if(warmup_stage)
1542 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
1543 o = Sbar_DrawNoteLine(o, s);
1547 s = strcat("^2A vote has been called for ^1", vote_called_vote);
1548 o = Sbar_DrawNoteLine(o, s);
1550 if(vote_waiting_for_me)
1552 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote yes", "vyes"), blinkcolor, " to accept");
1553 o = Sbar_DrawNoteLine(o, s);
1555 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote no", "vno"), blinkcolor, " to reject");
1556 o = Sbar_DrawNoteLine(o, s);
1558 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote abstain", "vabstain"), blinkcolor, " to abstain");
1559 o = Sbar_DrawNoteLine(o, s);
1563 s = strcat("^2Waiting for others to vote...");
1564 o = Sbar_DrawNoteLine(o, s);
1569 Sbar_UpdatePlayerTeams();
1574 Sbar_DrawScoreboard();
1575 else if (intermission == 1)
1577 Sbar_DrawScoreboard();
1580 else if (intermission == 2)
1581 Sbar_FinaleOverlay();
1584 if (sb_showscores || sb_showscores_force || (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard")))
1586 sbar_x = (vid_conwidth - 640.0)*0.5;
1587 sbar_y = vid_conheight - 47;
1588 //Sbar_DrawAlphaPic (sbar_x, sbar_y, sb_scorebar, sbar_alpha_bg.value);
1589 //drawpic('0 0 0', "gfx/scorebar", '0 0 0', '1 1 1', cvar("sbar_alpha_bg"), 0);
1590 Sbar_DrawScoreboard ();
1594 if (sb_lines && sbar_hudselector == 1)
1596 stat_items = getstati(STAT_ITEMS);
1597 stat_weapons = getstati(STAT_WEAPONS);
1599 sbar_x = (vid_conwidth - 320.0)*0.5;
1600 sbar_y = vid_conheight - 24.0 - 16.0;
1603 fade = 3.2 - 2 * (time - weapontime);
1604 fade = bound(0.7, fade, 1);
1607 Sbar_DrawWeapon_Clear();
1608 for(i = 1; i <= 24; ++i)
1610 if(weaponimpulse[i-1] >= 0)
1611 if(stat_weapons & x)
1613 Sbar_DrawWeapon(i-1, fade, (i == activeweapon));
1619 x = getstati(STAT_ARMOR);
1623 //Sbar_DrawStretchPic (72, 0, sb_armor[0], sbar_alpha_fg.value, 24, 24);
1624 drawpic(sbar + '72 0 0', "gfx/sb_armor", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1626 Sbar_DrawXNum('0 0 0', x, 3, 24, '0 1 0', 1, 0);
1628 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.2 1 0', 1, 0);
1630 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1632 Sbar_DrawXNum('0 0 0', x, 3, 24, '1 1 0.2', 1, 0);
1634 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1638 x = getstati(STAT_HEALTH);
1642 //Sbar_DrawStretchPic (184, 0, sb_health, sbar_alpha_fg.value, 24, 24);
1643 drawpic(sbar + '184 0 0', "gfx/sb_health", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1645 Sbar_DrawXNum('112 0 0', x, 3, 24, '0 1 0', 1, 0);
1647 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.2 1 0', 1, 0);
1649 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1651 Sbar_DrawXNum('112 0 0', x, 3, 24, '1 1 0.2', 1, 0);
1653 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1657 x = getstati(STAT_AMMO);
1658 if ((stat_items & IT_AMMO) || x != 0)
1660 if (stat_items & IT_SHELLS)
1661 drawpic(sbar + '296 0 0', "gfx/sb_shells", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1662 else if (stat_items & IT_NAILS)
1663 drawpic(sbar + '296 0 0', "gfx/sb_bullets", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1664 else if (stat_items & IT_ROCKETS)
1665 drawpic(sbar + '296 0 0', "gfx/sb_rocket", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1666 else if (stat_items & IT_CELLS)
1667 drawpic(sbar + '296 0 0', "gfx/sb_cells", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1669 Sbar_DrawXNum('224 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1671 Sbar_DrawXNum('224 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1674 if (sbar_x + 320 + 160 <= vid_conwidth)
1675 Sbar_MiniDeathmatchOverlay(sbar + '320 0 0');
1678 // The margin can be at most 8 to support 640x480 console size:
1679 // 320 + 2 * (144 + 16) = 640
1684 stat_items = getstati(STAT_ITEMS);
1685 stat_weapons = getstati(STAT_WEAPONS);
1687 sbar_x = (vid_conwidth - 640.0)*0.5;
1688 sbar_y = vid_conheight - 47;
1691 fade = 3 - 2 * (time - weapontime);
1694 Sbar_DrawWeapon_Clear();
1695 for(i = 1; i <= 24; ++i)
1697 if(weaponimpulse[i-1] >= 0)
1698 if(stat_weapons & x)
1700 Sbar_DrawWeapon(i-1, fade, (i == activeweapon));
1706 drawpic(sbar, "gfx/sbar", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1708 drawpic(sbar, "gfx/sbar_minimal", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1712 Sbar_DrawXNum('268 12 0', getstati(STAT_ARMOR), 3, 24, '0.6 0.7 0.8', 1, 0);
1716 x = getstati(STAT_HEALTH);
1718 Sbar_DrawXNum('82 12 0', x, 3, 24, '1 1 1', 1, 0);
1719 else if(x <= 25 && time - floor(time) > 0.5)
1720 Sbar_DrawXNum('82 12 0', x, 3, 24, '0.7 0 0', 1, 0);
1722 Sbar_DrawXNum('81 12 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1724 // AK dont draw ammo for the laser
1725 x = getstati(STAT_AMMO);
1726 if(activeweapon != 12)
1729 if (stat_items & IT_SHELLS)
1730 drawpic(sbar + '519 0 0', "gfx/sb_shells", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1731 else if (stat_items & IT_NAILS)
1732 drawpic(sbar + '519 0 0', "gfx/sb_bullets", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1733 else if (stat_items & IT_ROCKETS)
1734 drawpic(sbar + '519 0 0', "gfx/sb_rocket", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1735 else if (stat_items & IT_CELLS)
1736 drawpic(sbar + '519 0 0', "gfx/sb_cells", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1738 Sbar_DrawXNum('447 12 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1740 Sbar_DrawXNum('447 12 0', x, 3, 24, '0.7 0 0', 1, 0);
1744 drawpic(sbar, "gfx/sbar_overlay", '0 0 0', '1 1 1', 1, DRAWFLAG_MODULATE);
1746 if (sbar_x + 600 + 160 <= vid_conwidth)
1747 Sbar_MiniDeathmatchOverlay (sbar + '600 0 0');
1752 // Mini scoreboard uses 12*4 per other team, that is, 144
1753 // pixels when there are four teams...
1754 // Nexuiz by default sets vid_conwidth to 800... makes
1756 // so we need to shift it by 64 pixels to the right to fit
1757 // BUT: then it overlaps with the image that gets drawn
1758 // for viewsize 100! Therefore, just account for 3 teams,
1759 // that is, 96 pixels mini scoreboard size, needing 16 pixels
1764 if(gametype == GAME_KEYHUNT)
1767 } else if(gametype == GAME_CTF)
1775 void CSQC_ctf_hud(void)
1777 // cvar("sbar_flagstatus_right") move the flag icons right
1778 // cvar("sbar_flagstatus_pos") pixel position of the nexuiz flagstatus icons
1779 float redflag, blueflag;
1783 stat_items = getstati(STAT_ITEMS);
1784 redflag = (stat_items/32768) & 3;
1785 blueflag = (stat_items/131072) & 3;
1789 * For some reason now not even THAT works there...
1790 * Maybe the minus' precedence screws it up? The last one there, maybe I should use brackets
1792 * pos_x = (cvar("sbar_flagstatus_right")) ? vid_conwidth - 10 - sbar_x - 64 : 10 - sbar_x;
1793 ** Should try those later:
1794 * pos_x = (cvar("sbar_flagstatus_right")) ? (vid_conwidth - 10 - sbar_x - 64) : (10 - sbar_x);
1795 * pos_x = ( (cvar("sbar_flagstatus_right")) ? vid_conwidth - 10 - 64 : 10 ) - sbar_x;
1798 if(cvar("sbar_flagstatus_right"))
1799 pos_x = vid_conwidth - 10 - sbar_x - 64;
1801 pos_x = 10 - sbar_x;
1805 if(sbar_hudselector == 1)
1806 pos_y = (vid_conheight - sbar_y) - cvar("sbar_flagstatus_pos") - 64;
1814 case 1: drawpic(pos, "gfx/sb_flag_red_taken", '0 0 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
1815 case 2: drawpic(pos, "gfx/sb_flag_red_lost", '0 0 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
1816 case 3: drawpic(pos, "gfx/sb_flag_red_carrying", '0 0 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
1823 case 1: drawpic(pos, "gfx/sb_flag_blue_taken", '0 0 0', '1 1 1', 1, 0); break;
1824 case 2: drawpic(pos, "gfx/sb_flag_blue_lost", '0 0 0', '1 1 1', 1, 0); break;
1825 case 3: drawpic(pos, "gfx/sb_flag_blue_carrying", '0 0 0', '1 1 1', 1, 0); break;