Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
scoreboard.qh File Reference
#include "../panel.qh"
Include dependency graph for scoreboard.qh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GET_NEXTMAP()

Functions

void Cmd_Scoreboard_SetFields (int argc)
float HUD_Scoreboard_InputEvent (float bInputType, float nPrimary, float nSecondary)
void Scoreboard_Draw ()
void Scoreboard_InitScores ()
void Scoreboard_UI_Enable (int mode)
void Scoreboard_UpdatePlayerPos (entity pl)
void Scoreboard_UpdatePlayerTeams ()
void Scoreboard_UpdateTeamPos (entity Team)
bool Scoreboard_WouldDraw ()

Variables

string autocvar__nextmap
bool autocvar__scoreboard_team_selection
bool autocvar_cl_deathscoreboard
float autocvar_cl_deathscoreboard_delay = 1
float autocvar_hud_panel_scoreboard_namesize = 15
string autocvar_scoreboard_columns
bool ignored
int numplayers
int SB_PANEL_FIRST = 1
int SB_PANEL_MAX = 2
int SB_PANEL_RANKINGS = 2
int SB_PANEL_SCOREBOARD = 1
bool sb_showscores
float scoreboard_acc_fade_alpha
bool scoreboard_active
float scoreboard_bottom
float scoreboard_fade_alpha
float scoreboard_itemstats_fade_alpha
float scoreboard_left
float scoreboard_right
int scoreboard_selected_columns_layout
int scoreboard_selected_panel
float scoreboard_selected_panel_time
entity scoreboard_selected_player
entity scoreboard_selected_team
float scoreboard_top
int scoreboard_ui_enabled
int ts_max
 team size
int ts_min

Macro Definition Documentation

◆ GET_NEXTMAP

#define GET_NEXTMAP ( )
Value:
string autocvar__nextmap
Definition scoreboard.qh:9

Definition at line 12 of file scoreboard.qh.

Referenced by Scoreboard_Draw().

Function Documentation

◆ Cmd_Scoreboard_SetFields()

void Cmd_Scoreboard_SetFields ( int argc)

Definition at line 767 of file scoreboard.qc.

768{
769 TC(int, argc);
770 if (!gametype)
771 return; // do nothing, we don't know gametype and scores yet
772
773 int i;
774 bool have_name = false, have_primary = false, have_secondary = false, have_separator = false;
775
776 // sbt_fields uses strunzone on the titles!
777 if (!sbt_field_title[0])
778 for (i = 0; i < MAX_SBT_FIELDS; ++i)
779 sbt_field_title[i] = strzone("(null)");
780
781 // TODO: re enable with gametype dependant cvars?
782 if (argc < 3) // no arguments provided
784
785 if (argc < 3)
787
788 if (argc == 3)
789 {
790 if (argv(2) == "default" || argv(2) == "expand_default")
791 {
792 if (argv(2) == "expand_default")
793 cvar_set("scoreboard_columns", SCOREBOARD_DEFAULT_COLUMNS);
795 }
796 else if (argv(2) == "all" || argv(2) == "ALL")
797 {
798 string s = "ping pl name |"; // scores without label (not really scores)
799 if (argv(2) == "ALL")
800 {
801 // scores without label
802 s = strcat(s, " ", "sum");
803 s = strcat(s, " ", "kdratio");
804 s = strcat(s, " ", "frags");
805 }
806 FOREACH(Scores, true,
807 {
808 if (it != ps_primary && it != ps_secondary && scores_label(it) != "")
809 s = strcat(s, " ", scores_label(it));
810 });
812 s = strcat(s, " ", scores_label(ps_secondary));
813 s = strcat(s, " ", scores_label(ps_primary));
814 argc = tokenizebyseparator(strcat("0 1 ", s), " ");
815 }
816 }
817
818
819 sbt_num_fields = 0;
820
821 hud_fontsize = HUD_GetFontsize("hud_fontsize");
822
823 string str, pattern;
824 int slash;
825 bool nocomplain;
826 for (i = 1; i < argc - 1; ++i)
827 {
828 str = argv(i+1);
829 nocomplain = false;
830 if (substring(str, 0, 1) == "?")
831 {
832 nocomplain = true;
833 str = substring(str, 1, strlen(str) - 1);
834 }
835
836 slash = strstrofs(str, "/", 0);
837 if (slash >= 0)
838 {
839 pattern = substring(str, 0, slash);
840 str = substring(str, slash + 1, strlen(str) - (slash + 1));
841
842 if (!isGametypeInFilter(gametype, teamplay, false, pattern))
843 continue;
844 }
845
846 str = strtolower(str);
848
850 switch (str)
851 {
852 // fields without a label (not networked via the score system)
853 case "ping": sbt_field[sbt_num_fields] = SP_PING; break;
854 case "pl": sbt_field[sbt_num_fields] = SP_PL; break;
855 case "name":
856 case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break;
857 case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break;
858 case "kd":
859 case "kdr":
860 case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break;
861 case "sum":
862 case "diff":
863 case "k-d": sbt_field[sbt_num_fields] = SP_SUM; break;
864 case "frags": sbt_field[sbt_num_fields] = SP_FRAGS; break;
865 default: // fields with a label
866 {
867 // map alternative labels
868 if (str == "damage")
869 str = "dmg";
870 if (str == "damagetaken")
871 str = "dmgtaken";
872
873 FOREACH(Scores, str == strtolower(scores_label(it)),
874 {
875 j = it;
876 goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
877 });
878
879 // NOTE: can't check STAT(SHOWFPS) here, if checked too early it returns false anyway
880 if (!nocomplain && str != "fps" && str != "skill") // server can disable the fps or skill fields
881 LOG_INFOF("^1Error:^7 Unknown score field: '%s'", str);
882
884 continue;
885
886 LABEL(found)
888 if (j == ps_primary)
889 have_primary = true;
890 if (j == ps_secondary)
891 have_secondary = true;
892
893 }
894 }
897 break;
898 }
899
901 have_primary = true;
903 have_secondary = true;
905 have_secondary = true;
906 int missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
907
908 if (sbt_num_fields + missing < MAX_SBT_FIELDS)
909 {
910 if (!have_name)
911 {
913 for (i = sbt_num_fields; i > 0; --i)
914 {
916 sbt_field[i] = sbt_field[i-1];
917 }
919 sbt_field[0] = SP_NAME;
921 LOG_INFO("fixed missing field 'name'");
922
923 if (!have_separator)
924 {
926 for (i = sbt_num_fields; i > 1; --i)
927 {
929 sbt_field[i] = sbt_field[i-1];
930 }
931 sbt_field_title[1] = strzone("|");
932 sbt_field[1] = SP_SEPARATOR;
934 LOG_INFO("fixed missing field '|'");
935 }
936 }
937 else if (!have_separator)
938 {
940 sbt_field[sbt_num_fields] = SP_SEPARATOR;
942 LOG_INFO("fixed missing field '|'");
943 }
944 if (!have_secondary)
945 {
949 LOG_INFOF("fixed missing field '%s'", scores_label(ps_secondary));
950 }
951 if (!have_primary)
952 {
956 LOG_INFOF("fixed missing field '%s'", scores_label(ps_primary));
957 }
958 }
959
960 sbt_field[sbt_num_fields] = SP_END;
962}
vector hud_fontsize
Definition main.qh:77
entity gametype
Definition main.qh:43
#define scores_label(this)
Definition scores.qh:146
entity PlayerScoreField
Definition scores.qh:140
#define scores_flags(this)
Definition scores.qh:147
const int SFL_ALLOW_HIDE
Allow a column to be hidden (do not automatically add it even if it is a sorting key)
Definition scores.qh:112
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition util.qc:1087
string strtolower(string s)
#define LABEL(id)
Definition compiler.qh:34
#define strstrofs
#define strlen
#define tokenizebyseparator
vector HUD_GetFontsize(string cvarname)
Definition hud.qc:112
PlayerScoreField ps_secondary
Definition hud.qh:117
PlayerScoreField ps_primary
Definition hud.qh:117
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define TC(T, sym)
Definition _all.inc:82
#define LOG_INFO(...)
Definition log.qh:65
#define LOG_INFOF(...)
Definition log.qh:66
void cvar_set(string name, string value)
string substring(string s, float start, float length)
string strzone(string s)
string argv(float n)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
int sbt_num_fields
Definition scoreboard.qc:49
string TranslateScoresLabel(string label)
PlayerScoreField sbt_field[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:44
#define SCOREBOARD_DEFAULT_COLUMNS
const int MAX_SBT_FIELDS
Definition scoreboard.qc:42
int sb_field_sizes_init
Definition scoreboard.qc:56
string sbt_field_title[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:46
string autocvar_scoreboard_columns
Definition scoreboard.qh:6
#define strfree(this)
Definition string.qh:59
#define strcpy(this, s)
Definition string.qh:52
bool teamplay
Definition teams.qh:59

Referenced by Scoreboard_InitScores().

◆ HUD_Scoreboard_InputEvent()

float HUD_Scoreboard_InputEvent ( float bInputType,
float nPrimary,
float nSecondary )

Definition at line 231 of file scoreboard.qc.

232{
234 return false;
235
236 if (bInputType == 3)
237 {
238 mousepos.x = nPrimary;
239 mousepos.y = nSecondary;
240 return true;
241 }
242
243 if (bInputType == 2)
244 return false;
245
246 // at this point bInputType can only be 0 or 1 (key pressed or released)
247 bool key_pressed = bInputType == 0;
248
249 // ESC to exit (TAB-ESC works too)
250 if (nPrimary == K_ESCAPE)
251 {
252 if (!key_pressed)
253 return true;
255 return true;
256 }
257
258 // block any input while a menu dialog is fading
260 {
261 hudShiftState = 0;
262 return true;
263 }
264
265 // allow console bind to work
266 string con_keys = findkeysforcommand("toggleconsole", 0);
267 int keys = tokenize(con_keys); // findkeysforcommand returns data for this
268
269 bool hit_con_bind = false;
270 for (int i = 0; i < keys; ++i)
271 if (nPrimary == stof(argv(i)))
272 hit_con_bind = true;
273
274 if (key_pressed)
275 {
276 if (nPrimary == K_ALT) hudShiftState |= S_ALT;
277 if (nPrimary == K_CTRL) hudShiftState |= S_CTRL;
278 if (nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
279 if (nPrimary == K_TAB) hudShiftState |= S_TAB;
280 }
281 else
282 {
283 if (nPrimary == K_ALT) hudShiftState &= ~S_ALT;
284 if (nPrimary == K_CTRL) hudShiftState &= ~S_CTRL;
285 if (nPrimary == K_SHIFT) hudShiftState &= ~S_SHIFT;
286 if (nPrimary == K_TAB) hudShiftState &= ~S_TAB;
287 }
288
289 if (nPrimary == K_TAB)
290 {
291 if (!key_pressed)
292 return true;
293 if (scoreboard_ui_enabled == 2)
294 {
296 goto uparrow_action;
297 else
298 goto downarrow_action;
299 }
300
302 {
308 }
309 else
310 {
316 }
317
319 }
320 else if (nPrimary == K_DOWNARROW)
321 {
322 if (!key_pressed)
323 return true;
324 LABEL(downarrow_action);
326 {
327 if (scoreboard_ui_enabled == 2)
328 {
329 bool scoreboard_selected_team_found = !scoreboard_selected_team;
330
331 entity curr_team = NULL;
332 for (entity tm = teams.sort_next; tm; tm = tm.sort_next)
333 {
334 if (tm.team == NUM_SPECTATOR)
335 continue;
336 curr_team = tm;
337 if (scoreboard_selected_team_found)
338 goto ok_team;
339 if (scoreboard_selected_team == tm)
340 scoreboard_selected_team_found = true;
341 }
342 LABEL(ok_team);
343 if (curr_team == scoreboard_selected_team) // loop reached the last team
344 curr_team = NULL;
345 scoreboard_selected_team = curr_team;
346 }
347 else
348 {
349 bool scoreboard_selected_player_found = !scoreboard_selected_player;
350
351 entity curr_pl = NULL;
352 for (entity pl, tm = teams.sort_next; tm; tm = tm.sort_next)
353 if (tm.team != NUM_SPECTATOR)
354 for (pl = players.sort_next; pl; pl = pl.sort_next)
355 {
356 if (pl.team != tm.team)
357 continue;
358 curr_pl = pl;
359 if (scoreboard_selected_player_found)
360 goto ok_done;
362 scoreboard_selected_player_found = true;
363 }
364 LABEL(ok_done);
365 if (curr_pl == scoreboard_selected_player) // loop reached the last player
366 curr_pl = NULL;
368 }
369 }
370 }
371 else if (nPrimary == K_UPARROW)
372 {
373 if (!key_pressed)
374 return true;
375 LABEL(uparrow_action);
377 {
378 if (scoreboard_ui_enabled == 2)
379 {
381 for (entity tm = teams.sort_next; tm; tm = tm.sort_next)
382 {
383 if (tm.team == NUM_SPECTATOR)
384 continue;
385 if (tm == scoreboard_selected_team)
386 goto ok_team2;
387 prev_team = tm;
388 }
389 LABEL(ok_team2);
391 }
392 else
393 {
394 entity prev_pl = NULL;
395 for (entity pl, tm = teams.sort_next; tm; tm = tm.sort_next)
396 if (tm.team != NUM_SPECTATOR)
397 for (pl = players.sort_next; pl; pl = pl.sort_next)
398 {
399 if (pl.team != tm.team)
400 continue;
402 goto ok_done2;
403 prev_pl = pl;
404 }
405 LABEL(ok_done2);
407 }
408 }
409 }
410 else if (nPrimary == K_RIGHTARROW)
411 {
412 if (!key_pressed)
413 return true;
416 }
417 else if (nPrimary == K_LEFTARROW)
418 {
419 if (!key_pressed)
420 return true;
423 }
424 else if (nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
425 {
426 if (!key_pressed)
427 return true;
429 {
430 if (scoreboard_ui_enabled == 2)
431 {
432 string team_name;
434 team_name = "auto";
435 else
437 localcmd(sprintf("cmd selectteam %s; cmd join\n", team_name));
439 }
441 localcmd(sprintf("spectate %d\n", scoreboard_selected_player.sv_entnum + 1));
442 }
443 }
444 else if (nPrimary == 'c' && (hudShiftState & S_CTRL))
445 {
446 if (!key_pressed)
447 return true;
449 {
451 {
452 case 0:
454 {
455 localcmd(sprintf("scoreboard_columns_set\n")); // sets the layout saved in scoreboard_columns
457 break;
458 }
459 // fallthrough
460 case 1:
461 localcmd(sprintf("scoreboard_columns_set default\n"));
463 break;
464 case 2:
465 localcmd(sprintf("scoreboard_columns_set all\n"));
467 break;
468 }
469 }
470 }
471 else if (nPrimary == 'r' && (hudShiftState & S_CTRL))
472 {
473 if (!key_pressed)
474 return true;
476 localcmd("toggle hud_panel_scoreboard_scores_per_round\n");
477 }
478 else if (nPrimary == 't' && (hudShiftState & S_CTRL))
479 {
480 if (!key_pressed)
481 return true;
484 {
485 localcmd(sprintf("commandmode tell \"%s^7\"\n", entcs_GetName(scoreboard_selected_player.sv_entnum)));
487 }
488 }
489 else if (nPrimary == 'k' && (hudShiftState & S_CTRL))
490 {
491 if (!key_pressed)
492 return true;
495 {
496 localcmd(sprintf("vcall kick \"%s^7\"\n", entcs_GetName(scoreboard_selected_player.sv_entnum)));
497 }
498 }
499 else if (hit_con_bind || nPrimary == K_PAUSE)
500 return false;
501
502 return true;
503}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float RANKINGS_RECEIVED_CNT
Definition main.qh:79
entity players
Definition main.qh:57
entity teams
Definition main.qh:58
float time
string entcs_GetName(int i)
Definition ent_cs.qh:151
const int S_SHIFT
Definition hud.qh:129
int hudShiftState
Definition hud.qh:128
const int S_ALT
Definition hud.qh:131
float autocvar__menu_alpha
Definition hud.qh:187
vector mousepos
Definition hud.qh:103
const int S_TAB
Definition hud.qh:132
const int S_CTRL
Definition hud.qh:130
float K_SHIFT
Definition keycodes.qc:22
float K_UPARROW
Definition keycodes.qc:15
float K_DOWNARROW
Definition keycodes.qc:16
float K_CTRL
Definition keycodes.qc:21
float K_RIGHTARROW
Definition keycodes.qc:18
float K_SPACE
Definition keycodes.qc:10
float K_ALT
Definition keycodes.qc:20
float K_ENTER
Definition keycodes.qc:8
float K_LEFTARROW
Definition keycodes.qc:17
float K_KP_ENTER
Definition keycodes.qc:74
float K_TAB
Definition keycodes.qc:7
float K_ESCAPE
Definition keycodes.qc:9
float K_PAUSE
Definition keycodes.qc:78
void localcmd(string command,...)
float ceil(float f)
float stof(string val,...)
float min(float f,...)
float tokenize(string s)
float max(float f,...)
#define NULL
Definition post.qh:14
bool scoreboard_ui_disabling
int rankings_cnt
int rankings_start_column
int rankings_columns
int rankings_rows
void HUD_Scoreboard_UI_Disable()
int scoreboard_selected_panel
Definition scoreboard.qh:44
int SB_PANEL_FIRST
Definition scoreboard.qh:51
entity scoreboard_selected_player
Definition scoreboard.qh:46
int scoreboard_selected_columns_layout
Definition scoreboard.qh:48
int scoreboard_ui_enabled
Definition scoreboard.qh:40
entity scoreboard_selected_team
Definition scoreboard.qh:47
int SB_PANEL_SCOREBOARD
Definition scoreboard.qh:52
int SB_PANEL_MAX
Definition scoreboard.qh:54
int SB_PANEL_RANKINGS
Definition scoreboard.qh:53
float scoreboard_selected_panel_time
Definition scoreboard.qh:45
int prev_team
string Static_Team_ColorName(int teamid)
Definition teams.qh:103
const int NUM_SPECTATOR
Definition teams.qh:23

References argv(), autocvar__menu_alpha, autocvar_scoreboard_columns, ceil(), entcs_GetName(), entity(), HUD_Scoreboard_UI_Disable(), hudShiftState, K_ALT, K_CTRL, K_DOWNARROW, K_ENTER, K_ESCAPE, K_KP_ENTER, K_LEFTARROW, K_PAUSE, K_RIGHTARROW, K_SHIFT, K_SPACE, K_TAB, K_UPARROW, LABEL, localcmd(), max(), min(), mousepos, NULL, NUM_SPECTATOR, players, prev_team, rankings_cnt, rankings_columns, RANKINGS_RECEIVED_CNT, rankings_rows, rankings_start_column, S_ALT, S_CTRL, S_SHIFT, S_TAB, SB_PANEL_FIRST, SB_PANEL_MAX, SB_PANEL_RANKINGS, SB_PANEL_SCOREBOARD, scoreboard_selected_columns_layout, scoreboard_selected_panel, scoreboard_selected_panel_time, scoreboard_selected_player, scoreboard_selected_team, scoreboard_ui_disabling, scoreboard_ui_enabled, Static_Team_ColorName(), stof(), teams, time, and tokenize().

Referenced by CSQC_InputEvent().

◆ Scoreboard_Draw()

void Scoreboard_Draw ( )

Definition at line 2401 of file scoreboard.qc.

2402{
2404 {
2405 if (!hud_draw_maximized)
2406 return;
2407
2408 // frametime checks allow to toggle the scoreboard even when the game is paused
2410 {
2411 if (scoreboard_fade_alpha == 0)
2413 if (hud_configure_menu_open == 1)
2415 float scoreboard_fadeinspeed = autocvar_hud_panel_scoreboard_fadeinspeed;
2416 if (scoreboard_fadeinspeed && frametime)
2417 scoreboard_fade_alpha = min(1, scoreboard_fade_alpha + frametime * scoreboard_fadeinspeed);
2418 else
2420
2421 static string hud_fontsize_str;
2422 if (hud_fontsize_str != autocvar_hud_fontsize)
2423 {
2424 hud_fontsize = HUD_GetFontsize("hud_fontsize");
2425 strcpy(hud_fontsize_str, autocvar_hud_fontsize);
2427 }
2428
2429 static float scoreboard_table_fieldtitle_maxwidth_prev;
2430 if (scoreboard_table_fieldtitle_maxwidth_prev != autocvar_hud_panel_scoreboard_table_fieldtitle_maxwidth)
2431 {
2432 scoreboard_table_fieldtitle_maxwidth_prev = autocvar_hud_panel_scoreboard_table_fieldtitle_maxwidth;
2436 }
2437 }
2438 else
2439 {
2440 float scoreboard_fadeoutspeed = autocvar_hud_panel_scoreboard_fadeoutspeed;
2441 if (scoreboard_fadeoutspeed && frametime)
2442 scoreboard_fade_alpha = max(0, scoreboard_fade_alpha - frametime * scoreboard_fadeoutspeed);
2443 else
2445 }
2446
2448 {
2451 return;
2452 }
2453 }
2454 else
2456
2459 else
2461
2462 if (scoreboard_fade_alpha <= 0)
2463 return;
2466
2474
2475 // don't overlap with con_notify
2478
2480 float fixed_scoreboard_width = bound(vid_conwidth * autocvar_hud_panel_scoreboard_minwidth, vid_conwidth - excess, vid_conwidth * 0.93);
2481 scoreboard_left = 0.5 * (vid_conwidth - fixed_scoreboard_width);
2482 scoreboard_right = scoreboard_left + fixed_scoreboard_width;
2484 panel_size.x = fixed_scoreboard_width;
2485
2486 // field sizes can be initialized now after panel_size.x calculation
2488 {
2489 bool compress = (sb_field_sizes_init == 2);
2490 Scoreboard_initFieldSizes(compress);
2492 }
2493
2495
2497 vector pos = panel_pos;
2498
2500 drawfill('0 0 0', eX * vid_conwidth + eY * vid_conheight, '0 0 0', 0.7 * panel_fade_alpha, DRAWFLAG_NORMAL);
2501
2502 vector sb_gameinfo_type_fontsize, sb_gameinfo_detail_fontsize;
2503
2504 // Begin of Game Info Section
2505 sb_gameinfo_type_fontsize = hud_fontsize * 2.5;
2506 sb_gameinfo_detail_fontsize = hud_fontsize * 1.3;
2507
2508 string str;
2509 if (GET_NEXTMAP() != "")
2510 {
2511 // NOTE: nextmap is drawn before title to avoid covering title in case of long map name
2512 str = strcat("^7", _("Next map:"), " ^9", GET_NEXTMAP());
2513 drawcolorcodedstring(pos + vec2(hud_fontsize.x * 0.5, sb_gameinfo_type_fontsize.y - hud_fontsize.y * 1.25),
2515 }
2516
2517 // Game Info: Gametype
2518 if (scoreboard_ui_enabled == 2)
2519 str = _("Team Selection");
2520 else if (gametype_custom_name != "")
2522 else
2525 drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_type_fontsize)), str, sb_gameinfo_type_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2527
2528 pos.y += sb_gameinfo_type_fontsize.y;
2529 // Game Info: Game Detail
2530 if (scoreboard_ui_enabled == 2)
2531 {
2533 str = sprintf(_("^7Press ^3%s^7 to join the selected team"), translate_key("SPACE"));
2534 else
2535 str = sprintf(_("^7Press ^3%s^7 to auto-select a team and join"), translate_key("SPACE"));
2536 drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2537
2538 pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3;
2539 str = sprintf(_("^7Press ^3%s ^7to select a specific team"), translate_key("TAB"));
2540 drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2541 }
2542 else
2543 {
2544 float tl = STAT(TIMELIMIT);
2545 float fl = STAT(FRAGLIMIT);
2546 float ll = STAT(LEADLIMIT);
2547 float ll_and_fl = STAT(LEADLIMIT_AND_FRAGLIMIT);
2548 str = "";
2549 if (tl > 0)
2550 str = strcat(str, "^3", count_minutes(floor(tl)));
2551 if (!gametype.m_hidelimits)
2552 {
2553 if (fl > 0)
2554 {
2555 if (tl > 0)
2556 str = strcat(str, "^7 / "); // delimiter
2557 str = strcat(str, Scoreboard_Fraglimit_Draw(fl, false));
2558 }
2559 if (ll > 0 && (ll < fl || fl <= 0))
2560 {
2561 if (tl > 0 || fl > 0)
2562 {
2563 // delimiter
2564 if (ll_and_fl && fl > 0)
2565 str = strcat(str, "^7 & ");
2566 else
2567 str = strcat(str, "^7 / ");
2568 }
2569 str = strcat(str, Scoreboard_Fraglimit_Draw(ll, true));
2570 }
2571 }
2572 drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right
2573 // map name and player count
2574 if (campaign)
2575 str = "";
2576 else
2577 str = sprintf(_("^5%d^7/^5%d ^7players"), numplayers, srv_maxplayers ? srv_maxplayers : maxclients);
2578 str = strcat("^7", _("Map:"), " ^2", mi_shortname, " ", str); // reusing "Map:" translatable string
2579 drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
2580 }
2581 // End of Game Info Section
2582
2583 pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3; // space between Game Info Section and score table
2584 if (panel.current_panel_bg != "0")
2585 pos.y += panel_bg_border;
2586
2587 // Draw the scoreboard
2589 if (scale <= 0)
2590 scale = 0.25;
2591 vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * scale;
2592
2593 entity tm;
2594 if (teamplay)
2595 {
2596 vector panel_bg_color_save = panel_bg_color;
2597 vector team_score_baseoffset;
2598 vector team_size_baseoffset;
2599 if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
2600 {
2601 // put team score to the left of scoreboard (and team size to the right)
2602 team_score_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
2603 team_size_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
2604 if (panel.current_panel_bg != "0")
2605 {
2606 team_score_baseoffset.x -= panel_bg_border;
2607 team_size_baseoffset.x += panel_bg_border;
2608 }
2609 }
2610 else
2611 {
2612 // put team score to the right of scoreboard (and team size to the left)
2613 team_score_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
2614 team_size_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
2615 if (panel.current_panel_bg != "0")
2616 {
2617 team_score_baseoffset.x += panel_bg_border;
2618 team_size_baseoffset.x -= panel_bg_border;
2619 }
2620 }
2621
2622 int team_size_total = 0;
2623 if (autocvar_hud_panel_scoreboard_team_size_position != 0) // team size not off
2624 {
2625 // calculate team size total (sum of all team sizes)
2626 for (tm = teams.sort_next; tm; tm = tm.sort_next)
2627 if (tm.team != NUM_SPECTATOR)
2628 team_size_total += tm.team_size;
2629 }
2630
2631 vector str_pos;
2632 for (tm = teams.sort_next; tm; tm = tm.sort_next)
2633 {
2634 if (tm.team == NUM_SPECTATOR)
2635 continue;
2636 if (!tm.team)
2637 continue;
2638
2640 vector rgb = Team_ColorRGB(tm.team);
2641 str = ftos(tm.(teamscores(ts_primary)));
2642 if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
2643 {
2644 // team score on the left (default)
2645 str_pos = pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
2646 }
2647 else
2648 {
2649 // team score on the right
2650 str_pos = pos + team_score_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
2651 }
2652 drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
2653
2654 // team size (if set to show on the side)
2655 if (autocvar_hud_panel_scoreboard_team_size_position != 0) // team size not off
2656 {
2657 // calculate the starting position for the whole team size info string
2658 str = sprintf("%d/%d", tm.team_size, team_size_total);
2660 // team size on the left
2661 str_pos = pos + team_size_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
2662 else
2663 // team size on the right
2664 str_pos = pos + team_size_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
2665
2666 str = sprintf("%d", tm.team_size);
2667 drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
2668 str_pos += eX * stringwidth(str, true, hud_fontsize * 1.5) + eY * hud_fontsize.y * 0.5;
2669 str = sprintf("/%d", team_size_total);
2670 drawstring(str_pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2671 }
2672
2673
2674 // secondary score, e.g. keyhunt
2675 if (ts_primary != ts_secondary)
2676 {
2677 str = ftos(tm.(teamscores(ts_secondary)));
2678 if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
2679 // left
2680 str_pos = pos + team_score_baseoffset - vec2(stringwidth(str, false, hud_fontsize), hud_fontsize.y * -1.5);
2681 else
2682 // right
2683 str_pos = pos + team_score_baseoffset + vec2(panel_size.x + hud_fontsize.x * 1.5, hud_fontsize.y * 1.5);
2684
2686 }
2690 else if (panel_bg_color_team > 0)
2692 else
2693 panel_bg_color = rgb;
2694 pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
2695 }
2696 panel_bg_color = panel_bg_color_save;
2697 }
2698 else
2699 {
2700 for (tm = teams.sort_next; tm; tm = tm.sort_next)
2701 if (tm.team != NUM_SPECTATOR)
2702 break;
2703
2704 // display it anyway
2705 pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
2706 }
2707
2708 // if the name column is too small, try to compress all other field titles
2711
2712 // draw scoreboard spectators before accuracy and item stats
2714 pos = Scoreboard_Spectators_Draw(pos);
2715
2716 // draw accuracy and item stats
2718 pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
2720 pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
2721
2722 // draw scoreboard spectators after accuracy and item stats and before rankings
2724 pos = Scoreboard_Spectators_Draw(pos);
2725
2726 if (MUTATOR_CALLHOOK(ShowRankings))
2727 {
2728 string ranktitle = M_ARGV(0, string);
2730 float conversion_factor = GetSpeedUnitFactor(autocvar_hud_speed_unit);
2732 {
2733 string name;
2735 str = "";
2736 if (race_speedaward)
2737 {
2739 str = sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward * conversion_factor, unit, name);
2740 str = strcat(str, " / ");
2741 }
2743 str = strcat(str, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest * conversion_factor, unit, name));
2745 pos.y += 1.25 * hud_fontsize.y; // line height + line spacing
2746 }
2747 pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size);
2748 }
2749 else
2750 rankings_cnt = 0;
2751
2752 // draw scoreboard spectators after rankings
2754 pos = Scoreboard_Spectators_Draw(pos);
2755
2756 pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
2757
2758 // draw scoreboard spectators after mapstats
2760 pos = Scoreboard_Spectators_Draw(pos);
2761
2762
2763 // print information about respawn status
2764 float respawn_time = STAT(RESPAWN_TIME);
2765 if (!intermission && respawn_time)
2766 {
2767 if (respawn_time < 0)
2768 {
2769 // a negative number means we are awaiting respawn, time value is still the same
2770 respawn_time *= -1; // remove mark now that we checked it
2771
2772 if (respawn_time < time) // it happens for a few frames when server is respawning the player
2773 str = ""; // draw an empty string to not change suddenly scoreboard_bottom
2774 else
2775 str = sprintf(_("^1Respawning in ^3%s^1..."),
2778 :
2780 )
2781 );
2782 }
2783 else if (time < respawn_time)
2784 str = sprintf(_("You are dead, wait ^3%s^7 before respawning"),
2787 :
2789 )
2790 );
2791 else if (time >= respawn_time)
2792 str = sprintf(_("You are dead, press ^2%s^7 to respawn"), getcommandkey(_("jump"), "+jump"));
2793
2794 pos.y += 1.2 * hud_fontsize.y;
2796 }
2797
2798 pos.y += hud_fontsize.y;
2799 if (scoreboard_fade_alpha < 1)
2801 else if (pos.y != scoreboard_bottom)
2802 {
2803 if (pos.y > scoreboard_bottom)
2804 scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - scoreboard_top));
2805 else
2806 scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - scoreboard_top));
2807 }
2808
2809 if (rankings_cnt)
2810 {
2811 if (scoreboard_fade_alpha == 1)
2812 {
2813 if (scoreboard_bottom > 0.95 * vid_conheight)
2815 else if (scoreboard_bottom + 1.25 * hud_fontsize.y < 0.95 * vid_conheight)
2817 }
2819 }
2820}
#define MUTATOR_CALLHOOK(id,...)
Definition base.qh:143
#define drawcolorcodedstring(position, text, scale, alpha, flag)
Definition draw.qh:30
#define drawstring(position, text, scale, rgb, alpha, flag)
Definition draw.qh:27
#define draw_beginBoldFont()
Definition draw.qh:4
#define drawfill(position, size, rgb, alpha, flag)
Definition draw.qh:36
#define draw_endBoldFont()
Definition draw.qh:5
float autocvar_con_notifysize
Definition chat.qh:10
float autocvar_con_notify
Definition chat.qh:9
string GetSpeedUnit(int speed_unit)
Definition main.qc:1122
float GetSpeedUnitFactor(int speed_unit)
Definition main.qc:1109
entity playerslots[255]
Definition main.qh:84
int srv_maxplayers
Definition main.qh:126
string gametype_custom_name
Definition main.qh:44
#define getcommandkey(cmd_name, command)
Definition main.qh:137
bool campaign
Definition main.qh:122
#define M_ARGV(x, type)
Definition events.qh:17
string textShortenToWidth(string theText, float maxWidth, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
Definition util.qc:1071
string translate_key(string key)
Definition util.qc:1512
string mi_shortname
Definition util.qh:126
#define count_seconds_decs(time, decs)
Definition counting.qh:55
#define count_seconds(time)
Definition counting.qh:56
#define count_minutes(time)
Definition counting.qh:47
const float DRAWFLAG_NORMAL
float maxclients
float frametime
float player_localnum
float intermission
#define stringwidth
void HUD_Panel_LoadCvars()
Definition hud.qc:215
void HUD_Scale_Enable()
Definition hud.qc:91
void HUD_Scale_Disable()
Definition hud.qc:84
float panel_fade_alpha
Definition hud.qh:421
vector panel_size
Definition hud.qh:163
float panel_fg_alpha
Definition hud.qh:169
bool hud_draw_maximized
Definition hud.qh:69
float panel_bg_border
Definition hud.qh:172
float panel_bg_color_team
Definition hud.qh:167
int autocvar_hud_speed_unit
Definition hud.qh:207
int ts_secondary
Definition hud.qh:118
vector panel_pos
Definition hud.qh:162
vector panel_bg_color
Definition hud.qh:165
int ts_primary
Definition hud.qh:118
entity panel
Definition hud.qh:147
bool autocvar__hud_configure
Definition hud_config.qh:3
float hud_configure_menu_open
Definition hud_config.qh:22
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
#define STAT(...)
Definition stats.qh:82
string MapInfo_Type_ToText(Gametype t)
Definition mapinfo.qc:661
string name
Definition menu.qh:30
float bound(float min, float value, float max)
string ftos(float f)
float floor(float f)
float scale
Definition projectile.qc:14
float race_speedaward_alltimebest
Definition racetimer.qh:32
string race_speedaward_holder
Definition racetimer.qh:31
string race_speedaward_alltimebest_holder
Definition racetimer.qh:33
float race_speedaward
Definition racetimer.qh:30
float autocvar_hud_panel_scoreboard_table_fg_alpha
Definition scoreboard.qc:71
float sbt_field_size[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:45
float autocvar_hud_panel_scoreboard_table_fieldtitle_maxwidth
Definition scoreboard.qc:73
float autocvar_hud_panel_scoreboard_bg_teams_color_team
Definition scoreboard.qc:78
float sbt_highlight_alpha_self
Definition scoreboard.qc:63
float name_field_index
Definition scoreboard.qc:55
float scoreboard_time
float autocvar_hud_panel_scoreboard_team_size_position
Definition scoreboard.qc:79
float sbt_bg_alpha
Definition scoreboard.qc:58
float sbt_highlight_alpha_eliminated
Definition scoreboard.qc:64
void Scoreboard_initFieldSizes(bool compress_more)
bool autocvar_hud_panel_scoreboard_dynamichud
Definition scoreboard.qc:95
float max_namesize
Definition scoreboard.qc:54
string autocvar_hud_fontsize
Definition scoreboard.qc:53
float autocvar_hud_panel_scoreboard_minwidth
float autocvar_hud_panel_scoreboard_spectators_position
Definition scoreboard.qc:80
bool autocvar_hud_panel_scoreboard_table_highlight
Definition scoreboard.qc:74
float autocvar_hud_panel_scoreboard_table_bg_alpha
Definition scoreboard.qc:69
float autocvar_hud_panel_scoreboard_table_highlight_alpha
Definition scoreboard.qc:75
void Scoreboard_UpdatePlayerTeams()
vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
float autocvar_hud_panel_scoreboard_respawntime_decimals
Definition scoreboard.qc:68
vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size)
float autocvar_hud_panel_scoreboard_table_bg_scale
Definition scoreboard.qc:70
float sbt_highlight_alpha
Definition scoreboard.qc:62
float sbt_fg_alpha_self
Definition scoreboard.qc:60
float autocvar_hud_panel_scoreboard_fadeoutspeed
Definition scoreboard.qc:67
bool Scoreboard_ItemStats_WouldDraw(float ypos)
float sbt_fg_alpha
Definition scoreboard.qc:59
vector Scoreboard_Spectators_Draw(vector pos)
float autocvar_hud_panel_scoreboard_table_highlight_alpha_self
Definition scoreboard.qc:76
vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
float autocvar_hud_panel_scoreboard_fadeinspeed
Definition scoreboard.qc:66
float autocvar_hud_panel_scoreboard_table_fg_alpha_self
Definition scoreboard.qc:72
string Scoreboard_Fraglimit_Draw(float limit, bool is_leadlimit)
float sbt_field_title_maxwidth
Definition scoreboard.qc:50
vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
float autocvar_hud_panel_scoreboard_table_highlight_alpha_eliminated
Definition scoreboard.qc:77
float sbt_field_title_width[MAX_SBT_FIELDS+1]
Definition scoreboard.qc:48
bool sbt_highlight
Definition scoreboard.qc:61
bool Scoreboard_AccuracyStats_WouldDraw(float ypos)
vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector rgb, vector bg_size)
float scoreboard_right
Definition scoreboard.qh:24
#define GET_NEXTMAP()
Definition scoreboard.qh:12
float scoreboard_acc_fade_alpha
Definition scoreboard.qh:18
float scoreboard_top
Definition scoreboard.qh:21
float scoreboard_left
Definition scoreboard.qh:23
bool scoreboard_active
Definition scoreboard.qh:16
float scoreboard_fade_alpha
Definition scoreboard.qh:17
int numplayers
Definition scoreboard.qh:26
float scoreboard_bottom
Definition scoreboard.qh:22
float autocvar_hud_panel_scoreboard_namesize
Definition scoreboard.qh:7
float scoreboard_itemstats_fade_alpha
Definition scoreboard.qh:19
vector
Definition self.qh:92
float respawn_time
Definition client.qh:321
ERASEABLE string ColorTranslateRGB(string s)
Definition string.qh:196
float stringwidth_colors(string s, vector theSize)
Definition string.qh:30
vector Team_ColorRGB(int teamid)
Definition teams.qh:76
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90

References autocvar__hud_configure, autocvar_con_notify, autocvar_con_notifysize, autocvar_hud_fontsize, autocvar_hud_panel_scoreboard_bg_teams_color_team, autocvar_hud_panel_scoreboard_dynamichud, autocvar_hud_panel_scoreboard_fadeinspeed, autocvar_hud_panel_scoreboard_fadeoutspeed, autocvar_hud_panel_scoreboard_minwidth, autocvar_hud_panel_scoreboard_namesize, autocvar_hud_panel_scoreboard_respawntime_decimals, autocvar_hud_panel_scoreboard_spectators_position, autocvar_hud_panel_scoreboard_table_bg_alpha, autocvar_hud_panel_scoreboard_table_bg_scale, autocvar_hud_panel_scoreboard_table_fg_alpha, autocvar_hud_panel_scoreboard_table_fg_alpha_self, autocvar_hud_panel_scoreboard_table_fieldtitle_maxwidth, autocvar_hud_panel_scoreboard_table_highlight, autocvar_hud_panel_scoreboard_table_highlight_alpha, autocvar_hud_panel_scoreboard_table_highlight_alpha_eliminated, autocvar_hud_panel_scoreboard_table_highlight_alpha_self, autocvar_hud_panel_scoreboard_team_size_position, autocvar_hud_speed_unit, bound(), campaign, ceil(), ColorTranslateRGB(), count_minutes, count_seconds, count_seconds_decs, draw_beginBoldFont, draw_endBoldFont, drawcolorcodedstring, drawfill, DRAWFLAG_NORMAL, drawstring, entity(), eX, eY, floor(), frametime, ftos(), gametype, gametype_custom_name, GET_NEXTMAP, getcommandkey, GetSpeedUnit(), GetSpeedUnitFactor(), hud_configure_menu_open, hud_draw_maximized, hud_fontsize, HUD_GetFontsize(), HUD_Panel_LoadCvars(), HUD_Scale_Disable(), HUD_Scale_Enable(), intermission, M_ARGV, MapInfo_Type_ToText(), max(), max_namesize, maxclients, mi_shortname, min(), MUTATOR_CALLHOOK, name, name_field_index, NUM_SPECTATOR, numplayers, panel, panel_bg_border, panel_bg_color, panel_bg_color_team, panel_fade_alpha, panel_fg_alpha, panel_pos, panel_size, player_localnum, playerslots, race_speedaward, race_speedaward_alltimebest, race_speedaward_alltimebest_holder, race_speedaward_holder, rankings_cnt, rankings_columns, RANKINGS_RECEIVED_CNT, rankings_rows, respawn_time, sb_field_sizes_init, sbt_bg_alpha, sbt_fg_alpha, sbt_fg_alpha_self, sbt_field_size, sbt_field_title_maxwidth, sbt_field_title_width, sbt_highlight, sbt_highlight_alpha, sbt_highlight_alpha_eliminated, sbt_highlight_alpha_self, scale, scoreboard_acc_fade_alpha, Scoreboard_AccuracyStats_Draw(), Scoreboard_AccuracyStats_WouldDraw(), scoreboard_active, scoreboard_bottom, scoreboard_fade_alpha, Scoreboard_Fraglimit_Draw(), Scoreboard_initFieldSizes(), Scoreboard_ItemStats_Draw(), scoreboard_itemstats_fade_alpha, Scoreboard_ItemStats_WouldDraw(), scoreboard_left, Scoreboard_MakeTable(), Scoreboard_MapStats_Draw(), Scoreboard_Rankings_Draw(), scoreboard_right, scoreboard_selected_team, Scoreboard_Spectators_Draw(), scoreboard_time, scoreboard_top, scoreboard_ui_enabled, Scoreboard_UpdatePlayerTeams(), srv_maxplayers, STAT, strcat(), strcpy, stringwidth, stringwidth_colors(), Team_ColorRGB(), teamplay, teams, textShortenToWidth(), time, translate_key(), ts_primary, ts_secondary, vec2, vector, vid_conheight, and vid_conwidth.

◆ Scoreboard_InitScores()

void Scoreboard_InitScores ( )

Definition at line 514 of file scoreboard.qc.

515{
518
519 int f;
520 FOREACH(Scores, !(scores_flags(it) & SFL_NOT_SORTABLE),
521 {
523 if (f == SFL_SORT_PRIO_PRIMARY)
524 ps_primary = it;
526 ps_secondary = it;
527 });
528 if (ps_secondary == NULL)
530
531 for (int i = 0; i < MAX_TEAMSCORE; ++i)
532 {
534 if (f == SFL_SORT_PRIO_PRIMARY)
535 ts_primary = i;
537 ts_secondary = i;
538 }
539 if (ts_secondary == -1)
541
543}
#define MAX_TEAMSCORE
Definition scores.qh:149
#define teamscores_flags(i)
Definition scores.qh:156
const int SFL_NOT_SORTABLE
Definition scores.qh:124
const int SFL_SORT_PRIO_MASK
Definition scores.qh:135
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit) NOTE: SFL_SORT_PRIO_SECONDARY value must be lo...
Definition scores.qh:133
const int SFL_SORT_PRIO_PRIMARY
Definition scores.qh:134
void Cmd_Scoreboard_SetFields(int argc)

References Cmd_Scoreboard_SetFields(), FOREACH, MAX_TEAMSCORE, NULL, ps_primary, ps_secondary, scores_flags, SFL_NOT_SORTABLE, SFL_SORT_PRIO_MASK, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_SECONDARY, teamscores_flags, ts_primary, and ts_secondary.

Referenced by NET_HANDLE().

◆ Scoreboard_UI_Enable()

void Scoreboard_UI_Enable ( int mode)

Definition at line 198 of file scoreboard.qc.

199{
200 if (isdemo())
201 return;
202
203 if (mode == 1)
204 {
206 return;
207
208 // release player's pressed keys as they aren't released elsewhere
209 // in particular jump needs to be released as it may open the team selection
210 // (when server detects jump has been pressed it sends the command to open the team selection)
214 }
215 else
216 {
217 if (scoreboard_ui_enabled == 1)
218 return;
221 }
225}
void Release_Common_Keys()
Definition main.qc:477
float isdemo()

References intermission, isdemo(), NULL, Release_Common_Keys(), SB_PANEL_FIRST, SB_PANEL_SCOREBOARD, scoreboard_selected_panel, scoreboard_selected_panel_time, scoreboard_selected_player, scoreboard_selected_team, scoreboard_ui_enabled, teamplay, and time.

Referenced by CSQC_InputEvent(), and CSQC_UpdateView().

◆ Scoreboard_UpdatePlayerPos()

void Scoreboard_UpdatePlayerPos ( entity pl)

Definition at line 656 of file scoreboard.qc.

657{
658 entity ent;
659 for (ent = player.sort_next; ent && Scoreboard_ComparePlayerScores(player, ent); ent = player.sort_next)
660 SORT_SWAP(player, ent);
661 for (ent = player.sort_prev; ent != players && Scoreboard_ComparePlayerScores(ent, player); ent = player.sort_prev)
662 SORT_SWAP(ent, player);
663}
float Scoreboard_ComparePlayerScores(entity left, entity right)
#define SORT_SWAP(a, b)
Swap two neighbours in a sortlist.
Definition sortlist.qh:14

References entity(), players, Scoreboard_ComparePlayerScores(), and SORT_SWAP.

Referenced by NET_HANDLE(), Playerchecker_Think(), and Scoreboard_UpdatePlayerTeams().

◆ Scoreboard_UpdatePlayerTeams()

void Scoreboard_UpdatePlayerTeams ( )

Definition at line 546 of file scoreboard.qc.

547{
548 static float update_time;
549 if (time <= update_time)
550 return;
551 update_time = time;
552
553 numplayers = 0;
554 //int num = 0;
555 for (entity tmp, pl = players.sort_next; pl; pl = pl.sort_next)
556 {
557 numplayers += pl.team != NUM_SPECTATOR;
558 //++num;
559 int Team = entcs_GetScoreTeam(pl.sv_entnum);
560 if (SetTeam(pl, Team))
561 {
562 tmp = pl.sort_prev;
564 if (tmp)
565 pl = tmp;
566 else
567 pl = players.sort_next;
568 }
569 }
570 /*
571 if (num != lastpnum)
572 print(strcat("PNUM: ", ftos(num), "\n"));
573 lastpnum = num;
574 */
575
576 // update the smallest and largest team sizes
577 if (!teamplay || !teams.sort_next)
578 ts_min = ts_max = 0;
579 else
580 {
581 ts_min = 255, ts_max = 0;
582
583 for (entity tm = teams.sort_next; tm; tm = tm.sort_next)
584 {
585 if (tm.team == NUM_SPECTATOR)
586 continue;
587
588 if (ts_min > tm.team_size)
589 ts_min = tm.team_size;
590 if (ts_max < tm.team_size)
591 ts_max = tm.team_size;
592 }
593 }
594}
bool SetTeam(entity o, int Team)
Definition main.qc:348
int entcs_GetScoreTeam(int i)
Same as entcs_GetTeam, but returns -1 for no team in teamplay.
Definition ent_cs.qh:141
void Scoreboard_UpdatePlayerPos(entity player)
int ts_min
Definition scoreboard.qh:27
int ts_max
team size
Definition scoreboard.qh:27

References entcs_GetScoreTeam(), entity(), NUM_SPECTATOR, numplayers, players, Scoreboard_UpdatePlayerPos(), SetTeam(), teamplay, teams, time, ts_max, and ts_min.

Referenced by Announcer_Duel(), HUD_InfoMessages(), HUD_Quickmenu_PlayerListEntries(), HUD_Score_Rankings(), HUD_Timer(), and Scoreboard_Draw().

◆ Scoreboard_UpdateTeamPos()

void Scoreboard_UpdateTeamPos ( entity Team)

Definition at line 702 of file scoreboard.qc.

703{
704 entity ent;
705 for (ent = Team.sort_next; ent && Scoreboard_CompareTeamScores(Team, ent); ent = Team.sort_next)
706 SORT_SWAP(Team, ent);
707 for (ent = Team.sort_prev; ent != teams && Scoreboard_CompareTeamScores(ent, Team); ent = Team.sort_prev)
708 SORT_SWAP(ent, Team);
709}
float Scoreboard_CompareTeamScores(entity left, entity right)

References entity(), Scoreboard_CompareTeamScores(), SORT_SWAP, and teams.

Referenced by NET_HANDLE().

◆ Scoreboard_WouldDraw()

bool Scoreboard_WouldDraw ( )

Definition at line 1764 of file scoreboard.qc.

1765{
1767 {
1769 {
1770 if (scoreboard_fade_alpha == 0)
1772 return false;
1773 }
1775 {
1777 return false;
1778 }
1779 return true;
1780 }
1781 else if (MUTATOR_CALLHOOK(DrawScoreboard))
1782 return false;
1783 else if (QuickMenu_IsOpened())
1784 return false;
1785 else if (HUD_Radar_Clickable())
1786 return false;
1787 else if (sb_showscores) // set by +showscores engine command
1788 return true;
1789 else if (intermission == 1)
1790 return true;
1791 else if (intermission == 2)
1792 return false;
1793 else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && !MUTATOR_CALLHOOK(DrawDeathScoreboard)
1796 {
1797 return true;
1798 }
1799 else if (scoreboard_showscores_force || MUTATOR_CALLHOOK(DrawScoreboard_Force))
1800 return true;
1801 return false;
1802}
entity active_minigame
bool HUD_MinigameMenu_IsOpened()
int spectatee_status
the -1 disables HUD panels before CSQC receives necessary data
Definition main.qh:197
float player_localentnum
float death_time
entity CSQCModel_server2csqc(int i)
Definition cl_model.qc:314
bool QuickMenu_IsOpened()
Definition quickmenu.qc:291
bool HUD_Radar_Clickable()
Definition radar.qc:26
bool scoreboard_showscores_force
Definition racetimer.qh:46
void HUD_Scoreboard_UI_Disable_Instantly()
bool autocvar_cl_deathscoreboard
Definition scoreboard.qh:4
bool sb_showscores
Definition scoreboard.qh:14
float autocvar_cl_deathscoreboard_delay
Definition scoreboard.qh:5

References active_minigame, autocvar_cl_deathscoreboard, autocvar_cl_deathscoreboard_delay, CSQCModel_server2csqc(), death_time, HUD_MinigameMenu_IsOpened(), HUD_Radar_Clickable(), HUD_Scoreboard_UI_Disable_Instantly(), intermission, MUTATOR_CALLHOOK, player_localentnum, QuickMenu_IsOpened(), sb_showscores, scoreboard_fade_alpha, scoreboard_showscores_force, scoreboard_ui_disabling, scoreboard_ui_enabled, spectatee_status, STAT, and time.

Referenced by CSQC_UpdateView().

Variable Documentation

◆ autocvar__nextmap

string autocvar__nextmap

Definition at line 9 of file scoreboard.qh.

◆ autocvar__scoreboard_team_selection

bool autocvar__scoreboard_team_selection

Definition at line 41 of file scoreboard.qh.

Referenced by CSQC_UpdateView().

◆ autocvar_cl_deathscoreboard

bool autocvar_cl_deathscoreboard

Definition at line 4 of file scoreboard.qh.

Referenced by Scoreboard_WouldDraw().

◆ autocvar_cl_deathscoreboard_delay

float autocvar_cl_deathscoreboard_delay = 1

Definition at line 5 of file scoreboard.qh.

Referenced by Scoreboard_WouldDraw().

◆ autocvar_hud_panel_scoreboard_namesize

float autocvar_hud_panel_scoreboard_namesize = 15

◆ autocvar_scoreboard_columns

string autocvar_scoreboard_columns

Definition at line 6 of file scoreboard.qh.

Referenced by Cmd_Scoreboard_SetFields(), and HUD_Scoreboard_InputEvent().

◆ ignored

bool ignored

Definition at line 29 of file scoreboard.qh.

◆ numplayers

◆ SB_PANEL_FIRST

int SB_PANEL_FIRST = 1

Definition at line 51 of file scoreboard.qh.

Referenced by HUD_Scoreboard_InputEvent(), and Scoreboard_UI_Enable().

◆ SB_PANEL_MAX

int SB_PANEL_MAX = 2

Definition at line 54 of file scoreboard.qh.

Referenced by HUD_Scoreboard_InputEvent().

◆ SB_PANEL_RANKINGS

int SB_PANEL_RANKINGS = 2

Definition at line 53 of file scoreboard.qh.

Referenced by HUD_Scoreboard_InputEvent(), and Scoreboard_Rankings_Draw().

◆ SB_PANEL_SCOREBOARD

◆ sb_showscores

bool sb_showscores

Definition at line 14 of file scoreboard.qh.

Referenced by HUD_Scoreboard_UI_Disable(), and Scoreboard_WouldDraw().

◆ scoreboard_acc_fade_alpha

float scoreboard_acc_fade_alpha

Definition at line 18 of file scoreboard.qh.

Referenced by Scoreboard_AccuracyStats_Draw(), and Scoreboard_Draw().

◆ scoreboard_active

bool scoreboard_active

◆ scoreboard_bottom

float scoreboard_bottom

Definition at line 22 of file scoreboard.qh.

Referenced by HUD_CenterPrint(), HUD_Notify(), and Scoreboard_Draw().

◆ scoreboard_fade_alpha

◆ scoreboard_itemstats_fade_alpha

float scoreboard_itemstats_fade_alpha

Definition at line 19 of file scoreboard.qh.

Referenced by Scoreboard_Draw(), and Scoreboard_ItemStats_Draw().

◆ scoreboard_left

float scoreboard_left

◆ scoreboard_right

float scoreboard_right

◆ scoreboard_selected_columns_layout

int scoreboard_selected_columns_layout

Definition at line 48 of file scoreboard.qh.

Referenced by HUD_Scoreboard_InputEvent().

◆ scoreboard_selected_panel

◆ scoreboard_selected_panel_time

float scoreboard_selected_panel_time

◆ scoreboard_selected_player

◆ scoreboard_selected_team

◆ scoreboard_top

float scoreboard_top

Definition at line 21 of file scoreboard.qh.

Referenced by HUD_Notify(), and Scoreboard_Draw().

◆ scoreboard_ui_enabled

◆ ts_max

int ts_max

◆ ts_min