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
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), " ");
405 drawfont = sbar_font;
406 digit = stringwidth("0123456789", FALSE) / 10;
408 subpattern = strcat(",", GametypeNameFromType(gametype), ",");
410 subpattern2 = ",teams,";
412 subpattern2 = ",noteams,";
414 for(i = 0; i < argc - 1; ++i)
418 slash = strstrofs(str, "/", 0);
421 pattern = substring(str, 0, slash);
422 str = substring(str, slash + 1, strlen(str) - (slash + 1));
424 if(substring(pattern, 0, 1) == "-")
426 pattern = substring(pattern, 1, strlen(pattern) - 1);
427 if(strstrofs(strcat(",", pattern, ","), subpattern, 0) >= 0)
429 if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) >= 0)
434 if(substring(pattern, 0, 1) == "+")
435 pattern = substring(pattern, 1, strlen(pattern) - 1);
436 if(strstrofs(strcat(",", pattern, ","), subpattern, 0) < 0)
437 if(strstrofs(strcat(",", pattern, ","), subpattern2, 0) < 0)
442 strunzone(sbar_title[sbar_num_fields]);
443 sbar_title[sbar_num_fields] = strzone(str);
444 sbar_size[sbar_num_fields] = stringwidth(str, FALSE);
445 str = strtolower(str);
448 sbar_field[sbar_num_fields] = SP_PING;
449 } else if(str == "pl") {
450 sbar_field[sbar_num_fields] = SP_PL;
451 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
452 sbar_field[sbar_num_fields] = SP_KDRATIO;
453 } else if(str == "name" || str == "nick") {
454 sbar_field[sbar_num_fields] = SP_NAME;
455 sbar_size[sbar_num_fields] = MIN_NAMELEN; // minimum size? any use?
457 } else if(str == "|") {
458 sbar_field[sbar_num_fields] = SP_SEPARATOR;
461 for(j = 0; j < MAX_SCORE; ++j)
462 if(str == strtolower(scores_label[j]))
463 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
471 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
475 sbar_field[sbar_num_fields] = j;
478 if(j == ps_secondary)
482 if(sbar_num_fields >= MAX_SBAR_FIELDS)
486 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
488 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
490 if(ps_primary == ps_secondary)
492 missing = !have_primary + !have_secondary + !have_separator + !have_name;
494 if(sbar_num_fields+missing < MAX_SBAR_FIELDS)
498 strunzone(sbar_title[sbar_num_fields]);
499 for(i = sbar_num_fields; i > 0; --i)
501 sbar_title[i] = sbar_title[i-1];
502 sbar_size[i] = sbar_size[i-1];
503 sbar_field[i] = sbar_field[i-1];
505 sbar_title[0] = strzone("name");
506 sbar_field[0] = SP_NAME;
507 sbar_size[0] = MIN_NAMELEN; // minimum size? any use?
509 print("fixed missing field 'name'\n");
513 strunzone(sbar_title[sbar_num_fields]);
514 for(i = sbar_num_fields; i > 1; --i)
516 sbar_title[i] = sbar_title[i-1];
517 sbar_size[i] = sbar_size[i-1];
518 sbar_field[i] = sbar_field[i-1];
520 sbar_title[1] = strzone("|");
521 sbar_field[1] = SP_SEPARATOR;
522 sbar_size[1] = stringwidth("|", FALSE);
524 print("fixed missing field '|'\n");
527 else if(!have_separator)
529 strunzone(sbar_title[sbar_num_fields]);
530 sbar_title[sbar_num_fields] = strzone("|");
531 sbar_size[sbar_num_fields] = stringwidth("|", FALSE);
532 sbar_field[sbar_num_fields] = SP_SEPARATOR;
534 print("fixed missing field '|'\n");
539 strunzone(sbar_title[sbar_num_fields]);
540 sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);
541 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
542 sbar_field[sbar_num_fields] = ps_secondary;
544 print("fixed missing field '", scores_label[ps_secondary], "'\n");
549 strunzone(sbar_title[sbar_num_fields]);
550 sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);
551 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE);
552 sbar_field[sbar_num_fields] = ps_primary;
554 print("fixed missing field '", scores_label[ps_primary], "'\n");
558 sbar_field[sbar_num_fields] = SP_END;
562 vector sbar_field_rgb;
563 string sbar_field_icon0;
564 string sbar_field_icon1;
565 string sbar_field_icon2;
566 vector sbar_field_icon0_rgb;
567 vector sbar_field_icon1_rgb;
568 vector sbar_field_icon2_rgb;
569 float sbar_field_icon0_alpha;
570 float sbar_field_icon1_alpha;
571 float sbar_field_icon2_alpha;
572 string Sbar_GetField(entity pl, float field)
574 float tmp, num, denom, f;
576 sbar_field_rgb = '1 1 1';
577 sbar_field_icon0 = "";
578 sbar_field_icon1 = "";
579 sbar_field_icon2 = "";
580 sbar_field_icon0_rgb = '1 1 1';
581 sbar_field_icon1_rgb = '1 1 1';
582 sbar_field_icon2_rgb = '1 1 1';
583 sbar_field_icon0_alpha = 1;
584 sbar_field_icon1_alpha = 1;
585 sbar_field_icon2_alpha = 1;
590 return "\x8D\x8D\x8D"; // >>> sign
591 str = getplayerkey(pl.sv_entnum, "ping");
594 tmp = max(0, min(220, stof(str)-80)) / 220;
595 sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
601 str = getplayerkey(pl.sv_entnum, "pl");
604 tmp = bound(0, stof(str), 20) / 20; // 20% is REALLY BAD pl
605 sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
609 if(ready_waiting && pl.ready)
611 sbar_field_icon0 = "gfx/sb_player_ready";
615 f = stof(getplayerkey(pl.sv_entnum, "colors"));
617 sbar_field_icon0 = "gfx/sb_playercolor_base";
618 sbar_field_icon1 = "gfx/sb_playercolor_shirt";
619 sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
620 sbar_field_icon2 = "gfx/sb_playercolor_pants";
621 sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
624 return GetPlayerName(pl.sv_entnum);
627 f = pl.(scores[SP_KILLS]);
628 f -= pl.(scores[SP_SUICIDES]);
632 num = pl.(scores[SP_KILLS]);
633 denom = pl.(scores[SP_DEATHS]);
636 sbar_field_rgb = '0 1 0';
638 } else if(num <= 0) {
639 sbar_field_rgb = '1 0 0';
640 str = ftos(num/denom);
642 str = ftos(num/denom);
644 tmp = strstrofs(str, ".", 0);
646 str = substring(str, 0, tmp+2);
650 tmp = pl.(scores[field]);
651 f = scores_flags[field];
652 if(field == ps_primary)
653 sbar_field_rgb = '1 1 0';
654 else if(field == ps_secondary)
655 sbar_field_rgb = '0 1 1';
657 sbar_field_rgb = '1 1 1';
658 return ScoreString(f, tmp);
663 float xmin, xmax, ymin, ymax, sbwidth;
664 float sbar_fixscoreboardcolumnwidth_len;
665 float sbar_fixscoreboardcolumnwidth_iconlen;
666 float sbar_fixscoreboardcolumnwidth_marginlen;
668 float stringwidth_colors(string s)
670 return stringwidth(s, TRUE);
673 float stringwidth_nocolors(string s)
675 return stringwidth(s, FALSE);
678 string Sbar_FixScoreboardColumnWidth(float i, string str)
680 float field, maxsize, j, f;
682 field = sbar_field[i];
684 if(field == SP_NAME) // name gets all remaining space
686 maxsize = (xmax - xmin) / sbar_fontsize_x;
687 for(j = 0; j < sbar_num_fields; ++j) if(j != i) if(sbar_field[j] != SP_SEPARATOR)
688 maxsize -= sbar_size[j] + 1;
690 str = textShortenToWidth(str, maxsize, stringwidth_colors);
691 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE);
694 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE);
696 sbar_fixscoreboardcolumnwidth_iconlen = 0;
698 if(sbar_field_icon0 != "")
700 sz = drawgetimagesize(sbar_field_icon0);
702 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
703 sbar_fixscoreboardcolumnwidth_iconlen = f;
706 if(sbar_field_icon1 != "")
708 sz = drawgetimagesize(sbar_field_icon1);
710 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
711 sbar_fixscoreboardcolumnwidth_iconlen = f;
714 if(sbar_field_icon2 != "")
716 sz = drawgetimagesize(sbar_field_icon2);
718 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
719 sbar_fixscoreboardcolumnwidth_iconlen = f;
722 sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect
724 if(sbar_fixscoreboardcolumnwidth_iconlen != 0 && sbar_fixscoreboardcolumnwidth_len != 0)
725 sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE);
727 sbar_fixscoreboardcolumnwidth_marginlen = 0;
729 f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
736 void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self)
742 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
749 tmp_y = sbar_fontsize_y;
750 drawfill(pos - '1 1 0', tmp + '2 2 0', '1 1 1', 0.3, DRAWFLAG_NORMAL);
754 for(i = 0; i < sbar_num_fields; ++i)
756 field = sbar_field[i];
757 if(field == SP_SEPARATOR)
760 if(is_spec && field != SP_NAME && field != SP_PING) {
761 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
764 str = Sbar_GetField(pl, field);
765 str = Sbar_FixScoreboardColumnWidth(i, str);
767 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
769 if(field == SP_NAME) {
770 tmp_x = sbar_fontsize_x*(sbar_size[i] - sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen) + sbar_fontsize_x;
771 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
773 tmp_x = sbar_fixscoreboardcolumnwidth_len*sbar_fontsize_x + sbar_fontsize_x;
774 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
777 tmp_x = sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
778 if(sbar_field_icon0 != "")
779 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);
780 if(sbar_field_icon1 != "")
781 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);
782 if(sbar_field_icon2 != "")
783 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);
786 if(sbar_field[i] == SP_SEPARATOR)
789 for(i = sbar_num_fields-1; i > 0; --i)
791 field = sbar_field[i];
792 if(field == SP_SEPARATOR)
795 if(is_spec && field != SP_NAME && field != SP_PING) {
796 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
800 str = Sbar_GetField(pl, field);
801 str = Sbar_FixScoreboardColumnWidth(i, str);
803 if(field == SP_NAME) {
804 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
805 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, 1, DRAWFLAG_NORMAL);
807 tmp_x = sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_len; //strlen(str);
808 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, 1, DRAWFLAG_NORMAL);
811 tmp_x = sbar_fontsize_x*sbar_size[i];
812 if(sbar_field_icon0 != "")
813 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);
814 if(sbar_field_icon1 != "")
815 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);
816 if(sbar_field_icon2 != "")
817 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);
819 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
825 float scoreboard_bottom;
826 void Sbar_DrawScoreboard()
828 //float xmin, ymin, xmax, ymax;
829 vector rgb, pos, tmp, sbar_save;
834 if(time > lastpingstime + 10)
837 lastpingstime = time;
840 sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);
842 xmin = 0.5 * (vid_conwidth - sbwidth);
845 xmax = vid_conwidth - xmin;
846 ymax = vid_conheight - 0.2*vid_conheight;
848 center_x = xmin + 0.5*sbwidth;
850 //Sbar_UpdateFields();
852 // Initializes position
858 drawfont = sbar_bigfont;
859 pos_x = center_x - stringwidth("Scoreboard", TRUE)*0.5*24;
860 drawstring(pos, "Scoreboard", '24 24 0', '1 1 1', 1, DRAWFLAG_NORMAL);
864 // Titlebar background:
866 tmp_y = sbar_fontsize_y;
867 drawfill(pos - '1 1 0', tmp + '2 2 0', '0.5 0.5 0.5', 0.5, DRAWFLAG_NORMAL);
869 drawfont = sbar_font;
871 for(i = 0; i < sbar_num_fields; ++i)
873 if(sbar_field[i] == SP_SEPARATOR)
875 drawstring(pos, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
876 pos_x += sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
879 if(sbar_field[i] == SP_SEPARATOR)
881 pos_x = xmax + sbar_fontsize_x;
883 for(i = sbar_num_fields-1; i > 0; --i)
885 if(sbar_field[i] == SP_SEPARATOR)
888 pos_x -= sbar_fontsize_x*sbar_size[i] + sbar_fontsize_x;
891 * Using the following line will mess it all up:
893 * tmp_x = sbar_size[i] - strlen(sbar_title[i])*8;
895 tmp_x = sbar_fontsize_x*sbar_size[i];
896 tmp_x -= stringwidth(sbar_title[i], FALSE)*sbar_fontsize_x;
897 drawstring(pos + tmp, sbar_title[i], sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
902 pos_y += 1.5 * sbar_fontsize_y;
909 //for(tm = sortedTeams.sort_next; tm; tm = tm.sort_next)
910 for(tm = teams.sort_next; tm; tm = tm.sort_next)
912 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
915 rgb = GetTeamRGB(tm.team);
920 pos - '6.5 0 0' * sbar_fontsize_y,
921 tm.(teamscores[ts_primary]),
922 4, sbar_fontsize_y * 1.5, rgb, 1, DRAWFLAG_NORMAL);
924 if(ts_primary != ts_secondary)
926 pos - '4.5 0 0' * sbar_fontsize_y + '0 1.5 0' * sbar_fontsize_y,
927 tm.(teamscores[ts_secondary]),
928 4, sbar_fontsize_y * 1, rgb, 1, DRAWFLAG_NORMAL);
930 specs = tm.team_size;
936 tmp_y = 1.25 * sbar_fontsize_y * specs;
937 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, 0.2, DRAWFLAG_NORMAL);
939 for(pl = players.sort_next; pl; pl = pl.sort_next)
941 if(pl.team != tm.team)
943 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
944 pos_y += 1.25 * sbar_fontsize_y;
945 tmp_y -= 1.25 * sbar_fontsize_y;
947 pos_y += tmp_y + 1.5 * sbar_fontsize_y;
949 // rgb := tempvector :)
950 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
951 pos_y += 3 * sbar_fontsize_y;
953 for(pl = players.sort_next; pl; pl = pl.sort_next)
955 if(pl.team != COLOR_SPECTATOR)
957 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
958 pos += '0 1.25 0' * sbar_fontsize_y;
963 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
966 for(pl = players.sort_next; pl; pl = pl.sort_next)
968 if(pl.team == COLOR_SPECTATOR)
970 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
971 pos_y += 1.25 * sbar_fontsize_y;
972 tmp_y -= 1.25 * sbar_fontsize_y;
975 // rgb := tempvector :)
976 rgb = pos + '0 1.5 0' * sbar_fontsize_y;
977 pos_y += 3 * sbar_fontsize_y;
979 for(pl = players.sort_next; pl; pl = pl.sort_next)
981 if(pl.team != COLOR_SPECTATOR)
983 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1));
984 pos += '0 1.25 0' * sbar_fontsize_y;
989 drawstring(rgb, "Spectators", sbar_fontsize, '1 1 1', 1, 0);
994 str = strcat("playing on ^2", shortmapname, "^7");
995 tl = getstatf(STAT_TIMELIMIT);
996 fl = getstatf(STAT_FRAGLIMIT);
997 if(gametype == GAME_LMS)
1000 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
1005 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
1009 str = strcat(str, " or");
1012 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
1013 if(teamscores_label[ts_primary] == "score")
1014 str = strcat(str, " points^7");
1015 else if(teamscores_label[ts_primary] == "fastest")
1016 str = strcat(str, " is beaten^7");
1018 str = strcat(str, " ", teamscores_label[ts_primary]);
1022 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
1023 if(scores_label[ps_primary] == "score")
1024 str = strcat(str, " points^7");
1025 else if(scores_label[ps_primary] == "fastest")
1026 str = strcat(str, " is beaten^7");
1028 str = strcat(str, " ", scores_label[ps_primary]);
1034 pos_y += 1.2 * sbar_fontsize_y;
1035 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - sbar_fontsize_x * stringwidth(str, TRUE)), str, sbar_fontsize, 0.8, 0);
1038 scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;
1041 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
1049 if(histime == 0) // goal hit
1053 timestr = strcat("+", ftos_decimals(+mytime, 1));
1056 else if(mytime == 0)
1063 timestr = strcat("-", ftos_decimals(-mytime, 1));
1069 lapstr = strcat(" (-", ftos(lapdelta), "L)");
1072 else if(lapdelta < 0)
1074 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
1078 else if(histime > 0) // anticipation
1080 if(mytime >= histime)
1081 timestr = strcat("+", ftos_decimals(mytime - histime, 1));
1083 timestr = mmsss(histime * 10);
1090 cpname = strcat("Intermediate ", ftos(cp));
1092 cpname = "Finish line";
1095 return strcat(col, cpname);
1096 else if(hisname == "")
1097 return strcat(col, cpname, " (", timestr, ")");
1099 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
1102 void dummyfunction(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8)
1106 void Sbar_Score(float margin)
1108 float timelimit, minutes, seconds, timeleft, minutesLeft, secondsLeft, distribution, myplace, score;
1109 vector sbar_save, place, timer_color;
1113 myteam = GetPlayerColor(player_localentnum - 1);
1115 sbar_y = vid_conheight - (32+12);
1118 place = '-48 -12 0';
1123 // team1 team3 team4
1126 //for(i = 0; i < 4; ++i)
1127 for(tm = teams.sort_next; tm; tm = tm.sort_next)
1129 if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
1132 score = tm.(teamscores[ts_primary]);
1133 if(tm.team == myteam)
1134 Sbar_DrawXNum('-128 0 0', score, 4, 32, GetTeamRGB(tm.team), 1, DRAWFLAG_NORMAL);
1137 Sbar_DrawXNum(place, score, 4, 12, GetTeamRGB(tm.team), 1, DRAWFLAG_NORMAL);
1142 // me vector := [team/connected frags id]
1144 for(me = players.sort_next; me; me = me.sort_next)
1146 if(me.team != COLOR_SPECTATOR)
1148 if(me.sv_entnum == player_localentnum - 1)
1156 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
1161 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 1 1', 1, DRAWFLAG_NORMAL);
1162 else if(myplace == 2)
1163 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 1 0', 1, DRAWFLAG_NORMAL);
1165 Sbar_DrawXNum('-36 -12 0', myplace, 3, 12, '1 0 0', 1, DRAWFLAG_NORMAL);
1167 score = me.(scores[ps_primary]);
1168 if(distribution >= 0)
1170 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 1 1', 1, DRAWFLAG_NORMAL);
1171 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 1 1', 1, DRAWFLAG_NORMAL);
1172 } else if(distribution >= -5)
1174 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 1 0', 1, DRAWFLAG_NORMAL);
1175 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 1 0', 1, DRAWFLAG_NORMAL);
1177 Sbar_DrawXNum('-84 -12 0', distribution, 4, 12, ' 1 0 0', 1, DRAWFLAG_NORMAL);
1178 Sbar_DrawXNum('-128 0 0', score, 4, 32, '1 0 0', 1, DRAWFLAG_NORMAL);
1182 //draw the remaining or elapsed time
1183 timelimit = getstatf(STAT_TIMELIMIT);
1186 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
1187 timeleft = ceil(timeleft);
1188 minutesLeft = floor(timeleft / 60);
1189 secondsLeft = timeleft - minutesLeft*60;
1191 if(minutesLeft >= 5) {
1192 timer_color = '1 1 1'; //white
1193 } else if(minutesLeft >= 1) {
1194 timer_color = '1 1 0'; //yellow
1196 timer_color = '1 0 0'; //red
1200 timer_color = '1 1 1'; //don't use red or yellow for timer during warmup
1203 if (cvar("sbar_increment_maptime")) {
1204 if (time < getstatf(STAT_GAMESTARTTIME)) {
1205 //while restart is still active, show negative counter
1207 seconds = ceil(getstatf(STAT_GAMESTARTTIME) - time);
1210 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
1211 minutes = floor(elapsedTime / 60);
1212 seconds = elapsedTime - minutes*60;
1215 minutes = minutesLeft;
1216 seconds = secondsLeft;
1219 if(minutesLeft >= 1 || (cvar("sbar_increment_maptime") && minutes >= 1) ) {
1220 Sbar_DrawXNum('-72 32 0', minutes, 3, 12, timer_color, 1, DRAWFLAG_NORMAL);
1221 drawpic(sbar + '-36 32 0', "gfx/num_colon", '12 12 0', timer_color, sbar_alpha_fg, 0);
1223 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, timer_color, 1, DRAWFLAG_NORMAL);
1225 timer_color = '1 1 1'; //white
1226 minutes = floor(time / 60);
1227 seconds = floor(time - minutes*60);
1228 Sbar_DrawXNum('-72 32 0', minutes, 3, 12, timer_color, 1, DRAWFLAG_NORMAL);
1229 drawpic(sbar + '-36 32 0', "gfx/num_colon", '12 12 0', timer_color, sbar_alpha_fg, 0);
1230 Sbar_DrawXNum('-24 32 0', seconds, -2, 12, timer_color, 1, DRAWFLAG_NORMAL);
1233 if(gametype == GAME_RACE)
1235 drawfont = sbar_bigfont;
1238 string s, forcetime;
1240 m = '0.5 0 0' * vid_conwidth + '0 0.25 0' * vid_conheight;
1242 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, GetPlayerName(pl.sv_entnum), '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 void CSQC_Strength_Timer() {
1452 stat_items = getstati(STAT_ITEMS);
1453 if not(stat_items & IT_STRENGTH)
1454 if not(stat_items & IT_INVINCIBLE)
1457 if (getstati(STAT_HEALTH) <= 0)
1460 vector pos, picsize, number_position;
1461 float strength_time, invincibility_time, countdown_fontsize;
1463 picsize = '40 40 0';
1464 countdown_fontsize = 22;
1466 //element will be positioned on the right side of the screen:
1467 pos_x = vid_conwidth - picsize_x - 10; //margin 10 from right border
1468 number_position_x = pos_x - 5/*margin to the left from image*/ - countdown_fontsize*2/*width of text*/;
1471 number_position_y = pos_y;
1473 //now calculate the values Sbar_DrawXNum() will be called with:
1474 number_position_x = number_position_x - sbar_x; //relative to sbar coordinates
1475 number_position_y = number_position_y - sbar_y; //relative to sbar coordinates
1476 number_position_y += 10; //center number vertically to the icon
1478 pos_z = number_position_z = 0;
1481 if (stat_items & IT_STRENGTH) {
1482 drawpic(pos, "gfx/sb_str", picsize, '0 0.086 0.953'/*strength color*/, 1, DRAWFLAG_NORMAL);
1483 strength_time = getstatf(STAT_STRENGTH_FINISHED) - time;
1484 if (strength_time > 0) { //show countdown once we received the valid stats-value
1485 Sbar_DrawXNum(number_position, ceil(strength_time), 2, countdown_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1488 //add some margin to the invincibility icon
1489 pos_y += picsize_y + 10;
1490 number_position_y += picsize_y + 10;
1494 if (stat_items & IT_INVINCIBLE) {
1495 drawpic(pos, "gfx/sb_invinc", picsize, '0.976 0 0.165'/*invincibility color*/, 1, DRAWFLAG_NORMAL);
1496 invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED) - time;
1497 if (invincibility_time > 0) { //show countdown once we received the valid stats-value
1498 Sbar_DrawXNum(number_position, ceil(invincibility_time), 2, countdown_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1503 #define CENTERPRINT_MAX_LINES 30
1504 string centerprint_messages[CENTERPRINT_MAX_LINES];
1505 float centerprint_width[CENTERPRINT_MAX_LINES];
1506 vector centerprint_start;
1507 float centerprint_expire;
1508 float centerprint_num;
1509 float centerprint_offset_hint;
1510 vector centerprint_fontsize;
1512 void centerprint(string strMessage)
1514 float i, j, n, hcount;
1517 centerprint_fontsize = Sbar_GetFontsize("scr_centersize");
1519 // delete old centerprint messages
1520 for (i=0; i<centerprint_num; ++i)
1522 if(centerprint_messages[i])
1524 strunzone(centerprint_messages[i]);
1525 centerprint_messages[i] = string_null;
1526 centerprint_width[i] = 0;
1530 if(strMessage == "")
1533 // strip trailing newlines
1534 j = strlen(strMessage) - 1;
1535 while(substring(strMessage, j, 1) == "\n" && j >= 0)
1537 strMessage = substring(strMessage, 0, j + 1);
1539 if(strMessage == "")
1542 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
1544 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
1546 strMessage = substring(strMessage, j, strlen(strMessage) - j);
1547 centerprint_offset_hint = j;
1549 // TODO if we're parsing centerprints now anyway, why not word wrap them?
1550 n = tokenizebyseparator(strMessage, "\n");
1552 for(j = 0; j < n; ++j)
1554 getWrappedLine_remaining = argv(j);
1555 while(getWrappedLine_remaining)
1557 s = getWrappedLine(vid_conwidth * 0.75 / centerprint_fontsize_x, stringwidth_colors);
1558 centerprint_messages[i] = strzone(s);
1559 centerprint_width[i] = stringwidth(s, TRUE);
1562 // half height for empty lines looks better
1568 if(i >= CENTERPRINT_MAX_LINES)
1574 h = centerprint_fontsize_y*hcount;
1576 havail = vid_conheight;
1577 if(cvar("con_chatpos") < 0)
1578 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
1580 centerprint_start_x = 0;
1583 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
1585 // here, the centerprint would cover the crosshair. REALLY BAD.
1586 forbiddenmin = vid_conheight * 0.5 - h - 16;
1587 forbiddenmax = vid_conheight * 0.5 + 16;
1589 allowedmin = scoreboard_bottom;
1590 allowedmax = havail - h;
1591 preferred = (havail - h)/2;
1594 // possible orderings (total: 4! / 4 = 6)
1595 // allowedmin allowedmax forbiddenmin forbiddenmax
1596 // forbiddenmin forbiddenmax allowedmin allowedmax
1597 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
1599 // forbidden doesn't matter in this case
1600 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
1602 // allowedmin forbiddenmin allowedmax forbiddenmax
1603 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
1605 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
1607 // allowedmin forbiddenmin forbiddenmax allowedmax
1608 else if(allowedmin < forbiddenmin)
1610 // make sure the forbidden zone is not covered
1611 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
1612 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
1614 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
1616 // forbiddenmin allowedmin allowedmax forbiddenmax
1617 else if(allowedmax < forbiddenmax)
1619 // it's better to leave the allowed zone (overlap with scoreboard) than
1620 // to cover the forbidden zone (crosshair)
1621 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
1622 centerprint_start_y = forbiddenmax;
1624 centerprint_start_y = forbiddenmin;
1626 // forbiddenmin allowedmin forbiddenmax allowedmax
1629 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
1632 centerprint_start_y =
1635 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
1642 centerprint_num = i;
1643 centerprint_expire = time + cvar("scr_centertime");
1646 void Sbar_DrawCenterPrint (void)
1653 //if(time > centerprint_expire)
1656 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
1657 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
1658 //sz = 1.2 / (a + 0.2);
1663 pos = centerprint_start;
1664 for (i=0; i<centerprint_num; i = i + 1)
1666 pos_x = (vid_conwidth - centerprint_fontsize_x * centerprint_width[i]) * 0.5;
1667 ts = centerprint_messages[i];
1670 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1671 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
1672 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
1673 pos_y = pos_y + centerprint_fontsize_y;
1676 // half height for empty lines looks better
1677 pos_y = pos_y + centerprint_fontsize_y * 0.5;
1681 vector Sbar_DrawNoteLine(vector offset, string s)
1683 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
1684 drawcolorcodedstring(
1685 offset - sbar_fontsize_x * '1 0 0' * stringwidth(s, TRUE),
1691 return offset + sbar_fontsize_y * '0 1 0';
1694 void Sbar_Draw (void)
1698 float stat_items, stat_weapons;
1699 vector o; o = '1 0 0' * vid_conwidth;
1702 sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
1704 if(spectatee_status)
1706 if(spectatee_status == -1)
1709 s = strcat("^1Spectating ^7", GetPlayerName(spectatee_status - 1));
1710 o = Sbar_DrawNoteLine(o, s);
1712 if(spectatee_status == -1)
1713 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
1715 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
1716 o = Sbar_DrawNoteLine(o, s);
1718 if(spectatee_status == -1)
1719 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
1721 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
1722 o = Sbar_DrawNoteLine(o, s);
1724 if(gametype == GAME_ARENA)
1725 s = "^1Wait for your turn to join";
1726 else if(gametype == GAME_LMS)
1729 sk = playerslots[player_localentnum - 1];
1730 if(sk.(scores[ps_primary]) >= 666)
1731 s = "^1Match has already begun";
1732 else if(sk.(scores[ps_primary]) > 0)
1733 s = "^1You have no more lives left";
1735 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1738 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
1739 o = Sbar_DrawNoteLine(o, s);
1741 //show restart countdown:
1742 if (time < getstatf(STAT_GAMESTARTTIME)) {
1744 //we need to ceil, otherwise the countdown would be off by .5 when using round()
1745 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
1746 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
1747 o = Sbar_DrawNoteLine(o, s);
1752 s = "^2Currently in ^1warmup^2 stage!";
1753 o = Sbar_DrawNoteLine(o, s);
1756 // move more important stuff more to the middle so its more visible
1757 o_y = vid_conheight * 0.66;
1760 if(mod(time, 1) >= 0.5)
1767 if(ready_waiting_for_me)
1770 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
1772 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
1777 s = strcat("^2Waiting for others to ready up to end warmup...");
1779 s = strcat("^2Waiting for others to ready up...");
1781 o = Sbar_DrawNoteLine(o, s);
1783 else if(warmup_stage)
1785 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
1786 o = Sbar_DrawNoteLine(o, s);
1790 s = strcat("^2A vote has been called for ^1", vote_called_vote);
1791 o = Sbar_DrawNoteLine(o, s);
1793 if(vote_waiting_for_me)
1795 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote yes", "vyes"), blinkcolor, " to accept");
1796 o = Sbar_DrawNoteLine(o, s);
1798 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote no", "vno"), blinkcolor, " to reject");
1799 o = Sbar_DrawNoteLine(o, s);
1801 s = strcat(blinkcolor, "Press ^3", getcommandkey("vote abstain", "vabstain"), blinkcolor, " to abstain");
1802 o = Sbar_DrawNoteLine(o, s);
1806 s = strcat("^2Waiting for others to vote...");
1807 o = Sbar_DrawNoteLine(o, s);
1813 float ts_min, ts_max;
1814 tm = teams.sort_next;
1817 for(; tm.sort_next; tm = tm.sort_next)
1819 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
1821 if(!ts_min) ts_min = tm.team_size;
1822 else ts_min = min(ts_min, tm.team_size);
1823 if(!ts_max) ts_max = tm.team_size;
1824 else ts_max = max(ts_max, tm.team_size);
1826 if ((ts_max - ts_min) > 1)
1828 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
1829 tm = GetTeam(myteam, false);
1831 if (tm.team != COLOR_SPECTATOR)
1832 if (tm.team_size == ts_max)
1833 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
1835 o = Sbar_DrawNoteLine(o, s);
1841 Sbar_UpdatePlayerTeams();
1847 Sbar_DrawScoreboard();
1848 Sbar_DrawCenterPrint();
1850 else if (intermission == 1)
1852 Sbar_DrawScoreboard();
1853 Sbar_DrawCenterPrint();
1856 else if (intermission == 2)
1858 Sbar_FinaleOverlay();
1859 Sbar_DrawCenterPrint();
1863 if (sb_showscores || sb_showscores_force || (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard")))
1865 sbar_x = (vid_conwidth - 640.0)*0.5;
1866 sbar_y = vid_conheight - 47;
1867 //Sbar_DrawAlphaPic (sbar_x, sbar_y, sb_scorebar, sbar_alpha_bg.value);
1868 //drawpic('0 0 0', "gfx/scorebar", '0 0 0', '1 1 1', cvar("sbar_alpha_bg"), 0);
1869 Sbar_DrawScoreboard ();
1873 if (sb_lines && sbar_hudselector == 1)
1875 stat_items = getstati(STAT_ITEMS);
1876 stat_weapons = getstati(STAT_WEAPONS);
1878 sbar_x = (vid_conwidth - 320.0)*0.5;
1879 sbar_y = vid_conheight - 24.0 - 16.0;
1882 fade = 3.2 - 2 * (time - weapontime);
1883 fade = bound(0.7, fade, 1);
1886 Sbar_DrawWeapon_Clear();
1887 for(i = 1; i <= 24; ++i)
1889 if(weaponimpulse[i-1] >= 0)
1890 if(stat_weapons & x)
1892 Sbar_DrawWeapon(i-1, fade, (i == activeweapon));
1898 x = getstati(STAT_ARMOR);
1902 //Sbar_DrawStretchPic (72, 0, sb_armor[0], sbar_alpha_fg.value, 24, 24);
1903 drawpic(sbar + '72 0 0', "gfx/sb_armor", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1905 Sbar_DrawXNum('0 0 0', x, 3, 24, '0 1 0', 1, 0);
1907 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.2 1 0', 1, 0);
1909 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1911 Sbar_DrawXNum('0 0 0', x, 3, 24, '1 1 0.2', 1, 0);
1913 Sbar_DrawXNum('0 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1917 x = getstati(STAT_HEALTH);
1921 //Sbar_DrawStretchPic (184, 0, sb_health, sbar_alpha_fg.value, 24, 24);
1922 drawpic(sbar + '184 0 0', "gfx/sb_health", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1924 Sbar_DrawXNum('112 0 0', x, 3, 24, '0 1 0', 1, 0);
1926 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.2 1 0', 1, 0);
1928 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1930 Sbar_DrawXNum('112 0 0', x, 3, 24, '1 1 0.2', 1, 0);
1932 Sbar_DrawXNum('112 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1936 x = getstati(STAT_AMMO);
1937 if ((stat_items & IT_AMMO) || x != 0)
1939 if (stat_items & IT_SHELLS)
1940 drawpic(sbar + '296 0 0', "gfx/sb_shells", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1941 else if (stat_items & IT_NAILS)
1942 drawpic(sbar + '296 0 0', "gfx/sb_bullets", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1943 else if (stat_items & IT_ROCKETS)
1944 drawpic(sbar + '296 0 0', "gfx/sb_rocket", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1945 else if (stat_items & IT_CELLS)
1946 drawpic(sbar + '296 0 0', "gfx/sb_cells", '24 24 0', '1 1 1', sbar_alpha_fg, 0);
1948 Sbar_DrawXNum('224 0 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
1950 Sbar_DrawXNum('224 0 0', x, 3, 24, '0.7 0 0', 1, 0);
1953 if (sbar_x + 320 + 160 <= vid_conwidth)
1954 Sbar_MiniDeathmatchOverlay(sbar + '320 0 0');
1957 // The margin can be at most 8 to support 640x480 console size:
1958 // 320 + 2 * (144 + 16) = 640
1963 stat_items = getstati(STAT_ITEMS);
1964 stat_weapons = getstati(STAT_WEAPONS);
1966 sbar_x = (vid_conwidth - 640.0)*0.5;
1967 sbar_y = vid_conheight - 47;
1970 fade = 3 - 2 * (time - weapontime);
1973 Sbar_DrawWeapon_Clear();
1974 for(i = 1; i <= 24; ++i)
1976 if(weaponimpulse[i-1] >= 0)
1977 if(stat_weapons & x)
1979 Sbar_DrawWeapon(i-1, fade, (i == activeweapon));
1985 drawpic(sbar, "gfx/sbar", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1987 drawpic(sbar, "gfx/sbar_minimal", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
1991 Sbar_DrawXNum('268 12 0', getstati(STAT_ARMOR), 3, 24, '0.6 0.7 0.8', 1, 0);
1995 x = getstati(STAT_HEALTH);
1997 Sbar_DrawXNum('82 12 0', x, 3, 24, '1 1 1', 1, 0);
1998 else if(x <= 25 && time - floor(time) > 0.5)
1999 Sbar_DrawXNum('82 12 0', x, 3, 24, '0.7 0 0', 1, 0);
2001 Sbar_DrawXNum('81 12 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
2003 x = getstati(STAT_AMMO);
2004 if ((stat_items & IT_AMMO) || x != 0)
2007 if (stat_items & IT_SHELLS)
2008 drawpic(sbar + '519 0 0', "gfx/sb_shells", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
2009 else if (stat_items & IT_NAILS)
2010 drawpic(sbar + '519 0 0', "gfx/sb_bullets", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
2011 else if (stat_items & IT_ROCKETS)
2012 drawpic(sbar + '519 0 0', "gfx/sb_rocket", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
2013 else if (stat_items & IT_CELLS)
2014 drawpic(sbar + '519 0 0', "gfx/sb_cells", '0 0 0', '1 1 1', sbar_alpha_fg, 0);
2016 Sbar_DrawXNum('447 12 0', x, 3, 24, '0.6 0.7 0.8', 1, 0);
2018 Sbar_DrawXNum('447 12 0', x, 3, 24, '0.7 0 0', 1, 0);
2022 drawpic(sbar, "gfx/sbar_overlay", '0 0 0', '1 1 1', 1, DRAWFLAG_MODULATE);
2024 if (sbar_x + 600 + 160 <= vid_conwidth)
2025 Sbar_MiniDeathmatchOverlay (sbar + '600 0 0');
2030 // Mini scoreboard uses 12*4 per other team, that is, 144
2031 // pixels when there are four teams...
2032 // Nexuiz by default sets vid_conwidth to 800... makes
2034 // so we need to shift it by 64 pixels to the right to fit
2035 // BUT: then it overlaps with the image that gets drawn
2036 // for viewsize 100! Therefore, just account for 3 teams,
2037 // that is, 96 pixels mini scoreboard size, needing 16 pixels
2041 //show strength/invincibility ICON and timer:
2042 CSQC_Strength_Timer();
2044 if(gametype == GAME_KEYHUNT)
2047 } else if(gametype == GAME_CTF)
2052 Sbar_DrawCenterPrint();
2056 void CSQC_ctf_hud(void)
2058 // cvar("sbar_flagstatus_right") move the flag icons right
2059 // cvar("sbar_flagstatus_pos") pixel position of the nexuiz flagstatus icons
2060 float redflag, blueflag;
2064 stat_items = getstati(STAT_ITEMS);
2065 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
2066 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
2070 * For some reason now not even THAT works there...
2071 * Maybe the minus' precedence screws it up? The last one there, maybe I should use brackets
2073 * pos_x = (cvar("sbar_flagstatus_right")) ? vid_conwidth - 10 - sbar_x - 64 : 10 - sbar_x;
2074 ** Should try those later:
2075 * pos_x = (cvar("sbar_flagstatus_right")) ? (vid_conwidth - 10 - sbar_x - 64) : (10 - sbar_x);
2076 * pos_x = ( (cvar("sbar_flagstatus_right")) ? vid_conwidth - 10 - 64 : 10 ) - sbar_x;
2079 if(cvar("sbar_flagstatus_right"))
2080 pos_x = vid_conwidth - 10 - sbar_x - 64;
2082 pos_x = 10 - sbar_x;
2086 if(sbar_hudselector == 1)
2087 pos_y = (vid_conheight - sbar_y) - cvar("sbar_flagstatus_pos") - 64;
2095 case 1: drawpic(pos, "gfx/sb_flag_red_taken", '128 64 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
2096 case 2: drawpic(pos, "gfx/sb_flag_red_lost", '128 64 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
2097 case 3: drawpic(pos, "gfx/sb_flag_red_carrying", '128 64 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
2099 if(stat_items & IT_CTF_SHIELDED)
2100 if(myteam == COLOR_TEAM2)
2101 drawpic(pos, "gfx/sb_flag_red_shielded", '128 64 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;
2108 case 1: drawpic(pos, "gfx/sb_flag_blue_taken", '128 64 0', '1 1 1', 1, 0); break;
2109 case 2: drawpic(pos, "gfx/sb_flag_blue_lost", '128 64 0', '1 1 1', 1, 0); break;
2110 case 3: drawpic(pos, "gfx/sb_flag_blue_carrying", '128 64 0', '1 1 1', 1, 0); break;
2112 if(stat_items & IT_CTF_SHIELDED)
2113 if(myteam == COLOR_TEAM1)
2114 drawpic(pos, "gfx/sb_flag_blue_shielded", '128 64 0', '1 1 1', 1, DRAWFLAG_NORMAL); break;