1 void drawstringright(vector, string, vector, vector, float, float);
\r
2 void drawstringcenter(vector, string, vector, vector, float, float);
\r
6 float weapon_hits[WEP_MAXCOUNT];
\r
7 float weapon_fired[WEP_MAXCOUNT];
\r
13 float sbar_alpha_fg;
\r
14 float sbar_alpha_bg;
\r
15 float sbar_color_bg_team;
\r
16 float sbar_border_thickness;
\r
17 float sbar_accuracy_border_thickness;
\r
18 float sbar_scoreboard_alpha_bg;
\r
19 float sbar_scoreboard_alpha_fg;
\r
20 float sbar_scoreboard_highlight;
\r
21 float sbar_scoreboard_highlight_alpha;
\r
22 float sbar_scoreboard_highlight_alpha_self;
\r
23 float sbar_hudselector;
\r
24 float sbar_accuracy_hud;
\r
25 float sbar_scoreboard_alpha_name;
\r
26 float sbar_scoreboard_alpha_name_self;
\r
28 float ps_primary, ps_secondary;
\r
29 float ts_primary, ts_secondary;
\r
33 void CSQC_kh_hudreset();
\r
35 void CSQC_ctf_hudreset();
\r
36 void CSQC_ctf_hud();
\r
37 void CSQC_race_hud();
\r
38 void MapVote_Draw();
\r
39 void Sbar_FinaleOverlay()
\r
42 pos_x = (vid_conwidth - 1)/2;
\r
46 //drawpic(pos, "gfx/finale", '0 0 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
48 //drawstring(pos, "END", sbar_fontsize, '1 1 1', 1, DRAWFLAG_NORMAL);
\r
52 vector Sbar_AccuracyColor(float accuracy)
\r
55 float yellow_accuracy = cvar("sbar_accuracy_yellow"); // value at which this function returns yellow
\r
56 if(accuracy >= 100) {
\r
60 else if(accuracy > yellow_accuracy) {
\r
61 rgb_x = 1 - (accuracy-yellow_accuracy)/(100-yellow_accuracy); // red value between 1 -> 0
\r
66 rgb_y = accuracy/yellow_accuracy; // green value between 0 -> 1
\r
72 void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, float lettersize, vector rgb, float highlighted, float stroke, float alpha, float dflags)
\r
75 string str, tmp, l_length;
\r
77 vector vsize, num_color;
\r
79 vsize_x = vsize_y = lettersize;
\r
82 // showminusplus 1: always prefix with minus sign (useful in race distribution display)
\r
83 // showminusplus 2: always prefix with plus sign (useful in race distribution display)
\r
84 // showminusplus 3: prefix with minus sign if negative, plus sign if positive (useful in score distribution display)
\r
86 if((showminusplus == 2 && num >= 0) || (num > 0 && showminusplus == 3))
\r
92 if(num < 0 || (num < 0 && showminusplus == 3) || (showminusplus == 1 && num <= 0))
\r
103 str = strcat(substring("0000000000", 0, digits - strlen(tmp)), tmp);
\r
108 l_length = ftos(l);
\r
112 str = substring(str, l - digits, 999);
\r
116 if (highlighted == 1) {
\r
118 hl_size_x = vsize_x * l;
\r
119 hl_size_y = vsize_y * 1.1;
\r
122 hl_size_x = hl_size_x + vsize_x;
\r
125 hl_pos_x = pos_x - lettersize / 10;
\r
126 hl_pos_y = pos_y - lettersize / 20;
\r
129 //drawpic(hl_pos, strcat("gfx/hud/sb_highlight_", l_length), hl_size, '1 1 1', alpha, dflags);
\r
133 num_color = '1 1 1';
\r
140 drawstring(pos, "-", vsize, rgb, alpha, dflags);
\r
141 drawstring(pos, "-", vsize, num_color, alpha, dflags);
\r
142 pos_x += lettersize / 2;
\r
146 drawstring(pos, "+", vsize, rgb, alpha, dflags);
\r
147 drawstring(pos, "+", vsize, num_color, alpha, dflags);
\r
148 pos_x += lettersize / 2;
\r
152 drawstring(pos, str, vsize, rgb, alpha, dflags);
\r
153 drawstring(pos, str, vsize, num_color, alpha, dflags);
\r
156 void Sbar_DrawXNum_Colored (vector pos, float x, float lettersize, float alpha)
\r
164 color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
\r
165 color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
\r
169 color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
\r
170 color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
\r
171 color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
\r
176 color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
\r
180 color_y = (x-20)*90/27/100; // green value between 0 -> 1
\r
181 color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
\r
188 Sbar_DrawXNum(pos, x, 3, 0, lettersize, color, 0, 0, alpha, DRAWFLAG_NORMAL);
\r
191 void Cmd_Sbar_SetFields(float argc);
\r
192 void Sbar_InitScores()
\r
196 ps_primary = ps_secondary = ts_primary = ts_secondary = -1;
\r
197 for(i = 0; i < MAX_SCORE; ++i)
\r
199 f = (scores_flags[i] & SFL_SORT_PRIO_MASK);
\r
200 if(f == SFL_SORT_PRIO_PRIMARY)
\r
202 if(f == SFL_SORT_PRIO_SECONDARY)
\r
205 if(ps_secondary == -1)
\r
206 ps_secondary = ps_primary;
\r
208 for(i = 0; i < MAX_TEAMSCORE; ++i)
\r
210 f = (teamscores_flags[i] & SFL_SORT_PRIO_MASK);
\r
211 if(f == SFL_SORT_PRIO_PRIMARY)
\r
213 if(f == SFL_SORT_PRIO_SECONDARY)
\r
216 if(ts_secondary == -1)
\r
217 ts_secondary = ts_primary;
\r
219 Cmd_Sbar_SetFields(0);
\r
222 void Sbar_UpdatePlayerPos(entity pl);
\r
223 float SetTeam(entity pl, float Team);
\r
225 void Sbar_UpdatePlayerTeams()
\r
232 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
235 Team = GetPlayerColor(pl.sv_entnum);
\r
236 if(SetTeam(pl, Team))
\r
238 tmp = pl.sort_prev;
\r
239 Sbar_UpdatePlayerPos(pl);
\r
243 pl = players.sort_next;
\r
247 if(num != lastpnum)
\r
248 print(strcat("PNUM: ", ftos(num), "\n"));
\r
253 float Sbar_ComparePlayerScores(entity left, entity right)
\r
256 vl = GetPlayerColor(left.sv_entnum);
\r
257 vr = GetPlayerColor(right.sv_entnum);
\r
259 if(!left.gotscores)
\r
260 vl = COLOR_SPECTATOR;
\r
261 if(!right.gotscores)
\r
262 vr = COLOR_SPECTATOR;
\r
269 if(vl == COLOR_SPECTATOR)
\r
271 // FIRST the one with scores (spectators), THEN the ones without (downloaders)
\r
272 // no other sorting
\r
273 if(!left.gotscores && right.gotscores)
\r
278 vl = left.scores[ps_primary];
\r
279 vr = right.scores[ps_primary];
\r
280 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
\r
282 if(vl == 0 && vr != 0)
\r
284 if(vl != 0 && vr == 0)
\r
288 return IS_INCREASING(scores_flags[ps_primary]);
\r
290 return IS_DECREASING(scores_flags[ps_primary]);
\r
292 vl = left.scores[ps_secondary];
\r
293 vr = right.scores[ps_secondary];
\r
294 if(scores_flags[ps_secondary] & SFL_ZERO_IS_WORST)
\r
296 if(vl == 0 && vr != 0)
\r
298 if(vl != 0 && vr == 0)
\r
302 return IS_INCREASING(scores_flags[ps_secondary]);
\r
304 return IS_DECREASING(scores_flags[ps_secondary]);
\r
309 void Sbar_UpdatePlayerPos(entity player)
\r
311 for(other = player.sort_next; other && Sbar_ComparePlayerScores(player, other); other = player.sort_next)
\r
313 SORT_SWAP(player, other);
\r
315 for(other = player.sort_prev; other != players && Sbar_ComparePlayerScores(other, player); other = player.sort_prev)
\r
317 SORT_SWAP(other, player);
\r
321 float Sbar_CompareTeamScores(entity left, entity right)
\r
325 if(left.team == COLOR_SPECTATOR)
\r
327 if(right.team == COLOR_SPECTATOR)
\r
330 vl = left.teamscores[ts_primary];
\r
331 vr = right.teamscores[ts_primary];
\r
333 return IS_INCREASING(teamscores_flags[ts_primary]);
\r
335 return IS_DECREASING(teamscores_flags[ts_primary]);
\r
337 vl = left.teamscores[ts_secondary];
\r
338 vr = right.teamscores[ts_secondary];
\r
340 return IS_INCREASING(teamscores_flags[ts_secondary]);
\r
342 return IS_DECREASING(teamscores_flags[ts_secondary]);
\r
347 void Sbar_UpdateTeamPos(entity Team)
\r
349 for(other = Team.sort_next; other && Sbar_CompareTeamScores(Team, other); other = Team.sort_next)
\r
351 SORT_SWAP(Team, other);
\r
353 for(other = Team.sort_prev; other != teams && Sbar_CompareTeamScores(other, Team); other = Team.sort_prev)
\r
355 SORT_SWAP(other, Team);
\r
359 void Cmd_Sbar_Help(float argc)
\r
361 print("You can modify the scoreboard using the ^2sbar_columns_set command.\n");
\r
362 print("^3|---------------------------------------------------------------|\n");
\r
364 print("^2sbar_columns_set default\n");
\r
365 print("^2sbar_columns_set ^7filed1 field2 ...\n");
\r
366 print("The following field names are recognized (case insensitive):\n");
\r
367 print("You can use a ^3|^7 to start the right-aligned fields.\n\n");
\r
369 print("^3name^7 or ^3nick^7 Name of a player\n");
\r
370 print("^3ping^7 Ping time\n");
\r
371 print("^3pl^7 Packet loss\n");
\r
372 print("^3kills^7 Number of kills\n");
\r
373 print("^3deaths^7 Number of deaths\n");
\r
374 print("^3suicides^7 Number of suicides\n");
\r
375 print("^3frags^7 kills - suicides\n");
\r
376 print("^3kd^7 The kill-death ratio\n");
\r
377 print("^3caps^7 How often a flag (CTF) or a key (KeyHunt) was captured\n");
\r
378 print("^3pickups^7 How often a flag (CTF) or a key (KeyHunt) was picked up\n");
\r
379 print("^3fckills^7 Number of flag carrier kills\n");
\r
380 print("^3returns^7 Number of flag returns\n");
\r
381 print("^3drops^7 Number of flag drops\n");
\r
382 print("^3lives^7 Number of lives (LMS)\n");
\r
383 print("^3rank^7 Player rank\n");
\r
384 print("^3pushes^7 Number of players pushed into void\n");
\r
385 print("^3destroyed^7 Number of keys destroyed by pushing them into void\n");
\r
386 print("^3kckills^7 Number of keys carrier kills\n");
\r
387 print("^3losses^7 Number of times a key was lost\n");
\r
388 print("^3laps^7 Number of laps finished (race/cts)\n");
\r
389 print("^3time^7 Total time raced (race/cts)\n");
\r
390 print("^3fastest^7 Time of fastest lap (race/cts)\n");
\r
391 print("^3ticks^7 Number of ticks (DOM)\n");
\r
392 print("^3takes^7 Number of domination points taken (DOM)\n");
\r
393 print("^3score^7 Total score\n\n");
\r
395 print("Before a field you can put a + or - sign, then a comma separated list\n");
\r
396 print("of game types, then a slash, to make the field show up only in these\n");
\r
397 print("or in all but these game types. You can also specify 'all' as a\n");
\r
398 print("field to show all fields available for the current game mode.\n\n");
\r
400 print("The special game type names 'teams' and 'noteams' can be used to\n");
\r
401 print("include/exclude ALL teams/noteams game modes.\n\n");
\r
403 print("Example: sbar_columns_set name ping pl | +ctf/field3 -dm/field4\n");
\r
404 print("will display name, ping and pl aligned to the left, and the fields\n");
\r
405 print("right of the vertical bar aligned to the right.\n");
\r
406 print("'field3' will only be shown in CTF, and 'field4' will be shown in all\n");
\r
407 print("other gamemodes except DM.\n");
\r
410 string Sbar_DefaultColumnLayout()
\r
412 return strcat( // fteqcc sucks
\r
414 "-teams,race,lms/kills -teams,lms/deaths -teams,lms,race/suicides -race,dm,tdm/frags ", // tdm already has this in "score"
\r
415 "+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns ",
\r
416 "+lms/lives +lms/rank ",
\r
417 "+kh/caps +kh/pushes +kh/destroyed ",
\r
418 "?+race/laps ?+race/time ?+race/fastest ",
\r
422 void Cmd_Sbar_SetFields(float argc)
\r
425 string str, pattern;
\r
426 float have_name, have_primary, have_secondary, have_separator;
\r
429 // TODO: re enable with gametype dependant cvars?
\r
430 if(argc < 2) // no arguments provided
\r
431 argc = tokenizebyseparator(strcat("x ", cvar_string("sbar_columns")), " ");
\r
434 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
\r
438 if(argv(1) == "default")
\r
439 argc = tokenizebyseparator(strcat("x ", Sbar_DefaultColumnLayout()), " ");
\r
440 else if(argv(1) == "all")
\r
443 s = "ping pl color name |";
\r
444 for(i = 0; i < MAX_SCORE; ++i)
\r
446 if(i != ps_primary)
\r
447 if(i != ps_secondary)
\r
448 if(scores_label[i] != "")
\r
449 s = strcat(s, " ", scores_label[i]);
\r
451 if(ps_secondary != ps_primary)
\r
452 s = strcat(s, " ", scores_label[ps_secondary]);
\r
453 s = strcat(s, " ", scores_label[ps_primary]);
\r
454 argc = tokenizebyseparator(strcat("x ", s), " ");
\r
459 sbar_num_fields = 0;
\r
461 drawfont = sbar_font;
\r
463 for(i = 0; i < argc - 1; ++i)
\r
468 nocomplain = FALSE;
\r
469 if(substring(str, 0, 1) == "?")
\r
472 str = substring(str, 1, strlen(str) - 1);
\r
475 slash = strstrofs(str, "/", 0);
\r
478 pattern = substring(str, 0, slash);
\r
479 str = substring(str, slash + 1, strlen(str) - (slash + 1));
\r
481 if not(isGametypeInFilter(gametype, teamplay, pattern))
\r
485 strunzone(sbar_title[sbar_num_fields]);
\r
486 sbar_title[sbar_num_fields] = strzone(str);
\r
487 sbar_size[sbar_num_fields] = stringwidth(str, FALSE, sbar_fontsize);
\r
488 str = strtolower(str);
\r
490 if(str == "ping") {
\r
491 sbar_field[sbar_num_fields] = SP_PING;
\r
492 } else if(str == "pl") {
\r
493 sbar_field[sbar_num_fields] = SP_PL;
\r
494 } else if(str == "kd" || str == "kdr" || str == "kdratio" || str == "k/d") {
\r
495 sbar_field[sbar_num_fields] = SP_KDRATIO;
\r
496 } else if(str == "name" || str == "nick") {
\r
497 sbar_field[sbar_num_fields] = SP_NAME;
\r
499 } else if(str == "|") {
\r
500 sbar_field[sbar_num_fields] = SP_SEPARATOR;
\r
501 have_separator = 1;
\r
503 if(gametype == GAME_RPG)
\r
506 for(j = 0; j < MAX_SCORE; ++j)
\r
507 if(str == strtolower(scores_label[j]))
\r
508 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
\r
515 print(strcat("^1Error:^7 Unknown score field: '", str, "'\n"));
\r
519 sbar_field[sbar_num_fields] = j;
\r
520 if(j == ps_primary)
\r
522 if(j == ps_secondary)
\r
523 have_secondary = 1;
\r
526 if(sbar_num_fields >= MAX_SBAR_FIELDS)
\r
530 if(scores_flags[ps_primary] & SFL_ALLOW_HIDE)
\r
532 if(scores_flags[ps_secondary] & SFL_ALLOW_HIDE)
\r
533 have_secondary = 1;
\r
534 if(ps_primary == ps_secondary)
\r
535 have_secondary = 1;
\r
536 missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
\r
538 if(sbar_num_fields+missing < MAX_SBAR_FIELDS)
\r
542 strunzone(sbar_title[sbar_num_fields]);
\r
543 for(i = sbar_num_fields; i > 0; --i)
\r
545 sbar_title[i] = sbar_title[i-1];
\r
546 sbar_size[i] = sbar_size[i-1];
\r
547 sbar_field[i] = sbar_field[i-1];
\r
549 sbar_title[0] = strzone("name");
\r
550 sbar_field[0] = SP_NAME;
\r
552 print("fixed missing field 'name'\n");
\r
554 if(!have_separator)
\r
556 strunzone(sbar_title[sbar_num_fields]);
\r
557 for(i = sbar_num_fields; i > 1; --i)
\r
559 sbar_title[i] = sbar_title[i-1];
\r
560 sbar_size[i] = sbar_size[i-1];
\r
561 sbar_field[i] = sbar_field[i-1];
\r
563 sbar_title[1] = strzone("|");
\r
564 sbar_field[1] = SP_SEPARATOR;
\r
565 sbar_size[1] = stringwidth("|", FALSE, sbar_fontsize);
\r
567 print("fixed missing field '|'\n");
\r
570 else if(!have_separator)
\r
572 strunzone(sbar_title[sbar_num_fields]);
\r
573 sbar_title[sbar_num_fields] = strzone("|");
\r
574 sbar_size[sbar_num_fields] = stringwidth("|", FALSE, sbar_fontsize);
\r
575 sbar_field[sbar_num_fields] = SP_SEPARATOR;
\r
577 print("fixed missing field '|'\n");
\r
579 if(!have_secondary)
\r
581 strunzone(sbar_title[sbar_num_fields]);
\r
582 sbar_title[sbar_num_fields] = strzone(scores_label[ps_secondary]);
\r
583 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);
\r
584 sbar_field[sbar_num_fields] = ps_secondary;
\r
586 print("fixed missing field '", scores_label[ps_secondary], "'\n");
\r
590 strunzone(sbar_title[sbar_num_fields]);
\r
591 sbar_title[sbar_num_fields] = strzone(scores_label[ps_primary]);
\r
592 sbar_size[sbar_num_fields] = stringwidth(sbar_title[sbar_num_fields], FALSE, sbar_fontsize);
\r
593 sbar_field[sbar_num_fields] = ps_primary;
\r
595 print("fixed missing field '", scores_label[ps_primary], "'\n");
\r
599 sbar_field[sbar_num_fields] = SP_END;
\r
603 vector sbar_field_rgb;
\r
604 string sbar_field_icon0;
\r
605 string sbar_field_icon1;
\r
606 string sbar_field_icon2;
\r
607 vector sbar_field_icon0_rgb;
\r
608 vector sbar_field_icon1_rgb;
\r
609 vector sbar_field_icon2_rgb;
\r
610 float sbar_field_icon0_alpha;
\r
611 float sbar_field_icon1_alpha;
\r
612 float sbar_field_icon2_alpha;
\r
613 string Sbar_GetField(entity pl, float field)
\r
615 float tmp, num, denom, f;
\r
617 sbar_field_rgb = '1 1 1';
\r
618 sbar_field_icon0 = "";
\r
619 sbar_field_icon1 = "";
\r
620 sbar_field_icon2 = "";
\r
621 sbar_field_icon0_rgb = '1 1 1';
\r
622 sbar_field_icon1_rgb = '1 1 1';
\r
623 sbar_field_icon2_rgb = '1 1 1';
\r
624 sbar_field_icon0_alpha = 1;
\r
625 sbar_field_icon1_alpha = 1;
\r
626 sbar_field_icon2_alpha = 1;
\r
630 if not(pl.gotscores)
\r
631 return "\x8D\x8D\x8D"; // >>> sign
\r
632 //str = getplayerkey(pl.sv_entnum, "ping");
\r
636 tmp = max(0, min(220, f-80)) / 220;
\r
637 sbar_field_rgb = '1 1 1' - '0 1 1'*tmp;
\r
641 if not(pl.gotscores)
\r
643 f = pl.ping_packetloss;
\r
644 tmp = pl.ping_movementloss;
\r
645 if(f == 0 && tmp == 0)
\r
647 str = ftos(ceil(f * 100));
\r
649 str = strcat(str, "~", ftos(ceil(tmp * 100)));
\r
650 tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl
\r
651 sbar_field_rgb = '1 0.5 0.5' - '0 0.5 0.5'*tmp;
\r
655 if(ready_waiting && pl.ready)
\r
657 sbar_field_icon0 = "gfx/sb_player_ready";
\r
661 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
663 sbar_field_icon0 = "gfx/sb_playercolor_base";
\r
664 sbar_field_icon1 = "gfx/sb_playercolor_shirt";
\r
665 sbar_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
\r
666 sbar_field_icon2 = "gfx/sb_playercolor_pants";
\r
667 sbar_field_icon2_rgb = colormapPaletteColor(mod(f, 16), 1);
\r
670 return GetPlayerName(pl.sv_entnum);
\r
673 f = pl.(scores[SP_KILLS]);
\r
674 f -= pl.(scores[SP_SUICIDES]);
\r
678 num = pl.(scores[SP_KILLS]);
\r
679 denom = pl.(scores[SP_DEATHS]);
\r
682 sbar_field_rgb = '0 1 0';
\r
684 } else if(num <= 0) {
\r
685 sbar_field_rgb = '1 0 0';
\r
686 str = ftos(num/denom);
\r
688 str = ftos(num/denom);
\r
690 tmp = strstrofs(str, ".", 0);
\r
692 str = substring(str, 0, tmp+2);
\r
696 tmp = pl.(scores[field]);
\r
697 f = scores_flags[field];
\r
698 if(field == ps_primary)
\r
699 sbar_field_rgb = '1 1 0';
\r
700 else if(field == ps_secondary)
\r
701 sbar_field_rgb = '0 1 1';
\r
703 sbar_field_rgb = '1 1 1';
\r
704 return ScoreString(f, tmp);
\r
709 string Sbar_GetStomachField(entity pl, float field)
\r
714 return ""; // the returned value is not used, we only need the field
\r
717 return GetPlayerName(pl.sv_entnum);
\r
720 return ftos(pl.plhealth);
\r
728 string Sbar_GetStomachFieldPred(entity pl, float field)
\r
733 return GetPlayerName(pl.sv_entnum);
\r
740 float xmin, xmax, ymin, ymax, sbwidth;
\r
741 float sbar_fixscoreboardcolumnwidth_len;
\r
742 float sbar_fixscoreboardcolumnwidth_iconlen;
\r
743 float sbar_fixscoreboardcolumnwidth_marginlen;
\r
745 float stringwidth_colors(string s, vector theSize)
\r
747 return stringwidth(s, TRUE, theSize);
\r
750 float stringwidth_nocolors(string s, vector theSize)
\r
752 return stringwidth(s, FALSE, theSize);
\r
755 string Sbar_FixScoreboardColumnWidth(float i, string str)
\r
759 field = sbar_field[i];
\r
761 sbar_fixscoreboardcolumnwidth_iconlen = 0;
\r
763 if(sbar_field_icon0 != "")
\r
765 sz = drawgetimagesize(sbar_field_icon0);
\r
767 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
768 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
771 if(sbar_field_icon1 != "")
\r
773 sz = drawgetimagesize(sbar_field_icon1);
\r
775 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
776 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
779 if(sbar_field_icon2 != "")
\r
781 sz = drawgetimagesize(sbar_field_icon2);
\r
783 if(sbar_fixscoreboardcolumnwidth_iconlen < f)
\r
784 sbar_fixscoreboardcolumnwidth_iconlen = f;
\r
787 sbar_fixscoreboardcolumnwidth_iconlen *= sbar_fontsize_y / sbar_fontsize_x; // fix icon aspect
\r
789 if(sbar_fixscoreboardcolumnwidth_iconlen != 0)
\r
790 sbar_fixscoreboardcolumnwidth_marginlen = stringwidth(" ", FALSE, sbar_fontsize);
\r
792 sbar_fixscoreboardcolumnwidth_marginlen = 0;
\r
794 if(field == SP_NAME) // name gets all remaining space
\r
797 namesize = sbwidth;// / sbar_fontsize_x;
\r
798 for(j = 0; j < sbar_num_fields; ++j)
\r
800 if (sbar_field[i] != SP_SEPARATOR)
\r
801 namesize -= sbar_size[j] + 1;
\r
803 sbar_size[i] = namesize;
\r
805 if (sbar_fixscoreboardcolumnwidth_iconlen != 0)
\r
806 namesize -= sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
\r
807 str = textShortenToWidth(str, namesize, sbar_fontsize, stringwidth_colors);
\r
808 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, TRUE, sbar_fontsize);
\r
811 sbar_fixscoreboardcolumnwidth_len = stringwidth(str, FALSE, sbar_fontsize);
\r
813 f = sbar_fixscoreboardcolumnwidth_len + sbar_fixscoreboardcolumnwidth_marginlen + sbar_fixscoreboardcolumnwidth_iconlen;
\r
814 if(sbar_size[i] < f)
\r
820 void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_number)
\r
823 rgb = GetTeamRGB(pl.team);
\r
827 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
\r
829 if((rgb == '1 1 1') && (!is_spec)) {
\r
830 rgb_x = cvar("sbar_color_bg_r") + 0.5;
\r
831 rgb_y = cvar("sbar_color_bg_g") + 0.5;
\r
832 rgb_z = cvar("sbar_color_bg_b") + 0.5; }
\r
836 tmp_y = sbar_fontsize_y * 1.25;
\r
839 // alternated rows highlighting
\r
841 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
\r
842 else if((sbar_scoreboard_highlight) && (!mod(pl_number,2)))
\r
843 drawfill(pos - '1 1 0', tmp + '2 0 0', rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
847 for(i = 0; i < sbar_num_fields; ++i)
\r
849 field = sbar_field[i];
\r
850 if(field == SP_SEPARATOR)
\r
853 if(is_spec && field != SP_NAME && field != SP_PING) {
\r
854 pos_x += sbar_size[i] + sbar_fontsize_x;
\r
857 str = Sbar_GetField(pl, field);
\r
858 str = Sbar_FixScoreboardColumnWidth(i, str);
\r
860 pos_x += sbar_size[i] + sbar_fontsize_x;
\r
862 if(field == SP_NAME) {
\r
863 tmp_x = sbar_size[i] - sbar_fontsize_x*sbar_fixscoreboardcolumnwidth_iconlen - sbar_fixscoreboardcolumnwidth_marginlen + sbar_fontsize_x;
\r
865 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
867 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
869 tmp_x = sbar_fixscoreboardcolumnwidth_len + sbar_fontsize_x;
\r
871 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
873 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
876 tmp_x = sbar_size[i] + sbar_fontsize_x;
\r
877 if(sbar_field_icon0 != "")
\r
879 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
881 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
882 if(sbar_field_icon1 != "")
\r
884 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
886 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
887 if(sbar_field_icon2 != "")
\r
889 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
891 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
894 if(sbar_field[i] == SP_SEPARATOR)
\r
897 for(i = sbar_num_fields-1; i > 0; --i)
\r
899 field = sbar_field[i];
\r
900 if(field == SP_SEPARATOR)
\r
903 if(is_spec && field != SP_NAME && field != SP_PING) {
\r
904 pos_x -= sbar_size[i] + sbar_fontsize_x;
\r
908 str = Sbar_GetField(pl, field);
\r
909 str = Sbar_FixScoreboardColumnWidth(i, str);
\r
911 if(field == SP_NAME) {
\r
912 tmp_x = sbar_fixscoreboardcolumnwidth_len; // left or right aligned? let's put it right...
\r
914 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
916 drawcolorcodedstring(pos - tmp, str, sbar_fontsize, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
918 tmp_x = sbar_fixscoreboardcolumnwidth_len;
\r
920 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
922 drawstring(pos - tmp, str, sbar_fontsize, sbar_field_rgb, sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
925 tmp_x = sbar_size[i];
\r
926 if(sbar_field_icon0 != "")
\r
928 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
930 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
931 if(sbar_field_icon1 != "")
\r
933 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
935 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
936 if(sbar_field_icon2 != "")
\r
938 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 * sbar_scoreboard_alpha_name_self, DRAWFLAG_NORMAL);
\r
940 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 * sbar_scoreboard_alpha_name, DRAWFLAG_NORMAL);
\r
941 pos_x -= sbar_size[i] + sbar_fontsize_x;
\r
946 float fieldcounter;
\r
947 void Sbar_PrintStomachboardItem(vector pos, entity pl)
\r
949 // lists all players in the stomach
\r
952 float f, field, field_number;
\r
953 field_number = 3; // the number of components each row has
\r
955 for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter)
\r
957 field = -fieldcounter;
\r
958 str = Sbar_GetStomachField(pl, field);
\r
960 // row highlighting
\r
961 if(field == ST_HIGHLIGHT)
\r
963 if(getstati(STAT_VORE_EATEN))
\r
964 drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color2")), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
966 drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color1")), cvar("sbar_stomachboard_highlight_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
969 if(field == ST_NAME) {
\r
970 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
971 drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
972 drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
973 drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
976 drawcolorcodedstring(pos, textShortenToWidth(str, 138, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
979 if(field == ST_HEALTH)
\r
980 if(stof(str) > 0) {
\r
982 if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1))
\r
983 drawcolorcodedstring(pos, "self", '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
986 drawpic(pos, "gfx/hud/sb_health", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
989 drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
995 float fieldcounter2;
\r
996 void Sbar_PrintStomachboardItemPred(vector pos, entity pl)
\r
998 // shows the name of our predator
\r
1001 float f, field, field_number;
\r
1002 field_number = 1; // the number of components each row has
\r
1004 for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2)
\r
1006 field = -fieldcounter2;
\r
1007 str = Sbar_GetStomachFieldPred(pl, field);
\r
1009 if(field == STP_NAME) {
\r
1010 f = stof(getplayerkey(pl.sv_entnum, "colors"));
\r
1011 drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1012 drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1013 drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1016 drawcolorcodedstring(pos, textShortenToWidth(str, 122, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1022 * Sbar_Scoreboard_MakeTable
\r
1024 * Makes a table for a team (for all playing players in DM) and fills it
\r
1027 vector Sbar_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
\r
1029 float body_table_height, i;
\r
1030 vector tmp, column_dim;
\r
1033 body_table_height = 1.25 * sbar_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line
\r
1037 tmp_x = sbwidth + 2;
\r
1038 tmp_y = 1.25 * sbar_fontsize_y;
\r
1041 drawpic(pos, "gfx/hud/sb_scoreboard_tableheader", tmp, (rgb * sbar_color_bg_team) + '0.5 0.5 0.5', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1044 tmp_y += sbar_border_thickness;
\r
1045 tmp_y += body_table_height;
\r
1046 drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard
\r
1048 // separator header/table
\r
1049 pos_y += 1.25 * sbar_fontsize_y;
\r
1050 tmp_y = sbar_border_thickness;
\r
1051 drawfill(pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1053 pos_y += sbar_border_thickness;
\r
1055 // table background
\r
1056 tmp_y = body_table_height;
\r
1057 drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1059 // anyway, apply some color
\r
1060 //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
\r
1062 // go back to the top to make alternated columns highlighting and to print the strings
\r
1063 pos_y -= 1.25 * sbar_fontsize_y;
\r
1064 pos_y -= sbar_border_thickness;
\r
1068 if (sbar_scoreboard_highlight)
\r
1070 column_dim_y = 1.25 * sbar_fontsize_y; // header
\r
1071 column_dim_y += sbar_border_thickness;
\r
1072 column_dim_y += body_table_height;
\r
1075 // print the strings of the columns headers and draw the columns
\r
1076 for(i = 0; i < sbar_num_fields; ++i)
\r
1078 if(sbar_field[i] == SP_SEPARATOR)
\r
1080 column_dim_x = sbar_size[i] + sbar_fontsize_x;
\r
1081 if (sbar_scoreboard_highlight)
\r
1084 drawfill(pos - '0 1 0' - sbar_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1086 drawstring(pos, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1087 pos_x += column_dim_x;
\r
1089 if(sbar_field[i] == SP_SEPARATOR)
\r
1093 for(i = sbar_num_fields-1; i > 0; --i)
\r
1095 if(sbar_field[i] == SP_SEPARATOR)
\r
1098 pos_x -= sbar_size[i];
\r
1100 if (sbar_scoreboard_highlight)
\r
1104 if (i == sbar_num_fields-1)
\r
1105 column_dim_x = sbar_size[i] + sbar_fontsize_x / 2 + 1;
\r
1107 column_dim_x = sbar_size[i] + sbar_fontsize_x;
\r
1108 drawfill(pos - '0 1 0' - sbar_fontsize_x / 2 * '1 0 0', column_dim, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1112 tmp_x = stringwidth(sbar_title[i], FALSE, sbar_fontsize);
\r
1113 tmp_x = sbar_size[i] - tmp_x;
\r
1114 drawstring(pos + tmp, sbar_title[i], sbar_fontsize, rgb * 1.5, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1115 pos_x -= sbar_fontsize_x;
\r
1120 pos_y += 1.25 * sbar_fontsize_y; // skip the header
\r
1121 pos_y += sbar_border_thickness;
\r
1123 // fill the table and draw the rows
\r
1126 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1128 if(pl.team != tm.team)
\r
1130 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
\r
1131 pos_y += 1.25 * sbar_fontsize_y;
\r
1135 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1137 if(pl.team == COLOR_SPECTATOR)
\r
1139 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), i);
\r
1140 pos_y += 1.25 * sbar_fontsize_y;
\r
1145 pos_y += 1.25 * sbar_fontsize_y; // move to the end of the table
\r
1146 pos_y += 1.25 * sbar_fontsize_y; // move empty row (out of the table)
\r
1151 float Sbar_WouldDrawScoreboard() {
\r
1152 if (sb_showscores)
\r
1154 else if (intermission == 1)
\r
1156 else if (intermission == 2)
\r
1158 else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
\r
1160 else if(sb_showscores_force)
\r
1165 float average_accuracy;
\r
1166 vector Sbar_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
\r
1169 float weapon_hit, weapon_damage, weapon_stats;
\r
1170 float fontsize = 40 * 1/3;
\r
1174 if(cvar("sbar_accuracy_doublerows"))
\r
1178 float height = 40;
\r
1186 drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1190 tmp_y = height * rows;
\r
1192 drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1193 drawborderlines(sbar_accuracy_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
\r
1195 // column highlighting
\r
1196 for(i = 0; i < weapon_cnt/rows; ++i)
\r
1199 drawfill(pos + '1 0 0' * (sbwidth/weapon_cnt) * rows * i, '0 1 0' * height * rows + '1 0 0' * (sbwidth/weapon_cnt) * rows, '0 0 0', sbar_scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
\r
1202 // row highlighting
\r
1203 for(i = 0; i < rows; ++i)
\r
1205 drawfill(pos + '0 1 0' * height * (2/3) + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
1208 // skip useless weapons
\r
1210 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
1212 self = get_weaponinfo(i);
\r
1213 if not(self.weapons)
\r
1218 drawfont = sbar_bigfont;
\r
1219 average_accuracy = 0;
\r
1220 float weapons_with_stats;
\r
1221 weapons_with_stats = 0;
\r
1223 pos_x += sbwidth/weapon_cnt / 2;
\r
1225 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
1227 self = get_weaponinfo(i);
\r
1228 if not(self.weapons)
\r
1230 weapon_hit = weapon_hits[i-WEP_FIRST];
\r
1231 weapon_damage = weapon_fired[i-WEP_FIRST];
\r
1233 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
1234 float weapon_alpha;
\r
1237 weapon_alpha = sbar_scoreboard_alpha_fg;
\r
1239 weapon_alpha = 0.2 * sbar_scoreboard_alpha_fg;
\r
1242 drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
\r
1244 if(weapon_damage) {
\r
1245 weapons_with_stats += 1;
\r
1246 average_accuracy += weapon_stats; // store sum of all accuracies in average_accuracy
\r
1249 s = strcat(ftos(weapon_stats),"%");
\r
1252 padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
\r
1254 rgb = Sbar_AccuracyColor(weapon_stats);
\r
1255 drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1257 pos_x += sbwidth/weapon_cnt * rows;
\r
1258 if(rows == 2 && i == 6) {
\r
1263 drawfont = sbar_font;
\r
1265 if(weapons_with_stats)
\r
1266 average_accuracy = floor(average_accuracy / weapons_with_stats);
\r
1273 string race_PlaceName(float pos) {
\r
1281 return strcat(ftos(pos), "th");
\r
1284 vector Sbar_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size)
\r
1287 RANKINGS_RECEIVED_CNT = 0;
\r
1288 for (i=RANKINGS_CNT-1; i>=0; --i)
\r
1289 if (grecordtime[i])
\r
1290 RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;
\r
1292 if (RANKINGS_RECEIVED_CNT == 0)
\r
1296 is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
\r
1298 hl_rgb_x = cvar("sbar_color_bg_r") + 0.5;
\r
1299 hl_rgb_y = cvar("sbar_color_bg_g") + 0.5;
\r
1300 hl_rgb_z = cvar("sbar_color_bg_b") + 0.5;
\r
1302 pos_y += sbar_fontsize_y;
\r
1303 drawstring(pos, strcat("Rankings"), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1304 pos_y += sbar_fontsize_y;
\r
1307 tmp_y = sbar_fontsize_y * RANKINGS_RECEIVED_CNT;
\r
1309 drawpic_tiled(pos, "gfx/hud/sb_scoreboard_bg", bg_size, tmp, rgb * sbar_color_bg_team, sbar_scoreboard_alpha_bg, DRAWFLAG_NORMAL);
\r
1310 drawborderlines(sbar_border_thickness, pos, tmp, '0 0 0', sbar_scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
\r
1312 // row highlighting
\r
1313 for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)
\r
1317 t = grecordtime[i];
\r
1320 n = grecordholder[i];
\r
1321 p = race_PlaceName(i+1);
\r
1322 if(grecordholder[i] == GetPlayerName(player_localentnum - 1))
\r
1323 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha_self, DRAWFLAG_NORMAL);
\r
1324 else if(!mod(i, 2) && sbar_scoreboard_highlight)
\r
1325 drawfill(pos, '1 0 0' * sbwidth + '0 1 0' * sbar_fontsize_y, hl_rgb, sbar_scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
\r
1326 drawstring(pos, p, sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1327 drawstring(pos + '3 0 0' * sbar_fontsize_x, TIME_ENCODED_TOSTRING(t), sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1328 drawcolorcodedstring(pos + '8 0 0' * sbar_fontsize_x, n, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1329 pos += '0 1 0' * sbar_fontsize_y;
\r
1335 float scoreboard_bottom;
\r
1336 float sbar_scoreboard_fade_alpha;
\r
1337 float sbar_woulddrawscoreboard_prev;
\r
1338 float sbar_woulddrawscoreboard_change; // "time" at which Sbar_WouldDrawScoreboard() changed
\r
1339 void Sbar_DrawScoreboard()
\r
1341 float sbar_woulddrawscoreboard;
\r
1342 sbar_woulddrawscoreboard = Sbar_WouldDrawScoreboard();
\r
1343 if(sbar_woulddrawscoreboard != sbar_woulddrawscoreboard_prev) {
\r
1344 sbar_woulddrawscoreboard_change = time;
\r
1345 sbar_woulddrawscoreboard_prev = sbar_woulddrawscoreboard;
\r
1348 float scoreboard_fadeinspeed = cvar_or("sbar_scoreboard_fadeinspeed", 10);
\r
1349 float scoreboard_fadeoutspeed = cvar_or("sbar_scoreboard_fadeoutspeed", 5);
\r
1350 if(sbar_woulddrawscoreboard) {
\r
1351 if (scoreboard_fadeinspeed)
\r
1352 sbar_scoreboard_fade_alpha = bound (0, (time - sbar_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);
\r
1354 sbar_scoreboard_fade_alpha = 1;
\r
1357 if (scoreboard_fadeoutspeed)
\r
1358 sbar_scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - sbar_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);
\r
1360 sbar_scoreboard_fade_alpha = 0;
\r
1362 if not(sbar_scoreboard_fade_alpha)
\r
1365 sbar_scoreboard_alpha_bg = cvar("sbar_scoreboard_alpha_bg") * sbar_scoreboard_fade_alpha;
\r
1366 sbar_scoreboard_alpha_fg = cvar_or("sbar_scoreboard_alpha_fg", 1.0) * sbar_scoreboard_fade_alpha;
\r
1367 sbar_scoreboard_highlight = cvar("sbar_scoreboard_highlight");
\r
1368 sbar_scoreboard_highlight_alpha = cvar_or("sbar_scoreboard_highlight_alpha", 0.10) * sbar_scoreboard_alpha_fg;
\r
1369 sbar_scoreboard_highlight_alpha_self = cvar_or("sbar_scoreboard_highlight_alpha_self", 0.25) * sbar_scoreboard_alpha_fg;
\r
1370 sbar_scoreboard_alpha_name = cvar_or("sbar_scoreboard_alpha_name", 0.9) * sbar_scoreboard_alpha_fg;
\r
1371 sbar_scoreboard_alpha_name_self = cvar_or("sbar_scoreboard_alpha_name_self", 1) * sbar_scoreboard_alpha_fg;
\r
1373 vector rgb, pos, tmp;
\r
1376 sbwidth = Sbar_GetWidth(6.5 * sbar_fontsize_y);
\r
1378 xmin = 0.5 * (vid_conwidth - sbwidth);
\r
1379 ymin = cvar("sbar_scoreboard_offset");
\r
1381 xmax = vid_conwidth - xmin;
\r
1382 ymax = vid_conheight - 0.2*vid_conheight;
\r
1384 // Initializes position
\r
1390 drawfont = sbar_bigfont;
\r
1391 if(gametype == GAME_RPG)
\r
1392 drawstringcenter('0 1 0' * ymin, "Players", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1394 drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1397 pos_y += sbar_fontsize_y;
\r
1399 drawfont = sbar_font;
\r
1401 // Draw the scoreboard
\r
1403 bg_size = drawgetimagesize("gfx/hud/sb_scoreboard_bg");
\r
1407 for(tm = teams.sort_next; tm; tm = tm.sort_next)
\r
1409 if(tm.team == COLOR_SPECTATOR)
\r
1412 rgb = GetTeamRGB(tm.team);
\r
1413 Sbar_DrawXNum(pos - '9.5 0 0' * sbar_fontsize_y + '0 1 0' * sbar_fontsize_y, tm.(teamscores[ts_primary]), 6, 0, sbar_fontsize_y * 1.5, rgb, 0, 1, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1415 if(ts_primary != ts_secondary)
\r
1416 Sbar_DrawXNum(pos - '7.5 0 0' * sbar_fontsize_y + '0 2.5 0' * sbar_fontsize_y, tm.(teamscores[ts_secondary]), 6, 0, sbar_fontsize_y * 1, rgb, 0, 1, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1418 pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
\r
1423 rgb_x = cvar("sbar_color_bg_r");
\r
1424 rgb_y = cvar("sbar_color_bg_g");
\r
1425 rgb_z = cvar("sbar_color_bg_b");
\r
1427 for(tm = teams.sort_next; tm; tm = tm.sort_next)
\r
1429 if(tm.team == COLOR_SPECTATOR)
\r
1432 pos = Sbar_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
\r
1436 if(gametype == GAME_CTS || gametype == GAME_RACE) {
\r
1437 if(race_speedaward) {
\r
1438 drawcolorcodedstring(pos, strcat("Speed award: ", ftos(race_speedaward), " (", race_speedaward_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1439 pos_y += 1.25 * sbar_fontsize_y;
\r
1441 if(race_speedaward_alltimebest) {
\r
1442 drawcolorcodedstring(pos, strcat("All-time fastest: ", ftos(race_speedaward_alltimebest), " (", race_speedaward_alltimebest_holder, ")"), sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1443 pos_y += 1.25 * sbar_fontsize_y;
\r
1445 pos = Sbar_DrawScoreboardRankings(pos, pl, rgb, bg_size);
\r
1447 else if(cvar("sbar_accuracy") && spectatee_status != -1) {
\r
1449 pos = Sbar_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);
\r
1451 pos = Sbar_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
\r
1454 tmp = pos + '0 1.5 0' * sbar_fontsize_y;
\r
1455 pos_y += 3 * sbar_fontsize_y;
\r
1457 // List spectators
\r
1460 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
1462 if(pl.team != COLOR_SPECTATOR)
\r
1464 Sbar_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
\r
1465 pos_y += 1.25 * sbar_fontsize_y;
\r
1470 drawstring(tmp, "Spectators", sbar_fontsize, '1 1 1', sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1472 // Print info string
\r
1475 if(gametype == GAME_RPG)
\r
1476 str = strcat("you are in ^2", shortmapname, "^7");
\r
1478 str = strcat("playing on ^2", shortmapname, "^7");
\r
1479 tl = getstatf(STAT_TIMELIMIT);
\r
1480 fl = getstatf(STAT_FRAGLIMIT);
\r
1481 ll = getstatf(STAT_LEADLIMIT);
\r
1482 if(gametype == GAME_LMS)
\r
1485 str = strcat(str, " for up to ^1", ftos(tl), " minutes^7");
\r
1490 str = strcat(str, " for ^1", ftos(tl), " minutes^7");
\r
1491 if(fl > 0 && !(gametype == GAME_RPG))
\r
1494 str = strcat(str, " or");
\r
1497 str = strcat(str, " until ^3", ScoreString(teamscores_flags[ts_primary], fl));
\r
1498 if(teamscores_label[ts_primary] == "score")
\r
1499 str = strcat(str, " points^7");
\r
1500 else if(teamscores_label[ts_primary] == "fastest")
\r
1501 str = strcat(str, " is beaten^7");
\r
1503 str = strcat(str, " ", teamscores_label[ts_primary]);
\r
1507 str = strcat(str, " until ^3", ScoreString(scores_flags[ps_primary], fl));
\r
1508 if(scores_label[ps_primary] == "score")
\r
1509 str = strcat(str, " points^7");
\r
1510 else if(scores_label[ps_primary] == "fastest")
\r
1511 str = strcat(str, " is beaten^7");
\r
1513 str = strcat(str, " ", scores_label[ps_primary]);
\r
1518 if(tl > 0 || fl > 0)
\r
1519 str = strcat(str, " or");
\r
1522 str = strcat(str, " until a lead of ^3", ScoreString(teamscores_flags[ts_primary], ll));
\r
1523 if(teamscores_label[ts_primary] == "score")
\r
1524 str = strcat(str, " points^7");
\r
1525 else if(teamscores_label[ts_primary] == "fastest")
\r
1526 str = strcat(str, " is beaten^7");
\r
1528 str = strcat(str, " ", teamscores_label[ts_primary]);
\r
1532 str = strcat(str, " until a lead of ^3", ScoreString(scores_flags[ps_primary], ll));
\r
1533 if(scores_label[ps_primary] == "score")
\r
1534 str = strcat(str, " points^7");
\r
1535 else if(scores_label[ps_primary] == "fastest")
\r
1536 str = strcat(str, " is beaten^7");
\r
1538 str = strcat(str, " ", scores_label[ps_primary]);
\r
1544 pos_y += 1.2 * sbar_fontsize_y;
\r
1545 drawcolorcodedstring(pos + '0.5 0 0' * (sbwidth - stringwidth(str, TRUE, sbar_fontsize)), str, sbar_fontsize, sbar_scoreboard_alpha_fg, DRAWFLAG_NORMAL);
\r
1547 scoreboard_bottom = pos_y + 2 * sbar_fontsize_y;
\r
1550 string MakeRaceString(float cp, float mytime, float histime, float lapdelta, string hisname)
\r
1558 if(histime == 0) // goal hit
\r
1562 timestr = strcat("+", ftos_decimals(+mytime, TIME_DECIMALS));
\r
1565 else if(mytime == 0)
\r
1572 timestr = strcat("-", ftos_decimals(-mytime, TIME_DECIMALS));
\r
1578 lapstr = strcat(" (-", ftos(lapdelta), "L)");
\r
1581 else if(lapdelta < 0)
\r
1583 lapstr = strcat(" (+", ftos(-lapdelta), "L)");
\r
1587 else if(histime > 0) // anticipation
\r
1589 if(mytime >= histime)
\r
1590 timestr = strcat("+", ftos_decimals(mytime - histime, TIME_DECIMALS));
\r
1592 timestr = TIME_ENCODED_TOSTRING(TIME_ENCODE(histime));
\r
1599 cpname = "Start line";
\r
1600 else if(cp == 255)
\r
1601 cpname = "Finish line";
\r
1603 cpname = strcat("Intermediate ", ftos(cp));
\r
1605 cpname = "Finish line";
\r
1608 return strcat(col, cpname);
\r
1609 else if(hisname == "")
\r
1610 return strcat(col, cpname, " (", timestr, ")");
\r
1612 return strcat(col, cpname, " (", timestr, " ", strcat(hisname, col, lapstr), ")");
\r
1615 float race_CheckName(string net_name) { // Does the name already exist in rankings? In that case, where? (otherwise 0)
\r
1617 for (i=RANKINGS_CNT-1;i>=0;--i)
\r
1618 if(grecordholder[i] == net_name)
\r
1623 float race_status_time;
\r
1624 float race_status_prev;
\r
1625 string race_status_name_prev;
\r
1626 void Sbar_DrawRaceStatus(vector pos)
\r
1628 if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
\r
1629 race_status_time = time + 5;
\r
1630 race_status_prev = race_status;
\r
1631 if (race_status_name_prev)
\r
1632 strunzone(race_status_name_prev);
\r
1633 race_status_name_prev = strzone(race_status_name);
\r
1637 a = bound(0, race_status_time - time, 1);
\r
1640 s = textShortenToWidth(race_status_name, 120, '10 10 0', stringwidth_colors);
\r
1643 if(race_status > 0)
\r
1644 rank = race_CheckName(race_status_name);
\r
1646 rankname = race_PlaceName(rank);
\r
1648 if(race_status == 0)
\r
1649 drawpic(pos, "gfx/hud/race/newfail", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1650 else if(race_status == 1) {
\r
1651 drawpic(pos, "gfx/hud/race/newtime", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1652 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1653 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1654 } else if(race_status == 2) {
\r
1655 if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
\r
1656 drawpic(pos, "gfx/hud/race/newrankgreen", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1658 drawpic(pos, "gfx/hud/race/newrankyellow", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1659 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1660 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1661 } else if(race_status == 3) {
\r
1662 drawpic(pos, "gfx/hud/race/newrecordserver", '80 80 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1663 drawcolorcodedstring(pos + '40 80 0' - '1 0 0' * stringwidth(s, TRUE, '5 0 0'), s, '10 10 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1664 drawstring(pos + '40 20 0' - '1 0 0' * stringwidth(rankname, TRUE, '7 0 0'), rankname, '14 14 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1667 if (race_status_time - time <= 0) {
\r
1668 race_status_prev = -1;
\r
1670 if(race_status_name)
\r
1671 strunzone(race_status_name);
\r
1672 race_status_name = string_null;
\r
1673 if(race_status_name_prev)
\r
1674 strunzone(race_status_name_prev);
\r
1675 race_status_name_prev = string_null;
\r
1681 float score, distribution, leader;
\r
1682 vector score_pos, secondary_score_pos, distribution_color;
\r
1683 entity tm, pl, me;
\r
1684 me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
\r
1687 top_x = vid_conwidth / 2;
\r
1691 if(gametype == GAME_RPG)
\r
1694 score_pos = top + '-80 8 0';
\r
1695 secondary_score_pos = score_pos + '80 -6 0';
\r
1697 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
\r
1698 pl = players.sort_next;
\r
1700 pl = pl.sort_next;
\r
1701 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
\r
1702 if(pl.scores[ps_primary] == 0)
\r
1705 score = me.(scores[ps_primary]);
\r
1707 float racemin, racesec, racemsec;
\r
1708 float distsec, distmsec, minusplus;
\r
1710 racemin = floor(score/(60 * TIME_FACTOR));
\r
1711 racesec = floor((score - racemin*(60 * TIME_FACTOR))/TIME_FACTOR);
\r
1712 racemsec = score - racemin*60*TIME_FACTOR - racesec*TIME_FACTOR;
\r
1714 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
\r
1715 // distribution display
\r
1716 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
\r
1718 if (distribution < TIME_FACTOR && distribution > -TIME_FACTOR)
\r
1719 distmsec = fabs(distribution);
\r
1721 distsec = floor(fabs(distribution)/TIME_FACTOR);
\r
1722 distmsec = fabs(distribution) - distsec*TIME_FACTOR;
\r
1723 if (distribution < 0)
\r
1724 distsec = -distsec;
\r
1727 if (distribution <= 0) {
\r
1728 distribution_color = '0 1 0';
\r
1729 minusplus = 1; // minusplus 1: always prefix with minus sign
\r
1732 distribution_color = '1 0 0';
\r
1733 minusplus = 2; // minusplus 1: always prefix with plus sign
\r
1735 Sbar_DrawXNum(score_pos + '232 -4 0' - '16 0 0' * TIME_DECIMALS, distmsec, -TIME_DECIMALS, 0, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1736 Sbar_DrawXNum(score_pos + '232 12 0' - '16 0 0' * TIME_DECIMALS, distsec, 4, minusplus, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1737 drawstring(score_pos + '216 -4 0' - '16 0 0' * TIME_DECIMALS, ".", '16 16 0', distribution_color, sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
1739 // race record display
\r
1740 if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
\r
1741 drawpic(score_pos + '173 0 0' - '32 0 0' * (4 + TIME_DECIMALS), "gfx/hud/sb_highlight_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1743 Sbar_DrawXNum(score_pos + '192 0 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1744 Sbar_DrawXNum(score_pos + '192 0 0' - TIME_DECIMALS * '30 0 0' - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1745 drawstring(score_pos + '192 0 0' - TIME_DECIMALS * '30 0 0' - '18 0 0', ".", '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
1747 Sbar_DrawXNum(score_pos + '192 0 0' - TIME_DECIMALS * '30 0 0' - '132 0 0', racemin, -2, 0, 30, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1748 drawstring(score_pos + '192 0 0' - TIME_DECIMALS * '30 0 0' - '84 0 0', ":", '30 30 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
1750 } else if (!teamplay) { // non-teamgames, except race/cts
\r
1751 // me vector := [team/connected frags id]
\r
1752 pl = players.sort_next;
\r
1754 pl = pl.sort_next;
\r
1757 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
\r
1761 score = me.(scores[ps_primary]);
\r
1763 if(distribution >= 5) {
\r
1764 distribution_color = '0 1 0';
\r
1766 } else if(distribution >= 0) {
\r
1767 distribution_color = '1 1 1';
\r
1769 } else if(distribution >= -5)
\r
1770 distribution_color = '1 1 0';
\r
1772 distribution_color = '1 0 0';
\r
1774 Sbar_DrawXNum(secondary_score_pos, distribution, 6, 0, 16, distribution_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1775 Sbar_DrawXNum(score_pos, score, 6, 0, 34, distribution_color, leader, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1776 } else { // teamgames
\r
1777 float max_fragcount;
\r
1778 max_fragcount = -999;
\r
1780 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
\r
1781 if(tm.team == COLOR_SPECTATOR || !tm.team_size) // no players? don't display
\r
1783 score = tm.(teamscores[ts_primary]);
\r
1786 if (score > max_fragcount)
\r
1787 max_fragcount = score;
\r
1789 if(tm.team == myteam) {
\r
1790 if (max_fragcount == score)
\r
1792 Sbar_DrawXNum(score_pos, score, 6, 0, 34, GetTeamRGB(tm.team) * 0.8, leader, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1794 if (max_fragcount == score)
\r
1796 Sbar_DrawXNum(secondary_score_pos, score, 6, 0, 16, GetTeamRGB(tm.team) * 0.8, leader, 1, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1797 secondary_score_pos = secondary_score_pos + '0 16 0';
\r
1802 if(gametype == GAME_RACE || gametype == GAME_CTS)
\r
1804 drawfont = sbar_bigfont;
\r
1807 string s, forcetime;
\r
1809 m = '0.5 0 0' * vid_conwidth + '0 1 0' * cvar_or("cl_racetimer_position", 0.25) * vid_conheight;
\r
1811 if(race_checkpointtime)
\r
1813 a = bound(0, 2 - (time - race_checkpointtime), 1);
\r
1816 if(a > 0) // just hit a checkpoint?
\r
1818 if(race_checkpoint != 254)
\r
1820 if(race_time && race_previousbesttime)
\r
1821 s = MakeRaceString(race_checkpoint, TIME_DECODE(race_time) - TIME_DECODE(race_previousbesttime), 0, 0, race_previousbestname);
\r
1823 s = MakeRaceString(race_checkpoint, 0, -1, 0, race_previousbestname);
\r
1825 forcetime = TIME_ENCODED_TOSTRING(race_time);
\r
1830 if(race_laptime && race_nextbesttime && race_nextcheckpoint != 254)
\r
1832 a = bound(0, 2 - ((race_laptime + TIME_DECODE(race_nextbesttime)) - (time + TIME_DECODE(race_penaltyaccumulator))), 1);
\r
1833 if(a > 0) // next one?
\r
1835 s = MakeRaceString(race_nextcheckpoint, (time + TIME_DECODE(race_penaltyaccumulator)) - race_laptime, TIME_DECODE(race_nextbesttime), 0, race_nextbestname);
\r
1840 if(s != "" && a > 0)
\r
1842 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
1843 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1844 drawcolorcodedstring(m - '0 16 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1847 if(race_penaltytime)
\r
1849 a = bound(0, 2 - (time - race_penaltyeventtime), 1);
\r
1852 s = strcat("^1PENALTY: ", ftos_decimals(race_penaltytime * 0.1, 1), " (", race_penaltyreason, ")");
\r
1853 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
1854 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1855 drawcolorcodedstring(m - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1859 if(forcetime != "")
\r
1861 a = bound(0, (time - race_checkpointtime) / 0.5, 1);
\r
1862 //drawstring_expanding(m - '16 0 0' * stringwidth(forcetime, FALSE), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);
\r
1863 drawstring_expanding(m - '1 0 0' * stringwidth(forcetime, FALSE, '16 0 0'), forcetime, '32 32 0', '1 1 1', sbar_alpha_fg, 0, a);
\r
1868 if(race_laptime && race_checkpoint != 255)
\r
1870 s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime));
\r
1871 //drawstring(m - '16 0 0' * stringwidth(s, FALSE), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1872 drawstring(m - '0.5 0 0' * stringwidth(s, FALSE, '32 32 0'), s, '32 32 0', '1 1 1', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1877 if(race_mycheckpointtime)
\r
1879 a = bound(0, 2 - (time - race_mycheckpointtime), 1);
\r
1880 s = MakeRaceString(race_mycheckpoint, TIME_DECODE(race_mycheckpointdelta), -!race_mycheckpointenemy, race_mycheckpointlapsdelta, race_mycheckpointenemy);
\r
1881 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
1882 //drawcolorcodedstring(m - '0 16 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1883 drawcolorcodedstring(m - '0 16 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1885 if(race_othercheckpointtime && race_othercheckpointenemy != "")
\r
1887 a = bound(0, 2 - (time - race_othercheckpointtime), 1);
\r
1888 s = MakeRaceString(race_othercheckpoint, -TIME_DECODE(race_othercheckpointdelta), -!race_othercheckpointenemy, race_othercheckpointlapsdelta, race_othercheckpointenemy);
\r
1889 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
1890 //drawcolorcodedstring(m - '0 0 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1891 drawcolorcodedstring(m - '0 0 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1894 if(race_penaltytime && !race_penaltyaccumulator)
\r
1896 t = race_penaltytime * 0.1 + race_penaltyeventtime;
\r
1897 a = bound(0, (1 + t - time), 1);
\r
1901 s = strcat("^1PENALTY: ", ftos_decimals(t - time, 1), " (", race_penaltyreason, ")");
\r
1903 s = strcat("^2PENALTY: 0.0 (", race_penaltyreason, ")");
\r
1904 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
1905 //drawcolorcodedstring(m - '0 32 0' - '8 0 0' * stringwidth(s, TRUE), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1906 drawcolorcodedstring(m - '0 32 0' - '0.5 0 0' * stringwidth(s, TRUE, '16 16 0'), s, '16 16 0', sbar_alpha_fg * a, DRAWFLAG_NORMAL);
\r
1911 drawfont = sbar_font;
\r
1917 float timelimit, elapsedTime, minutes, seconds, timeleft, minutesLeft, secondsLeft;
\r
1918 vector bgpos, timer_color;
\r
1922 topright = '0 0 0';
\r
1923 topright_x = vid_conwidth;
\r
1926 scale = cvar_or("sbar_timer_scale", 1);
\r
1927 timelimit = getstatf(STAT_TIMELIMIT);
\r
1929 if(gametype == GAME_RPG && !timelimit) // don't draw the timer in rpg if there's no time limit
\r
1932 Sbar_DrawRaceStatus((topright_x - 100) * '1 0 0' + '0 30 0' * scale);
\r
1934 timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
\r
1935 timeleft = ceil(timeleft);
\r
1936 minutesLeft = floor(timeleft / 60);
\r
1937 secondsLeft = timeleft - minutesLeft*60;
\r
1939 if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit
\r
1940 timer_color = '1 1 1'; //white
\r
1941 else if(minutesLeft >= 1)
\r
1942 timer_color = '1 1 0'; //yellow
\r
1944 timer_color = '1 0 0'; //red
\r
1946 if (cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
\r
1947 if (time < getstatf(STAT_GAMESTARTTIME)) {
\r
1948 //while restart is still active, show 00:00
\r
1949 minutes = seconds = 0;
\r
1951 elapsedTime = floor(time - getstatf(STAT_GAMESTARTTIME)); //127
\r
1952 minutes = floor(elapsedTime / 60);
\r
1953 seconds = elapsedTime - minutes*60;
\r
1956 bgpos_x = topright_x - (54 + 17 + 12) * scale;
\r
1957 else if (minutes < 100) // nudge the timer background left if more digits are drawn
\r
1958 bgpos_x = topright_x - (62 + 17 + 12) * scale;
\r
1960 bgpos_x = topright_x - (70 + 17 + 12) * scale;
\r
1964 minutes = minutesLeft;
\r
1965 seconds = secondsLeft;
\r
1967 bgpos_x = topright_x - (36 + 7 + 12) * scale;
\r
1968 else if (minutes < 10) // nudge the timer background left if more digits are drawn
\r
1969 bgpos_x = topright_x - (54 + 17 + 12) * scale;
\r
1970 else if (minutes < 100)
\r
1971 bgpos_x = topright_x - (72 + 17 + 12) * scale;
\r
1973 bgpos_x = topright_x - (90 + 17 + 12) * scale;
\r
1978 if (cvar("viewsize") <= 100) { // draw timer background when viewsize <= 100
\r
1980 drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color
\r
1982 color_x = cvar("sbar_color_bg_r");
\r
1983 color_y = cvar("sbar_color_bg_g");
\r
1984 color_z = cvar("sbar_color_bg_b");
\r
1986 drawpic(bgpos, "gfx/hud/bg_timer", '120 30 0' * scale, color, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
1990 if(minutesLeft >= 1 || cvar("sbar_increment_maptime") || timelimit == 0 || warmup_stage) {
\r
1991 Sbar_DrawXNum(topright - ('44 -2 0' - '0 2 0') - (strlen(ftos(minutes)) * 18 * scale * '0.5 0 0'), minutes, 3, 0, 18 * scale, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1992 drawstring(topright - ('42 -2 0' - '0 1 0'), ":", '18 18 0' * scale, timer_color, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1994 Sbar_DrawXNum(topright - ('31 -2 0' + '3 0 0' - '0 2 0'), seconds, -2, 0, 18 * scale, timer_color, 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
1997 void CSQC_Strength_Timer() {
\r
1999 vector bottomright;
\r
2001 bottomright_x = vid_conwidth;
\r
2002 bottomright_y = vid_conheight;
\r
2003 bottomright_z = 0;
\r
2005 float stat_items, dt;
\r
2006 stat_items = getstati(STAT_ITEMS);
\r
2008 if not(stat_items & IT_STRENGTH)
\r
2009 if not(stat_items & IT_INVINCIBLE)
\r
2013 if (getstati(STAT_HEALTH) <= 0)
\r
2017 float strength_time, invincibility_time, countdown_fontsize;
\r
2019 picsize = '22 22 0';
\r
2020 countdown_fontsize = 18;
\r
2022 pos = bottomright - '34 48 0';
\r
2025 strength_time = getstatf(STAT_STRENGTH_FINISHED);
\r
2026 invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED);
\r
2028 if (strength_time) {
\r
2029 dt = strength_time - time;
\r
2034 drawpic_expanding_two(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2035 bound(0, (ceil(dt) - dt) / 0.5, 1));
\r
2039 drawpic(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
2041 Sbar_DrawXNum(pos - '20 -2 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2045 drawpic_expanding(pos, "gfx/hud/sb_str", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2046 bound(0, -dt / 0.5, 1));
\r
2051 if (invincibility_time) {
\r
2052 dt = invincibility_time - time;
\r
2057 drawpic_expanding_two(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2058 bound(0, (ceil(dt) - dt) / 0.5, 1));
\r
2062 drawpic(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE);
\r
2064 Sbar_DrawXNum(pos - '20 -24 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2068 drawpic_expanding(pos - '0 -22 0', "gfx/hud/sb_invinc", picsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_ADDITIVE,
\r
2069 bound(0, -dt / 0.5, 1));
\r
2074 #define CENTERPRINT_MAX_LINES 30
\r
2075 string centerprint_messages[CENTERPRINT_MAX_LINES];
\r
2076 float centerprint_width[CENTERPRINT_MAX_LINES];
\r
2077 vector centerprint_start;
\r
2078 float centerprint_expire;
\r
2079 float centerprint_num;
\r
2080 float centerprint_offset_hint;
\r
2081 vector centerprint_fontsize;
\r
2083 void centerprint(string strMessage)
\r
2085 float i, j, n, hcount;
\r
2088 centerprint_fontsize = Sbar_GetFontsize("scr_centersize");
\r
2090 centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
\r
2092 if(cvar("scr_centertime") <= 0)
\r
2095 if(strMessage == "")
\r
2098 // strip trailing newlines
\r
2099 j = strlen(strMessage) - 1;
\r
2100 while(substring(strMessage, j, 1) == "\n" && j >= 0)
\r
2102 strMessage = substring(strMessage, 0, j + 1);
\r
2104 if(strMessage == "")
\r
2107 // strip leading newlines and remember them, they are a hint that the message should be lower on the screen
\r
2109 while(substring(strMessage, j, 1) == "\n" && j < strlen(strMessage))
\r
2111 strMessage = substring(strMessage, j, strlen(strMessage) - j);
\r
2112 centerprint_offset_hint = j;
\r
2114 if(strMessage == "")
\r
2117 // if we get here, we have a message. Initialize its height.
\r
2118 centerprint_num = 0;
\r
2120 n = tokenizebyseparator(strMessage, "\n");
\r
2122 for(j = 0; j < n; ++j)
\r
2124 getWrappedLine_remaining = argv(j);
\r
2125 while(getWrappedLine_remaining)
\r
2127 s = getWrappedLine(vid_conwidth * 0.75, centerprint_fontsize, stringwidth_colors);
\r
2128 if(centerprint_messages[i])
\r
2129 strunzone(centerprint_messages[i]);
\r
2130 centerprint_messages[i] = strzone(s);
\r
2131 centerprint_width[i] = stringwidth(s, TRUE, centerprint_fontsize);
\r
2134 // half height for empty lines looks better
\r
2140 if(i >= CENTERPRINT_MAX_LINES)
\r
2146 h = centerprint_fontsize_y*hcount;
\r
2148 havail = vid_conheight;
\r
2149 if(cvar("con_chatpos") < 0)
\r
2150 havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
\r
2151 if(havail > vid_conheight - 70)
\r
2152 havail = vid_conheight - 70; // avoid overlapping HUD
\r
2154 centerprint_start_x = 0;
\r
2157 float forbiddenmin, forbiddenmax, allowedmin, allowedmax, preferred;
\r
2159 // here, the centerprint would cover the crosshair. REALLY BAD.
\r
2160 forbiddenmin = vid_conheight * 0.5 - h - 16;
\r
2161 forbiddenmax = vid_conheight * 0.5 + 16;
\r
2163 allowedmin = scoreboard_bottom;
\r
2164 allowedmax = havail - h;
\r
2165 preferred = (havail - h)/2;
\r
2168 // possible orderings (total: 4! / 4 = 6)
\r
2169 // allowedmin allowedmax forbiddenmin forbiddenmax
\r
2170 // forbiddenmin forbiddenmax allowedmin allowedmax
\r
2171 if(allowedmax < forbiddenmin || allowedmin > forbiddenmax)
\r
2173 // forbidden doesn't matter in this case
\r
2174 centerprint_start_y = bound(allowedmin, preferred, allowedmax);
\r
2176 // allowedmin forbiddenmin allowedmax forbiddenmax
\r
2177 else if(allowedmin < forbiddenmin && allowedmax < forbiddenmax)
\r
2179 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
\r
2181 // allowedmin forbiddenmin forbiddenmax allowedmax
\r
2182 else if(allowedmin < forbiddenmin)
\r
2184 // make sure the forbidden zone is not covered
\r
2185 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
\r
2186 centerprint_start_y = bound(allowedmin, preferred, forbiddenmin);
\r
2188 centerprint_start_y = bound(forbiddenmax, preferred, allowedmin);
\r
2190 // forbiddenmin allowedmin allowedmax forbiddenmax
\r
2191 else if(allowedmax < forbiddenmax)
\r
2193 // it's better to leave the allowed zone (overlap with scoreboard) than
\r
2194 // to cover the forbidden zone (crosshair)
\r
2195 if(preferred > (forbiddenmin + forbiddenmax) * 0.5)
\r
2196 centerprint_start_y = forbiddenmax;
\r
2198 centerprint_start_y = forbiddenmin;
\r
2200 // forbiddenmin allowedmin forbiddenmax allowedmax
\r
2203 centerprint_start_y = bound(forbiddenmax, preferred, allowedmax);
\r
2206 centerprint_start_y =
\r
2209 max(scoreboard_bottom, vid_conheight * 0.5 + 16),
\r
2216 centerprint_num = i;
\r
2217 centerprint_expire = time + cvar("scr_centertime");
\r
2220 void Sbar_DrawCenterPrint (void)
\r
2227 //if(time > centerprint_expire)
\r
2230 //a = bound(0, 1 - 2 * (time - centerprint_expire), 1);
\r
2231 a = bound(0, 1 - 4 * (time - centerprint_expire), 1);
\r
2232 //sz = 1.2 / (a + 0.2);
\r
2237 pos = centerprint_start;
\r
2238 for (i=0; i<centerprint_num; i = i + 1)
\r
2240 pos_x = (vid_conwidth - centerprint_width[i]) * 0.5;
\r
2241 ts = centerprint_messages[i];
\r
2244 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2245 drawcolorcodedstring(pos, ts, centerprint_fontsize, a, DRAWFLAG_NORMAL);
\r
2246 // - '0 0.5 0' * (sz - 1) * centerprint_fontsize_x - '0.5 0 0' * (sz - 1) * centerprint_width[i] * centerprint_fontsize_y, centerprint_fontsize * sz
\r
2247 pos_y = pos_y + centerprint_fontsize_y;
\r
2250 // half height for empty lines looks better
\r
2251 pos_y = pos_y + centerprint_fontsize_y * 0.5;
\r
2255 vector Sbar_DrawNoteLine(vector offset, string s)
\r
2257 dummyfunction(0, 0, 0, 0, 0, 0, 0, 0); // work around DP bug (set OFS_PARAM5 to 0)
\r
2258 drawcolorcodedstring(
\r
2259 offset - '1 0 0' * stringwidth(s, TRUE, sbar_fontsize),
\r
2265 return offset + sbar_fontsize_y * '0 1 0';
\r
2268 void Sbar_DrawPressedKeys(void)
\r
2270 vector pos, bgsize;
\r
2271 float pressedkeys;
\r
2273 pos = stov(cvar_string("cl_showpressedkeys_position"));
\r
2275 bgsize = '126 75 0';
\r
2277 pos = '1 0 0' * (vid_conwidth - bgsize_x) * pos_x
\r
2278 + '0 1 0' * (vid_conheight - bgsize_y) * pos_y;
\r
2279 pos -= '-15 -6 0'; // adjust to the origin of these numbers
\r
2281 pressedkeys = getstatf(STAT_PRESSED_KEYS);
\r
2282 drawpic(pos + '-15 -6 0', "gfx/hud/keys/key_bg.tga", bgsize, '1 1 1', 0.1 * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2283 drawpic(pos + ' 83.5 9 0', ((pressedkeys & KEY_CROUCH) ? "gfx/hud/keys/key_crouch_inv.tga" : "gfx/hud/keys/key_crouch.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2284 drawpic(pos + ' 32 -1.5 0', ((pressedkeys & KEY_FORWARD) ? "gfx/hud/keys/key_forward_inv.tga" : "gfx/hud/keys/key_forward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2285 drawpic(pos + '-11.5 9 0', ((pressedkeys & KEY_JUMP) ? "gfx/hud/keys/key_jump_inv.tga" : "gfx/hud/keys/key_jump.tga"), ' 24 24 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2286 drawpic(pos + ' -1 32 0', ((pressedkeys & KEY_LEFT) ? "gfx/hud/keys/key_left_inv.tga" : "gfx/hud/keys/key_left.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2287 drawpic(pos + ' 32 32 0', ((pressedkeys & KEY_BACKWARD) ? "gfx/hud/keys/key_backward_inv.tga" : "gfx/hud/keys/key_backward.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2288 drawpic(pos + ' 65 32 0', ((pressedkeys & KEY_RIGHT) ? "gfx/hud/keys/key_right_inv.tga" : "gfx/hud/keys/key_right.tga"), ' 32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2291 void Sbar_ShowSpeed(void)
\r
2294 float pos, conversion_factor;
\r
2295 string speed, zspeed, unit;
\r
2297 switch(cvar("cl_showspeed_unit"))
\r
2302 conversion_factor = 1.0;
\r
2306 conversion_factor = 1.0;
\r
2310 conversion_factor = 0.0254;
\r
2314 conversion_factor = 0.0254 * 3.6;
\r
2318 conversion_factor = 0.0254 * 3.6 * 0.6213711922;
\r
2322 conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
\r
2326 speed = strcat(ftos(floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 )), unit);
\r
2328 numsize_x = numsize_y = cvar("cl_showspeed_size");
\r
2329 pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
\r
2331 drawfont = sbar_bigfont;
\r
2332 drawstringcenter('1 0 0' + pos * '0 1 0', speed, numsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2334 if (cvar("cl_showspeed_z") == 1) {
\r
2335 zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
\r
2336 drawstringcenter('1 0 0' + pos * '0 1 0' + numsize_y * '0 1 0', zspeed, numsize * 0.5, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2339 drawfont = sbar_font;
\r
2342 vector acc_prevspeed;
\r
2343 float acc_prevtime;
\r
2346 void Sbar_ShowAcceleration(void)
\r
2348 float acceleration, sz, scale, alpha, f;
\r
2349 vector pos, top, rgb;
\r
2350 top_x = vid_conwidth/2;
\r
2353 f = time - acc_prevtime;
\r
2354 if(cvar("cl_showacceleration_z"))
\r
2355 acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
\r
2357 acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
\r
2358 acc_prevspeed = pmove_vel;
\r
2359 acc_prevtime = time;
\r
2361 f = bound(0, f * 10, 1);
\r
2362 acc_avg = acc_avg * (1 - f) + acceleration * f;
\r
2363 acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
\r
2365 pos = top - sz/2 * '0 1 0' + (cvar("cl_showacceleration_position") * vid_conheight) * '0 1 0';
\r
2367 sz = cvar("cl_showacceleration_size");
\r
2368 scale = cvar("cl_showacceleration_scale");
\r
2369 alpha = cvar("cl_showacceleration_alpha");
\r
2370 if (cvar("cl_showacceleration_color_custom"))
\r
2371 rgb = stov(cvar_string("cl_showacceleration_color"));
\r
2374 if (acceleration < 0) {
\r
2375 rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
\r
2376 } else if (acceleration > 0) {
\r
2377 rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
\r
2381 if (acceleration > 0)
\r
2382 drawpic(pos, "gfx/hud/accelerometer_gradient", acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2383 else if (acceleration < 0)
\r
2384 drawpic(pos + acceleration * scale * '40 0 0', "gfx/hud/accelerometer_gradient", -acceleration * scale * '40 0 0' + sz * '0 1 0', rgb, alpha * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2387 void Sbar_DrawAccuracyStats_Description_Hitscan(vector position)
\r
2389 drawstring(position + '0 3 0' * sbar_fontsize_y, "Shots fired:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2390 drawstring(position + '0 5 0' * sbar_fontsize_y, "Shots hit:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2391 drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2392 drawstring(position + '0 9 0' * sbar_fontsize_y, "Shots missed:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2395 /*void Sbar_DrawAccuracyStats_Description_Splash(vector position)
\r
2397 drawstring(position + '0 3 0' * sbar_fontsize_y, "Maximum damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2398 drawstring(position + '0 5 0' * sbar_fontsize_y, "Actual damage:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2399 drawstring(position + '0 7 0' * sbar_fontsize_y, "Accuracy:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2400 drawstring(position + '0 9 0' * sbar_fontsize_y, "Damage wasted:", sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2401 }*/ // we have no splash damage weapons, but keep this code just in case
\r
2403 void Sbar_DrawAccuracyStats()
\r
2405 float i, count_hitscan, /*count_splash,*/ row_hitscan/*, row_splash*/; // count is the number of 'colums'
\r
2406 float weapon_hit, weapon_damage, weapon_stats;
\r
2407 float left_border; // position where the weapons start, the description is in the border
\r
2408 vector fill_colour, fill_size;
\r
2410 vector border_colour;
\r
2412 float col_margin = 20; // pixels between the columns
\r
2413 float row_margin = 20; // pixels between the rows
\r
2415 fill_size_x = 5 * sbar_fontsize_x; // width of the background
\r
2416 fill_size_y = 10 * sbar_fontsize_y; // height of the background
\r
2418 drawfont = sbar_bigfont;
\r
2420 pos_y = cvar("sbar_scoreboard_offset");
\r
2422 drawstringcenter(pos, "Weapon Accuracy", 2 * sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2424 left_border = col_margin + 11 * sbar_fontsize_x;
\r
2426 drawfont = sbar_font;
\r
2431 if(mod(time, 1) >= 0.4)
\r
2432 drawstringcenter(pos, "Stats are not tracked during warmup stage", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2437 if(gametype == GAME_RACE || gametype == GAME_CTS)
\r
2440 if(mod(time, 1) >= 0.4)
\r
2441 drawstringcenter(pos, "Stats are not tracked in Race/CTS", sbar_fontsize, '1 1 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2446 float top_border_hitscan = cvar("sbar_scoreboard_offset") + 55; // position where the hitscan row starts: pixels down the screen
\r
2447 Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * top_border_hitscan);
\r
2449 // float top_border_splash = cvar("sbar_scoreboard_offset") + 175; // position where the splash row starts: pixels down the screen
\r
2450 // Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * top_border_splash);
\r
2452 for(i = WEP_FIRST; i <= WEP_LAST; ++i)
\r
2454 self = get_weaponinfo(i);
\r
2455 if not(self.weapons)
\r
2457 weapon_hit = weapon_hits[i-WEP_FIRST];
\r
2458 weapon_damage = weapon_fired[i-WEP_FIRST];
\r
2459 border_colour = (i == activeweapon) ? '1 1 1' : '0 0 0'; // white or black border
\r
2461 if (weapon_damage) {
\r
2462 /*if (self.spawnflags & WEP_TYPE_SPLASH) {
\r
2463 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
2465 fill_colour_x = 1 - 0.015 * weapon_stats;
\r
2466 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
\r
2468 // how the background colour is calculated
\r
2469 // % red green red_2 green_2
\r
2470 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2471 // 10 0.85 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2472 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2473 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2474 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2475 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2476 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2477 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2478 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2479 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2480 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2482 if ((left_border + count_splash * (fill_size_x + col_margin) + fill_size_x) >= vid_conwidth)
\r
2486 Sbar_DrawAccuracyStats_Description_Splash('1 0 0' * col_margin + '0 1 0' * (top_border_splash + row_splash * (fill_size_y + row_margin)));
\r
2489 pos_x = left_border + count_splash * (fill_size_x + col_margin);
\r
2490 pos_y = top_border_splash + row_splash * (fill_size_y + row_margin);
\r
2493 drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2494 drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2497 drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2499 // the amount of shots fired or max damage
\r
2500 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2502 // the amount of hits or actual damage
\r
2503 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2506 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2508 // the amount of shots missed or damage wasted
\r
2509 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2512 } else*/ // we have no splash damage weapons, but keep this code just in case
\r
2514 if (self.spawnflags & WEP_TYPE_HITSCAN) {
\r
2515 weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100);
\r
2517 fill_colour_x = 1 - 0.015 * weapon_stats;
\r
2518 fill_colour_y = 1 - 0.015 * (100 - weapon_stats);
\r
2520 // how the background colour is calculated
\r
2521 // % red green red_2 green_2
\r
2522 // 0 1 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2523 // 10 0.850 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2524 // 20 0.70 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2525 // 30 0.55 0 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2526 // 40 0.40 0.10 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2527 // 50 0.25 0.25 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2528 // 60 0.10 0.40 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2529 // 70 0 0.55 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2530 // 80 0 0.70 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2531 // 90 0 0.85 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2532 // 100 0 1 1 - % * 0.015 1 - (100 - %) * 0.015
\r
2534 if ((left_border + count_hitscan * (fill_size_x + col_margin) + fill_size_x + cvar("stats_right_margin")) >= vid_conwidth)
\r
2536 count_hitscan = 0;
\r
2538 Sbar_DrawAccuracyStats_Description_Hitscan('1 0 0' * col_margin + '0 1 0' * (top_border_hitscan + row_hitscan * (fill_size_y + row_margin)));
\r
2541 pos_x = left_border + count_hitscan * (fill_size_x + col_margin);
\r
2542 pos_y = top_border_hitscan + row_hitscan * (fill_size_y + row_margin);
\r
2545 drawpic(pos, "gfx/hud/sb_accuracy", fill_size , fill_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2546 drawborderlines(sbar_border_thickness, pos, fill_size, border_colour, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2549 drawpic(pos, strcat("gfx/hud/inv_weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2551 // the amount of shots fired or max damage
\r
2552 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 3 0' * sbar_fontsize_y, ftos(weapon_damage), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2554 // the amount of hits or actual damage
\r
2555 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 5 0' * sbar_fontsize_y, ftos(weapon_hit), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2558 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 7 0' * sbar_fontsize_y, strcat(ftos(weapon_stats),"%"), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2560 // the amount of shots missed or damage wasted
\r
2561 drawstringright(pos + '4.5 0 0' * sbar_fontsize_x + '0 9 0' * sbar_fontsize_y, ftos(max(0, weapon_damage - weapon_hit)), sbar_fontsize, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2569 void drawstringright(vector position, string text, vector scale, vector rgb, float alpha, float flag)
\r
2571 position_x -= 2 / 3 * strlen(text) * scale_x;
\r
2572 drawstring(position, text, scale, rgb, alpha, flag);
\r
2575 void drawstringcenter(vector position, string text, vector scale, vector rgb, float alpha, float flag)
\r
2577 position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * scale_x);
\r
2578 drawstring(position, text, scale, rgb, alpha, flag);
\r
2581 float GetAmmoStat(float i)
\r
2585 case 0: return STAT_FUEL;
\r
2586 default: return -1;
\r
2590 float GetAmmoItemCode(float i)
\r
2594 case 0: return IT_FUEL;
\r
2595 default: return -1;
\r
2599 string GetAmmoPicture(float i)
\r
2603 case 0: return "gfx/hud/sb_fuel";
\r
2604 default: return "";
\r
2608 void Sbar_Reset (void)
\r
2610 // reset gametype specific icons
\r
2611 if(gametype == GAME_KEYHUNT)
\r
2612 CSQC_kh_hudreset();
\r
2613 else if(gametype == GAME_CTF)
\r
2614 CSQC_ctf_hudreset();
\r
2617 float vote_yescount;
\r
2618 float vote_nocount;
\r
2619 float vote_needed;
\r
2620 float vote_highlighted; // currently selected vote
\r
2622 float vote_active; // is there an active vote?
\r
2623 float vote_prev; // previous state of vote_active to check for a change
\r
2625 float vote_change; // "time" when vote_active changed
\r
2627 vector stomachstatus_colorfade_current;
\r
2628 vector StomachStatus_ColorFade(vector target_color)
\r
2631 step = cvar("sbar_stomachboard_status_fade") * frametime;
\r
2633 if(stomachstatus_colorfade_current_x >= target_color_x + step)
\r
2634 stomachstatus_colorfade_current_x -= step;
\r
2635 else if(stomachstatus_colorfade_current_x <= target_color_x - step)
\r
2636 stomachstatus_colorfade_current_x += step;
\r
2638 if(stomachstatus_colorfade_current_y >= target_color_y + step)
\r
2639 stomachstatus_colorfade_current_y -= step;
\r
2640 else if(stomachstatus_colorfade_current_y <= target_color_y - step)
\r
2641 stomachstatus_colorfade_current_y += step;
\r
2643 if(stomachstatus_colorfade_current_z >= target_color_z + step)
\r
2644 stomachstatus_colorfade_current_z -= step;
\r
2645 else if(stomachstatus_colorfade_current_z <= target_color_z - step)
\r
2646 stomachstatus_colorfade_current_z += step;
\r
2648 return stomachstatus_colorfade_current;
\r
2651 void Sbar_Draw (void)
\r
2653 // vectors for top right, bottom right, bottom and bottom left corners
\r
2656 vector bottomright;
\r
2657 vector bottomleft;
\r
2659 topright_x = vid_conwidth;
\r
2663 bottom_x = vid_conwidth/2;
\r
2664 bottom_y = vid_conheight;
\r
2667 bottomright_x = vid_conwidth;
\r
2668 bottomright_y = vid_conheight;
\r
2669 bottomright_z = 0;
\r
2672 bottomleft_y = vid_conheight;
\r
2675 sbar_alpha_bg = cvar("sbar_alpha_bg") * (1 - cvar("_menu_alpha"));
\r
2676 sbar_border_thickness = bound(0, cvar("sbar_border_thickness"), 5);
\r
2677 sbar_accuracy_border_thickness = bound(0, cvar_or("sbar_accuracy_border_thickness", 1), 5);
\r
2678 sbar_color_bg_team = cvar("sbar_color_bg_team");
\r
2680 float weapon_stats;
\r
2682 float stat_items, stat_weapons;
\r
2684 weapon_stats = getstati(STAT_DAMAGE_HITS);
\r
2685 weapon_number = weapon_stats & 63;
\r
2686 weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
\r
2688 weapon_stats = getstati(STAT_DAMAGE_FIRED);
\r
2689 weapon_number = weapon_stats & 63;
\r
2690 weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
\r
2692 vector o; o = '1 0 0' * vid_conwidth;
\r
2693 o_y = 28; // move spectator text slightly down to prevent overlapping the timer
\r
2699 sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
\r
2700 sbar_fontsize_spec = Sbar_GetFontsize("sbar_fontsize_spec");
\r
2701 if(sbar_fontsize != sbar_oldfontsize)
\r
2703 Cmd_Sbar_SetFields(0);
\r
2704 sbar_oldfontsize = sbar_fontsize;
\r
2707 if(spectatee_status && !intermission)
\r
2709 drawfont = sbar_bigfont;
\r
2710 if(spectatee_status == -1)
\r
2711 s = "^1Observing";
\r
2713 s = GetPlayerName(spectatee_status - 1);
\r
2714 // spectated player name between HUD and chat area, aligned to the left
\r
2715 pos_x = bottomleft_x;
\r
2716 pos_y = bottom_y - 200 - sbar_fontsize_spec_y;
\r
2717 s = textShortenToWidth(s, vid_conwidth/2.5, sbar_fontsize_spec, stringwidth_colors);
\r
2718 drawcolorcodedstring(pos, s, sbar_fontsize_spec, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2719 drawfont = sbar_font;
\r
2721 // spectator text in the upper right corner
\r
2722 if(spectatee_status == -1)
\r
2723 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
\r
2725 s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
\r
2726 o = Sbar_DrawNoteLine(o, s);
\r
2728 if(spectatee_status == -1)
\r
2729 s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
\r
2731 s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
\r
2732 o = Sbar_DrawNoteLine(o, s);
\r
2734 s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
\r
2735 o = Sbar_DrawNoteLine(o, s);
\r
2737 if(gametype == GAME_ARENA)
\r
2738 s = "^1Wait for your turn to join";
\r
2739 else if(gametype == GAME_LMS)
\r
2742 sk = playerslots[player_localentnum - 1];
\r
2743 if(sk.(scores[ps_primary]) >= 666)
\r
2744 s = "^1Match has already begun";
\r
2745 else if(sk.(scores[ps_primary]) > 0)
\r
2746 s = "^1You have no more lives left";
\r
2748 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
\r
2751 s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
\r
2752 o = Sbar_DrawNoteLine(o, s);
\r
2754 //show restart countdown:
\r
2755 if (time < getstatf(STAT_GAMESTARTTIME)) {
\r
2757 //we need to ceil, otherwise the countdown would be off by .5 when using round()
\r
2758 countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
\r
2759 s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
\r
2760 o = Sbar_DrawNoteLine(o, s);
\r
2763 if(warmup_stage && !intermission)
\r
2765 s = "^2Currently in ^1warmup^2 stage!";
\r
2766 o = Sbar_DrawNoteLine(o, s);
\r
2769 // move more important stuff more to the middle so its more visible
\r
2770 o_y = vid_conheight * 0.66;
\r
2772 string blinkcolor;
\r
2773 if(mod(time, 1) >= 0.5)
\r
2774 blinkcolor = "^1";
\r
2776 blinkcolor = "^3";
\r
2778 if(ready_waiting && !intermission && !spectatee_status)
\r
2780 if(ready_waiting_for_me)
\r
2783 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " to end warmup");
\r
2785 s = strcat(blinkcolor, "Press ^3", getcommandkey("ready", "ready"), blinkcolor, " once you are ready");
\r
2790 s = strcat("^2Waiting for others to ready up to end warmup...");
\r
2792 s = strcat("^2Waiting for others to ready up...");
\r
2794 o = Sbar_DrawNoteLine(o, s);
\r
2796 else if(warmup_stage && !intermission && !spectatee_status)
\r
2798 s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
\r
2799 o = Sbar_DrawNoteLine(o, s);
\r
2802 if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
\r
2805 float ts_min, ts_max;
\r
2806 tm = teams.sort_next;
\r
2809 for(; tm.sort_next; tm = tm.sort_next)
\r
2811 if(!tm.team_size || tm.team == COLOR_SPECTATOR)
\r
2813 if(!ts_min) ts_min = tm.team_size;
\r
2814 else ts_min = min(ts_min, tm.team_size);
\r
2815 if(!ts_max) ts_max = tm.team_size;
\r
2816 else ts_max = max(ts_max, tm.team_size);
\r
2818 if ((ts_max - ts_min) > 1)
\r
2820 s = strcat(blinkcolor, "Teamnumbers are unbalanced!");
\r
2821 tm = GetTeam(myteam, false);
\r
2823 if (tm.team != COLOR_SPECTATOR)
\r
2824 if (tm.team_size == ts_max)
\r
2825 s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
\r
2827 o = Sbar_DrawNoteLine(o, s);
\r
2832 if(vote_active != vote_prev) {
\r
2833 vote_change = time;
\r
2834 vote_prev = bound(0, vote_active, 1);
\r
2838 vote_alpha = bound(0, (time - vote_change) * 2, 1);
\r
2840 vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
\r
2844 a = vote_alpha * bound(cvar_or("sbar_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
\r
2847 color = GetTeamRGB(myteam) * sbar_color_bg_team;
\r
2849 color_x = cvar("sbar_color_bg_r");
\r
2850 color_y = cvar("sbar_color_bg_g");
\r
2851 color_z = cvar("sbar_color_bg_b");
\r
2854 vector voteorigin = bottomright - '290 135 0';
\r
2855 vector votesize = '280 70 0';
\r
2856 drawpic(voteorigin, "gfx/hud/voteprogress_back", votesize, color, a * sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2858 s = "A vote has been called for: ";
\r
2859 drawstring(voteorigin + '0.5 0 0' * votesize_x + '0 0.1 0' * votesize_y - '1 0 0' * stringwidth(s, FALSE, '6 0 0'), s, '12 12 0', '1 1 1', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2860 s = textShortenToWidth(vote_called_vote, votesize_x * 0.96, '10 0 0', stringwidth_colors);
\r
2861 drawcolorcodedstring(voteorigin + '0.52 0 0' * votesize_x + '0 0.3 0' * votesize_y - '1 0 0' * stringwidth(s, FALSE, '5 0 0'), s, '10 10 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2863 // print the yes/no counts
\r
2864 s = strcat("Yes: ", ftos(vote_yescount));
\r
2865 drawstring(voteorigin + '0 0.6 0' * votesize_y + '0.02 0 0' * votesize_x, s, '12 12 0', '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2866 s = strcat("No: ", ftos(vote_nocount));
\r
2867 drawstring(voteorigin + '0 0.6 0' * votesize_y + '0.98 0 0' * votesize_x - '1 0 0' * stringwidth(s, FALSE, '12 0 0'), s, '12 12 0', '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2869 // draw the progress bars
\r
2870 drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5 * (vote_yescount/vote_needed), votesize_y);
\r
2871 drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2873 drawsetcliparea(voteorigin_x + votesize_x - votesize_x * 0.5 * (vote_nocount/vote_needed), voteorigin_y, votesize_x * 0.5, votesize_y);
\r
2874 drawpic(voteorigin, "gfx/hud/voteprogress_prog", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2876 // draw the highlights
\r
2877 if(vote_highlighted == 1) {
\r
2878 drawsetcliparea(voteorigin_x, voteorigin_y, votesize_x * 0.5, votesize_y);
\r
2879 drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '0 1 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2881 else if(vote_highlighted == 2) {
\r
2882 drawsetcliparea(voteorigin_x + 0.5 * votesize_x, voteorigin_y, votesize_x * 0.5, votesize_y);
\r
2883 drawpic(voteorigin, "gfx/hud/voteprogress_voted", votesize, '1 0 0', a * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2886 drawresetcliparea();
\r
2888 else if(!vote_active) {
\r
2889 vote_highlighted = 0;
\r
2892 Sbar_UpdatePlayerTeams();
\r
2893 if (intermission == 2) // map voting screen
\r
2897 Sbar_DrawScoreboard();
\r
2899 Sbar_FinaleOverlay();
\r
2903 else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)
\r
2905 Sbar_DrawScoreboard();
\r
2911 StomachStatus_ColorFade('0 0 0');
\r
2915 if(sb_showaccuracy && spectatee_status != -1)
\r
2916 Sbar_DrawAccuracyStats();
\r
2918 Sbar_DrawScoreboard();
\r
2919 float armor, health;
\r
2920 armor = getstati(STAT_ARMOR);
\r
2921 health = getstati(STAT_HEALTH);
\r
2923 stat_items = getstati(STAT_ITEMS);
\r
2924 stat_weapons = getstati(STAT_WEAPONS);
\r
2926 fade = 3.2 - 2 * (time - weapontime);
\r
2927 fade = bound(0.7, fade, 1);
\r
2929 if(g_vore) // only when the vore system is active
\r
2931 // draw the stomach board
\r
2932 if (cvar("viewsize") <= 100) {
\r
2934 drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color
\r
2936 // allow for custom HUD colors in non-teamgames
\r
2937 color_x = cvar("sbar_color_bg_r");
\r
2938 color_y = cvar("sbar_color_bg_g");
\r
2939 color_z = cvar("sbar_color_bg_b");
\r
2941 drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
2945 if(getstati(STAT_VORE_EATEN))
\r
2947 drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color2"))), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2948 drawstring(bottomleft - '-80 172 0', "predator:", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2952 drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color1"))), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2953 drawstring(bottomleft - '-80 172 0', "self:", '10 10 0', ' 1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2956 float stomach_load;
\r
2957 stomach_load = getstati(STAT_VORE_LOAD); // shows the predator's stomach load when we are eaten, and ours otherwise
\r
2959 Sbar_DrawXNum(bottomleft - '-26 171 0', bound(0, stomach_load, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2960 drawstring(bottomleft - '-41 171 0', "/", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2961 Sbar_DrawXNum(bottomleft - '-50 171 0', bound(0, g_balance_vore_swallow_limit, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2963 if(getstati(STAT_VORE_DIGESTING))
\r
2964 drawstring(bottomleft - '-76 142 0', "stomach digesting", '12 12 0', '1 0.5 0.5', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2965 else if(stomach_load == g_balance_vore_swallow_limit)
\r
2966 drawstring(bottomleft - '-76 142 0', "stomach full", '12 12 0', '0.5 1 0.5', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2967 else if(!stomach_load)
\r
2968 drawstring(bottomleft - '-76 142 0', "stomach empty", '12 12 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2970 drawstring(bottomleft - '-76 142 0', "stomach has prey", '12 12 0', '0.75 1 0.75', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
2972 // draw the stomach board player list
\r
2977 for(pl = players.sort_next; pl; pl = pl.sort_next)
\r
2979 if(pl.team == COLOR_SPECTATOR)
\r
2982 if(getstati(STAT_VORE_EATEN))
\r
2983 f = pl.plpredator == getstati(STAT_VORE_EATEN);
\r
2986 if(spectatee_status)
\r
2987 f = pl.plpredator == spectatee_status;
\r
2989 f = pl.plpredator == player_localentnum;
\r
2994 Sbar_PrintStomachboardItem(pos - '-16 124 0', pl);
\r
2995 pos_y += 1.25 * sbar_fontsize_y;
\r
2998 if(getstati(STAT_VORE_EATEN))
\r
2999 if(pl.sv_entnum == getstati(STAT_VORE_EATEN) - 1)
\r
3000 Sbar_PrintStomachboardItemPred(bottomleft - '-76 156 0', pl);
\r
3004 if (cvar("viewsize") <= 100) {
\r
3006 drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color
\r
3008 // allow for custom HUD colors in non-teamgames
\r
3009 color_x = cvar("sbar_color_bg_r");
\r
3010 color_y = cvar("sbar_color_bg_g");
\r
3011 color_z = cvar("sbar_color_bg_b");
\r
3013 drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);
\r
3017 vector health_pos, armor_pos;
\r
3018 health_pos = bottom - '60 58 0';
\r
3019 armor_pos = bottom - '52.5 68 0';
\r
3025 drawpic(armor_pos + '0 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3026 if(x < 100) armor_pos_x += 2.5; // always center
\r
3027 if(x < 10) armor_pos_x += 2.5; // always center
\r
3028 Sbar_DrawXNum_Colored(armor_pos, x, 12, sbar_alpha_fg);
\r
3033 drawpic(health_pos + '4.5 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3034 if(x < 100) health_pos_x += 5; // always center
\r
3035 if(x < 10) health_pos_x += 5; // always center
\r
3036 Sbar_DrawXNum_Colored(health_pos, x, 22, sbar_alpha_fg);
\r
3039 pos_x = bottom_x + 140;
\r
3040 pos_y = bottom_y - 20;
\r
3042 float weapon_clipload, weapon_clipsize;
\r
3044 // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon
\r
3045 if(stat_items & IT_JETPACK && button_jetpack)
\r
3047 a = getstati(GetAmmoStat(0)); // how much fuel do we have?
\r
3048 drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3049 Sbar_DrawXNum(pos - '128 16 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3054 for (i = 0; i < 1; ++i)
\r
3056 if (stat_items & GetAmmoItemCode(i))
\r
3058 a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?
\r
3059 drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3060 weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);
\r
3062 // if the weapon we're holding is reloadable, show both its ammo and load
\r
3063 if(weapon_clipsize)
\r
3065 weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);
\r
3066 if(weapon_clipload < 0) // we're reloading
\r
3067 drawstring(pos - '104 23 0', "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3069 Sbar_DrawXNum(pos - '124 23 0', weapon_clipload, 2, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3070 Sbar_DrawXNum(pos - '126 7 0', a, 3, 0, 12, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3073 Sbar_DrawXNum(pos - '128 16 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3080 e = get_weaponinfo(activeweapon);
\r
3081 if (e && e.netname != "" && e.netname != "N/A")
\r
3082 drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3084 // draw scores and timer
\r
3088 // draw strength/invincibility icon and timer
\r
3089 CSQC_Strength_Timer();
\r
3091 // draw gametype specific icons
\r
3092 if(gametype == GAME_KEYHUNT)
\r
3094 else if(gametype == GAME_CTF)
\r
3096 else if(gametype == GAME_CTS || gametype == GAME_RACE)
\r
3099 // draw the canleave message
\r
3100 if(getstati(STAT_VORE_CANLEAVE))
\r
3101 if not(spectatee_status) // this message doesn't address spectated players
\r
3103 s = strcat("^7Press ^3", getcommandkey("jump", "+jump"), " ^7to exit");
\r
3104 pos_x = bottom_x - stringwidth(s, TRUE, '0 0 0') * 16 / 2;
\r
3105 pos_y = bottom_y - 120;
\r
3106 drawcolorcodedstring(pos, s, '16 16 0', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3113 float redflag_prevframe, blueflag_prevframe; // status during previous frame
\r
3114 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
\r
3115 float redflag_statuschange_time, blueflag_statuschange_time; // time when the status changed
\r
3117 void CSQC_ctf_hudreset(void)
\r
3119 redflag_prevstatus = blueflag_prevstatus = redflag_prevframe = blueflag_prevframe = redflag_statuschange_time = blueflag_statuschange_time = 0;
\r
3122 void CSQC_ctf_hud(void)
\r
3124 vector top, redflag_pos, blueflag_pos, sz;
\r
3125 float f; // every function should have that
\r
3126 top_x = vid_conwidth / 2;
\r
3130 float redflag, blueflag; // current status
\r
3131 float redflag_statuschange_elapsedtime, blueflag_statuschange_elapsedtime; // time since the status changed
\r
3134 stat_items = getstati(STAT_ITEMS);
\r
3135 redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
\r
3136 blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
\r
3138 // when status CHANGES, set old status into prevstatus and current status into status
\r
3139 if (redflag != redflag_prevframe)
\r
3141 redflag_statuschange_time = time;
\r
3142 redflag_prevstatus = redflag_prevframe;
\r
3143 redflag_prevframe = redflag;
\r
3146 if (blueflag != blueflag_prevframe)
\r
3148 blueflag_statuschange_time = time;
\r
3149 blueflag_prevstatus = blueflag_prevframe;
\r
3150 blueflag_prevframe = blueflag;
\r
3153 redflag_statuschange_elapsedtime = time - redflag_statuschange_time;
\r
3154 blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time;
\r
3156 float BLINK_FACTOR = 0.15;
\r
3157 float BLINK_BASE = 0.85;
\r
3159 // RMS = sqrt(BLINK_BASE^2 + 0.5 * BLINK_FACTOR^2)
\r
3161 // BLINK_BASE = sqrt(RMS^2 - 0.5 * BLINK_FACTOR^2)
\r
3162 // ensure RMS == 1
\r
3163 float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz
\r
3165 string red_icon, red_icon_prevstatus;
\r
3166 float red_alpha, red_alpha_prevstatus;
\r
3167 red_alpha = red_alpha_prevstatus = 1;
\r
3169 case 1: red_icon = "gfx/hud/sb_flag_red_taken"; break;
\r
3170 case 2: red_icon = "gfx/hud/sb_flag_red_lost"; break;
\r
3171 case 3: red_icon = "gfx/hud/sb_flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3173 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
\r
3174 red_icon = "gfx/hud/sb_flag_red_shielded";
\r
3176 red_icon = string_null;
\r
3179 switch(redflag_prevstatus) {
\r
3180 case 1: red_icon_prevstatus = "gfx/hud/sb_flag_red_taken"; break;
\r
3181 case 2: red_icon_prevstatus = "gfx/hud/sb_flag_red_lost"; break;
\r
3182 case 3: red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3185 red_icon_prevstatus = "gfx/hud/sb_flag_red_carrying"; // make it more visible
\r
3186 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM2))
\r
3187 red_icon_prevstatus = "gfx/hud/sb_flag_red_shielded";
\r
3189 red_icon_prevstatus = string_null;
\r
3193 string blue_icon, blue_icon_prevstatus;
\r
3194 float blue_alpha, blue_alpha_prevstatus;
\r
3195 blue_alpha = blue_alpha_prevstatus = 1;
\r
3196 switch(blueflag) {
\r
3197 case 1: blue_icon = "gfx/hud/sb_flag_blue_taken"; break;
\r
3198 case 2: blue_icon = "gfx/hud/sb_flag_blue_lost"; break;
\r
3199 case 3: blue_icon = "gfx/hud/sb_flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3201 if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
\r
3202 blue_icon = "gfx/hud/sb_flag_blue_shielded";
\r
3204 blue_icon = string_null;
\r
3207 switch(blueflag_prevstatus) {
\r
3208 case 1: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_taken"; break;
\r
3209 case 2: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_lost"; break;
\r
3210 case 3: blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break;
\r
3213 blue_icon_prevstatus = "gfx/hud/sb_flag_blue_carrying"; // make it more visible
\r
3214 else if((stat_items & IT_CTF_SHIELDED) && (myteam == COLOR_TEAM1))
\r
3215 blue_icon_prevstatus = "gfx/hud/sb_flag_blue_shielded";
\r
3217 blue_icon_prevstatus = string_null;
\r
3221 if (myteam == COLOR_TEAM1) { // always draw own flag on left
\r
3222 redflag_pos = top + '-52 50 0';
\r
3223 blueflag_pos = top + '0 40 0';
\r
3225 blueflag_pos = top + '-52 50 0';
\r
3226 redflag_pos = top + '0 40 0';
\r
3231 f = bound(0, redflag_statuschange_elapsedtime*2, 1);
\r
3232 if(red_icon_prevstatus && f < 1)
\r
3233 drawpic_expanding(redflag_pos, red_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * red_alpha_prevstatus, DRAWFLAG_NORMAL, f);
\r
3235 drawpic(redflag_pos, red_icon, sz, '1 1 1', sbar_alpha_fg * red_alpha * f, DRAWFLAG_NORMAL);
\r
3237 f = bound(0, blueflag_statuschange_elapsedtime*2, 1);
\r
3238 if(blue_icon_prevstatus && f < 1)
\r
3239 drawpic_expanding(blueflag_pos, blue_icon_prevstatus, sz, '1 1 1', sbar_alpha_fg * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f);
\r
3241 drawpic(blueflag_pos, blue_icon, sz, '1 1 1', sbar_alpha_fg * blue_alpha * f, DRAWFLAG_NORMAL);
\r
3245 float kh_runheretime;
\r
3247 void CSQC_kh_hudreset(void)
\r
3249 kh_runheretime = 0;
\r
3252 void CSQC_kh_hud(void)
\r
3257 vector p, pa, kh_size, kh_asize;
\r
3260 top_x = vid_conwidth / 2;
\r
3264 p = top + '-50 64 0';
\r
3266 kh_keys = getstati(STAT_KH_KEYS);
\r
3268 kh_size = '19 34 0';
\r
3269 kh_asize = '19 10 0';
\r
3270 pa = p + '0 -10 0';
\r
3276 for(i = 0; i < 4; ++i)
\r
3278 key = floor(kh_keys / pow(32, i)) & 31;
\r
3279 keyteam = key - 1;
\r
3280 if(keyteam == 30 && keycount <= 4)
\r
3282 if(keyteam == myteam || keyteam == -1 || keyteam == 30)
\r
3285 // this yields 8 exactly if "RUN HERE" shows
\r
3289 if(!kh_runheretime)
\r
3290 kh_runheretime = time;
\r
3291 pa_y -= fabs(sin((time - kh_runheretime) * 3.5)) * 6; // make the arrows jump in case of RUN HERE
\r
3294 kh_runheretime = 0;
\r
3296 for(i = 0; i < 4; ++i)
\r
3298 key = floor(kh_keys / pow(32, i)) & 31;
\r
3299 keyteam = key - 1;
\r
3302 case 30: // my key
\r
3307 case -1: // no key
\r
3311 default: // owned or dropped
\r
3316 a = a * sbar_alpha_fg;
\r
3317 aa = aa * sbar_alpha_fg;
\r
3323 drawpic (pa, "gfx/hud/sb_kh_redarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3326 drawpic (pa, "gfx/hud/sb_kh_bluearrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3329 drawpic (pa, "gfx/hud/sb_kh_yellowarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3332 drawpic (pa, "gfx/hud/sb_kh_pinkarrow", kh_asize, '1 1 1', aa, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3337 switch(i) // YAY! switch(i) inside a for loop for i. DailyWTF, here we come!
\r
3340 drawpic (p, "gfx/hud/sb_kh_red", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3343 drawpic (p, "gfx/hud/sb_kh_blue", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3346 drawpic (p, "gfx/hud/sb_kh_yellow", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3349 drawpic (p, "gfx/hud/sb_kh_pink", kh_size, '1 1 1', a, DRAWFLAG_NORMAL); // show 30% alpha key
\r
3358 float crecordtime_prev; // last remembered crecordtime
\r
3359 float crecordtime_change_time; // time when crecordtime last changed
\r
3360 float srecordtime_prev; // last remembered srecordtime
\r
3361 float srecordtime_change_time; // time when srecordtime last changed
\r
3362 void CSQC_race_hud(void)
\r
3365 me = playerslots[player_localentnum - 1];
\r
3367 float f; // yet another function has this
\r
3368 score = me.(scores[ps_primary]);
\r
3370 if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
\r
3371 return; // no records in the actual race
\r
3373 drawfont = sbar_bigfont;
\r
3376 pos_y = vid_conheight - 272;
\r
3378 // clientside personal record
\r
3380 if(gametype == GAME_CTS)
\r
3384 t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
\r
3386 if(score && score < t || !t)
\r
3387 db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
\r
3389 if(t != crecordtime_prev) {
\r
3390 crecordtime_prev = t;
\r
3391 crecordtime_change_time = time;
\r
3393 f = time - crecordtime_change_time;
\r
3396 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3397 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3399 drawstring(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3400 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3401 drawstring_expanding(pos, "Personal best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3402 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3407 t = race_server_record;
\r
3408 if(t != srecordtime_prev) {
\r
3409 srecordtime_prev = t;
\r
3410 srecordtime_change_time = time;
\r
3412 f = time - srecordtime_change_time;
\r
3415 drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3416 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3418 drawstring(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3419 drawstring(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);
\r
3420 drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3421 drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL, f);
\r
3423 drawfont = sbar_font;
\r