Xonotic
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.

Functions

void Cmd_Scoreboard_SetFields (int argc)
 
void Scoreboard_Draw ()
 
void Scoreboard_InitScores ()
 
void Scoreboard_UpdatePlayerPos (entity pl)
 
void Scoreboard_UpdatePlayerTeams ()
 
void Scoreboard_UpdateTeamPos (entity Team)
 
bool Scoreboard_WouldDraw ()
 

Variables

bool autocvar_cl_deathscoreboard
 
string autocvar_scoreboard_columns
 
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
 
bool scoreboard_showscores
 
float scoreboard_top
 

Function Documentation

◆ Cmd_Scoreboard_SetFields()

void Cmd_Scoreboard_SetFields ( int  argc)

Definition at line 412 of file scoreboard.qc.

References argv(), autocvar_scoreboard_columns, cvar_set(), FOREACH, gametype, hud_fontsize, HUD_GetFontsize(), isGametypeInFilter(), LABEL, LOG_INFO, LOG_INFOF, MAX_SBT_FIELDS, ps_primary, ps_secondary, sbt_field, sbt_field_size, sbt_field_title, sbt_num_fields, SCOREBOARD_DEFAULT_COLUMNS, scores_flags, scores_label, SFL_ALLOW_HIDE, strcat(), strcpy, strfree, stringwidth, strlen(), strstrofs, strzone(), substring(), TC, teamplay, tokenizebyseparator, and TranslateScoresLabel().

Referenced by Scoreboard_InitScores().

413 {
414  TC(int, argc);
415  int i, slash;
416  string str, pattern;
417  bool have_name = false, have_primary = false, have_secondary = false, have_separator = false;
418  int missing;
419 
420  if(!gametype)
421  return; // do nothing, we don't know gametype and scores yet
422 
423  // sbt_fields uses strunzone on the titles!
424  if(!sbt_field_title[0])
425  for(i = 0; i < MAX_SBT_FIELDS; ++i)
426  sbt_field_title[i] = strzone("(null)");
427 
428  // TODO: re enable with gametype dependant cvars?
429  if(argc < 3) // no arguments provided
431 
432  if(argc < 3)
434 
435  if(argc == 3)
436  {
437  if(argv(2) == "default" || argv(2) == "expand_default")
438  {
439  if(argv(2) == "expand_default")
440  cvar_set("scoreboard_columns", SCOREBOARD_DEFAULT_COLUMNS);
442  }
443  else if(argv(2) == "all" || argv(2) == "ALL")
444  {
445  string s = "ping pl name |"; // scores without label (not really scores)
446  if(argv(2) == "ALL")
447  {
448  // scores without label
449  s = strcat(s, " ", "sum");
450  s = strcat(s, " ", "kdratio");
451  s = strcat(s, " ", "frags");
452  }
453  FOREACH(Scores, true, {
454  if(it != ps_primary)
455  if(it != ps_secondary)
456  if(scores_label(it) != "")
457  s = strcat(s, " ", scores_label(it));
458  });
459  if(ps_secondary != ps_primary)
460  s = strcat(s, " ", scores_label(ps_secondary));
461  s = strcat(s, " ", scores_label(ps_primary));
462  argc = tokenizebyseparator(strcat("0 1 ", s), " ");
463  }
464  }
465 
466 
467  sbt_num_fields = 0;
468 
469  hud_fontsize = HUD_GetFontsize("hud_fontsize");
470 
471  for(i = 1; i < argc - 1; ++i)
472  {
473  str = argv(i+1);
474  bool nocomplain = false;
475  if(substring(str, 0, 1) == "?")
476  {
477  nocomplain = true;
478  str = substring(str, 1, strlen(str) - 1);
479  }
480 
481  slash = strstrofs(str, "/", 0);
482  if(slash >= 0)
483  {
484  pattern = substring(str, 0, slash);
485  str = substring(str, slash + 1, strlen(str) - (slash + 1));
486 
487  if (!isGametypeInFilter(gametype, teamplay, false, pattern))
488  continue;
489  }
490 
491  str = strtolower(str);
494 
496  switch(str)
497  {
498  // fields without a label (not networked via the score system)
499  case "ping": sbt_field[sbt_num_fields] = SP_PING; break;
500  case "pl": sbt_field[sbt_num_fields] = SP_PL; break;
501  case "name": case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break;
502  case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break;
503  case "kd": case "kdr": case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break;
504  case "sum": case "diff": case "k-d": sbt_field[sbt_num_fields] = SP_SUM; break;
505  case "frags": sbt_field[sbt_num_fields] = SP_FRAGS; break;
506  default: // fields with a label
507  {
508  // map alternative labels
509  if (str == "damage") str = "dmg";
510  if (str == "damagetaken") str = "dmgtaken";
511 
512  FOREACH(Scores, true, {
513  if (str == strtolower(scores_label(it))) {
514  j = it;
515  goto found; // sorry, but otherwise fteqcc -O3 miscompiles this and warns about "unreachable code"
516  }
517  });
518 
519  // NOTE: can't check STAT(SHOWFPS) here, if checked too early it returns false anyway
520  if(!nocomplain && str != "fps") // server can disable the fps field
521  LOG_INFOF("^1Error:^7 Unknown score field: '%s'", str);
522 
523  strfree(sbt_field_title[sbt_num_fields]);
525  continue;
526 
527  LABEL(found)
529  if(j == ps_primary)
530  have_primary = true;
531  if(j == ps_secondary)
532  have_secondary = true;
533 
534  }
535  }
536  ++sbt_num_fields;
537  if(sbt_num_fields >= MAX_SBT_FIELDS)
538  break;
539  }
540 
542  have_primary = true;
543  if(scores_flags(ps_secondary) & SFL_ALLOW_HIDE)
544  have_secondary = true;
545  if(ps_primary == ps_secondary)
546  have_secondary = true;
547  missing = (!have_primary) + (!have_secondary) + (!have_separator) + (!have_name);
548 
549  if(sbt_num_fields + missing < MAX_SBT_FIELDS)
550  {
551  if(!have_name)
552  {
553  strfree(sbt_field_title[sbt_num_fields]);
554  for(i = sbt_num_fields; i > 0; --i)
555  {
557  sbt_field_size[i] = sbt_field_size[i-1];
558  sbt_field[i] = sbt_field[i-1];
559  }
561  sbt_field[0] = SP_NAME;
562  ++sbt_num_fields;
563  LOG_INFO("fixed missing field 'name'");
564 
565  if(!have_separator)
566  {
567  strfree(sbt_field_title[sbt_num_fields]);
568  for(i = sbt_num_fields; i > 1; --i)
569  {
571  sbt_field_size[i] = sbt_field_size[i-1];
572  sbt_field[i] = sbt_field[i-1];
573  }
574  sbt_field_title[1] = strzone("|");
575  sbt_field[1] = SP_SEPARATOR;
576  sbt_field_size[1] = stringwidth("|", false, hud_fontsize);
577  ++sbt_num_fields;
578  LOG_INFO("fixed missing field '|'");
579  }
580  }
581  else if(!have_separator)
582  {
583  strcpy(sbt_field_title[sbt_num_fields], "|");
585  sbt_field[sbt_num_fields] = SP_SEPARATOR;
586  ++sbt_num_fields;
587  LOG_INFO("fixed missing field '|'");
588  }
589  if(!have_secondary)
590  {
594  ++sbt_num_fields;
595  LOG_INFOF("fixed missing field '%s'", scores_label(ps_secondary));
596  }
597  if(!have_primary)
598  {
602  ++sbt_num_fields;
603  LOG_INFOF("fixed missing field '%s'", scores_label(ps_primary));
604  }
605  }
606 
607  sbt_field[sbt_num_fields] = SP_END;
608 }
PlayerScoreField sbt_field[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:43
#define stringwidth
Definition: csprogsdefs.qh:29
string TranslateScoresLabel(string label)
Definition: scoreboard.qc:168
const int MAX_SBT_FIELDS
Definition: scoreboard.qc:41
string sbt_field_title[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:45
#define strcpy(this, s)
Definition: string.qh:49
#define SCOREBOARD_DEFAULT_COLUMNS
Definition: scoreboard.qc:394
#define LOG_INFOF(...)
Definition: log.qh:71
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector HUD_GetFontsize(string cvarname)
Definition: hud.qc:111
PlayerScoreField ps_secondary
Definition: hud.qh:116
#define LOG_INFO(...)
Definition: log.qh:70
float isGametypeInFilter(Gametype gt, float tp, float ts, string pattern)
Definition: util.qc:972
entity gametype
Definition: main.qh:30
#define TC(T, sym)
Definition: _all.inc:82
#define strstrofs
Definition: dpextensions.qh:42
float teamplay
Definition: progsdefs.qc:31
#define scores_flags(this)
Definition: scores.qh:140
float sbt_field_size[MAX_SBT_FIELDS+1]
Definition: scoreboard.qc:44
int sbt_num_fields
Definition: scoreboard.qc:46
#define scores_label(this)
Definition: scores.qh:139
#define tokenizebyseparator
Definition: dpextensions.qh:21
#define LABEL(id)
Definition: compiler.qh:36
PlayerScoreField ps_primary
Definition: hud.qh:116
vector hud_fontsize
Definition: main.qh:63
#define strfree(this)
Definition: string.qh:56
string autocvar_scoreboard_columns
Definition: scoreboard.qh:5
#define FOREACH(list, cond, body)
Definition: iter.qh:19
entity PlayerScoreField
Definition: scores.qh:133
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:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Scoreboard_Draw()

void Scoreboard_Draw ( )

Definition at line 1774 of file scoreboard.qc.

References autocvar__hud_configure, autocvar_con_notify, autocvar_con_notifysize, autocvar_hud_fontsize, 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_table_bg_alpha, autocvar_hud_panel_scoreboard_table_fg_alpha, autocvar_hud_panel_scoreboard_table_fg_alpha_self, 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, bound(), draw_beginBoldFont, draw_endBoldFont, drawcolorcodedstring(), DRAWFLAG_NORMAL, entity(), frametime, gametype, hud_configure_menu_open, hud_draw_maximized, hud_fontsize, hud_fontsize_str, HUD_GetFontsize(), HUD_Panel_LoadCvars(), HUD_Scale_Disable(), HUD_Scale_Enable(), MapInfo_Type_ToText(), max(), max_namesize, min(), panel_fade_alpha, panel_fg_alpha, panel_pos, panel_size, sbt_bg_alpha, sbt_fg_alpha, sbt_fg_alpha_self, sbt_highlight, sbt_highlight_alpha, sbt_highlight_alpha_eliminated, sbt_highlight_alpha_self, scoreboard_acc_fade_alpha, scoreboard_active, scoreboard_fade_alpha, Scoreboard_initFieldSizes(), scoreboard_itemstats_fade_alpha, scoreboard_left, scoreboard_right, scoreboard_time, scoreboard_top, Scoreboard_UpdatePlayerTeams(), strcat(), strcpy, stringwidth, time, vector(), and vid_conwidth.

1775 {
1777  {
1778  if(!hud_draw_maximized) return;
1779 
1780  // frametime checks allow to toggle the scoreboard even when the game is paused
1781  if(scoreboard_active) {
1782  if (scoreboard_fade_alpha == 0)
1784  if(hud_configure_menu_open == 1)
1786  float scoreboard_fadeinspeed = autocvar_hud_panel_scoreboard_fadeinspeed;
1787  if (scoreboard_fadeinspeed && frametime)
1788  scoreboard_fade_alpha = min(1, scoreboard_fade_alpha + frametime * scoreboard_fadeinspeed);
1789  else
1792  {
1793  hud_fontsize = HUD_GetFontsize("hud_fontsize");
1796  }
1797  }
1798  else {
1799  float scoreboard_fadeoutspeed = autocvar_hud_panel_scoreboard_fadeoutspeed;
1800  if (scoreboard_fadeoutspeed && frametime)
1801  scoreboard_fade_alpha = max(0, scoreboard_fade_alpha - frametime * scoreboard_fadeoutspeed);
1802  else
1804  }
1805 
1806  if (!scoreboard_fade_alpha)
1807  {
1810  return;
1811  }
1812  }
1813  else
1815 
1817  HUD_Scale_Enable();
1818  else
1820 
1821  if(scoreboard_fade_alpha <= 0)
1822  return;
1825 
1833 
1834  // don't overlap with con_notify
1837 
1839  float fixed_scoreboard_width = bound(vid_conwidth * autocvar_hud_panel_scoreboard_minwidth, vid_conwidth - excess, vid_conwidth * 0.93);
1840  scoreboard_left = 0.5 * (vid_conwidth - fixed_scoreboard_width);
1841  scoreboard_right = scoreboard_left + fixed_scoreboard_width;
1843  panel_size.x = fixed_scoreboard_width;
1844 
1846 
1848  vector pos = panel_pos;
1849  entity tm;
1850  string str;
1851  vector str_pos;
1852 
1853  vector sb_gameinfo_type_fontsize, sb_gameinfo_detail_fontsize;
1854 
1855  // Begin of Game Info Section
1856  sb_gameinfo_type_fontsize = hud_fontsize * 2.5;
1857  sb_gameinfo_detail_fontsize = hud_fontsize * 1.3;
1858 
1859  // Game Info: Game Type
1862  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);
1863  draw_endBoldFont();
1864 
1865  // Game Info: Game Detail
1866  float tl = STAT(TIMELIMIT);
1867  float fl = STAT(FRAGLIMIT);
1868  float ll = STAT(LEADLIMIT);
1869  float ll_and_fl = STAT(LEADLIMIT_AND_FRAGLIMIT);
1870  str = "";
1871  if(tl > 0)
1872  str = strcat(str, sprintf(_("^3%1.0f minutes"), tl));
1873  if(!gametype.m_hidelimits)
1874  {
1875  if(fl > 0)
1876  {
1877  if(tl > 0)
1878  str = strcat(str, "^7 / "); // delimiter
1879  if(teamplay)
1880  {
1881  str = strcat(str, sprintf(_("^5%s %s"), ScoreString(teamscores_flags(ts_primary), fl),
1882  (teamscores_label(ts_primary) == "score") ? CTX(_("SCO^points")) :
1883  (teamscores_label(ts_primary) == "fastest") ? "" :
1885  }
1886  else
1887  {
1888  str = strcat(str, sprintf(_("^5%s %s"), ScoreString(scores_flags(ps_primary), fl),
1889  (scores_label(ps_primary) == "score") ? CTX(_("SCO^points")) :
1890  (scores_label(ps_primary) == "fastest") ? "" :
1892  }
1893  }
1894  if(ll > 0)
1895  {
1896  if(tl > 0 || fl > 0)
1897  {
1898  // delimiter
1899  if (ll_and_fl && fl > 0)
1900  str = strcat(str, "^7 & ");
1901  else
1902  str = strcat(str, "^7 / ");
1903  }
1904 
1905  if(teamplay)
1906  {
1907  str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(teamscores_flags(ts_primary), ll),
1908  (teamscores_label(ts_primary) == "score") ? CTX(_("SCO^points")) :
1909  (teamscores_label(ts_primary) == "fastest") ? "" :
1911  }
1912  else
1913  {
1914  str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(scores_flags(ps_primary), ll),
1915  (scores_label(ps_primary) == "score") ? CTX(_("SCO^points")) :
1916  (scores_label(ps_primary) == "fastest") ? "" :
1918  }
1919  }
1920  }
1921 
1922  pos.y += sb_gameinfo_type_fontsize.y;
1923  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
1924  // map name
1925  str = sprintf(_("^7Map: ^2%s"), shortmapname);
1926  drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
1927  // End of Game Info Section
1928 
1929  pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3; // space between Game Info Section and score table
1930  if(panel.current_panel_bg != "0")
1931  pos.y += panel_bg_border;
1932 
1933  // Draw the scoreboard
1935  if(scale <= 0)
1936  scale = 0.25;
1937  vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * scale;
1938 
1939  if(teamplay)
1940  {
1941  vector panel_bg_color_save = panel_bg_color;
1942  vector team_score_baseoffset;
1943  vector team_size_baseoffset;
1944  if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
1945  {
1946  // put team score to the left of scoreboard (and team size to the right)
1947  team_score_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
1948  team_size_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
1949  if(panel.current_panel_bg != "0")
1950  {
1951  team_score_baseoffset.x -= panel_bg_border;
1952  team_size_baseoffset.x += panel_bg_border;
1953  }
1954  }
1955  else
1956  {
1957  // put team score to the right of scoreboard (and team size to the left)
1958  team_score_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
1959  team_size_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
1960  if(panel.current_panel_bg != "0")
1961  {
1962  team_score_baseoffset.x += panel_bg_border;
1963  team_size_baseoffset.x -= panel_bg_border;
1964  }
1965  }
1966 
1967  int team_size_total = 0;
1968  if (autocvar_hud_panel_scoreboard_team_size_position != 0) // team size not off
1969  {
1970  // calculate team size total (sum of all team sizes)
1971  for(tm = teams.sort_next; tm; tm = tm.sort_next)
1972  if(tm.team != NUM_SPECTATOR)
1973  team_size_total += tm.team_size;
1974  }
1975 
1976  for(tm = teams.sort_next; tm; tm = tm.sort_next)
1977  {
1978  if(tm.team == NUM_SPECTATOR)
1979  continue;
1980  if(!tm.team)
1981  continue;
1982 
1984  vector rgb = Team_ColorRGB(tm.team);
1985  str = ftos(tm.(teamscores(ts_primary)));
1986  if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
1987  {
1988  // team score on the left (default)
1989  str_pos = pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
1990  }
1991  else
1992  {
1993  // team score on the right
1994  str_pos = pos + team_score_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
1995  }
1996  drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
1997 
1998  // team size (if set to show on the side)
1999  if (autocvar_hud_panel_scoreboard_team_size_position != 0) // team size not off
2000  {
2001  // calculate the starting position for the whole team size info string
2002  str = sprintf("%d/%d", tm.team_size, team_size_total);
2004  {
2005  // team size on the left
2006  str_pos = pos + team_size_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
2007  }
2008  else
2009  {
2010  // team size on the right
2011  str_pos = pos + team_size_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
2012  }
2013  str = sprintf("%d", tm.team_size);
2014  drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
2015  str_pos += eX * stringwidth(str, true, hud_fontsize * 1.5) + eY * hud_fontsize.y * .5;
2016  str = sprintf("/%d", team_size_total);
2017  drawstring(str_pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
2018  }
2019 
2020 
2021  // secondary score, e.g. keyhunt
2022  if(ts_primary != ts_secondary)
2023  {
2024  str = ftos(tm.(teamscores(ts_secondary)));
2025  if (autocvar_hud_panel_scoreboard_team_size_position != 1) // team size not on left
2026  {
2027  // left
2028  str_pos = pos + team_score_baseoffset - vec2(stringwidth(str, false, hud_fontsize), hud_fontsize.y * -1.5);
2029  }
2030  else
2031  {
2032  // right
2033  str_pos = pos + team_score_baseoffset + vec2(panel_size.x + hud_fontsize.x * 1.5, hud_fontsize.y * 1.5);
2034  }
2035 
2036  drawstring(str_pos, str, hud_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
2037  }
2038  draw_endBoldFont();
2041  else if(panel_bg_color_team > 0)
2043  else
2044  panel_bg_color = rgb;
2045  pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
2046  }
2047  panel_bg_color = panel_bg_color_save;
2048  }
2049  else
2050  {
2051  for(tm = teams.sort_next; tm; tm = tm.sort_next)
2052  if(tm.team != NUM_SPECTATOR)
2053  break;
2054 
2055  // display it anyway
2056  pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
2057  }
2058 
2059  // draw scoreboard spectators before accuracy and item stats
2061  pos = Scoreboard_Spectators_Draw(pos);
2062  }
2063 
2064  // draw accuracy and item stats
2066  pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
2067  if (Scoreboard_ItemStats_WouldDraw(pos.y))
2068  pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
2069 
2070  // draw scoreboard spectators after accuracy and item stats and before rankings
2072  pos = Scoreboard_Spectators_Draw(pos);
2073  }
2074 
2075  if(MUTATOR_CALLHOOK(ShowRankings)) {
2076  string ranktitle = M_ARGV(0, string);
2078  if(race_speedaward) {
2079  drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2080  pos.y += 1.25 * hud_fontsize.y;
2081  }
2083  drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2084  pos.y += 1.25 * hud_fontsize.y;
2085  }
2087  pos.y += 0.25 * hud_fontsize.y;
2088  pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size);
2089  }
2090  else
2091  rankings_cnt = 0;
2092 
2093  // draw scoreboard spectators after rankings
2095  pos = Scoreboard_Spectators_Draw(pos);
2096  }
2097 
2098  pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
2099 
2100  // draw scoreboard spectators after mapstats
2102  pos = Scoreboard_Spectators_Draw(pos);
2103  }
2104 
2105 
2106  // print information about respawn status
2107  float respawn_time = STAT(RESPAWN_TIME);
2108  if(!intermission)
2109  if(respawn_time)
2110  {
2111  if(respawn_time < 0)
2112  {
2113  // a negative number means we are awaiting respawn, time value is still the same
2114  respawn_time *= -1; // remove mark now that we checked it
2115 
2116  if(respawn_time < time) // it happens for a few frames when server is respawning the player
2117  str = ""; // draw an empty string to not change suddenly scoreboard_bottom
2118  else
2119  str = sprintf(_("^1Respawning in ^3%s^1..."),
2122  :
2123  count_seconds(ceil(respawn_time - time))
2124  )
2125  );
2126  }
2127  else if(time < respawn_time)
2128  {
2129  str = sprintf(_("You are dead, wait ^3%s^7 before respawning"),
2132  :
2133  count_seconds(ceil(respawn_time - time))
2134  )
2135  );
2136  }
2137  else if(time >= respawn_time)
2138  str = sprintf(_("You are dead, press ^2%s^7 to respawn"), getcommandkey("jump", "+jump"));
2139 
2140  pos.y += 1.2 * hud_fontsize.y;
2141  drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, hud_fontsize)), str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
2142  }
2143 
2144  pos.y += hud_fontsize.y;
2145  if (scoreboard_fade_alpha < 1)
2147  else if (pos.y != scoreboard_bottom)
2148  {
2149  if (pos.y > scoreboard_bottom)
2150  scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - scoreboard_top));
2151  else
2152  scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - scoreboard_top));
2153  }
2154 
2155  if (rankings_cnt)
2156  {
2157  if (scoreboard_fade_alpha == 1)
2158  {
2159  if (scoreboard_bottom > 0.95 * vid_conheight)
2160  rankings_rows = max(1, rankings_rows - 1);
2161  else if (scoreboard_bottom + 1.25 * hud_fontsize.y < 0.95 * vid_conheight)
2163  }
2165  }
2166 }
float vid_conheight
float autocvar_hud_panel_scoreboard_spectators_position
Definition: scoreboard.qc:85
float panel_bg_border
Definition: hud.qh:169
string shortmapname
Definition: main.qh:172
float scoreboard_left
Definition: scoreboard.qh:16
#define draw_endBoldFont()
Definition: draw.qh:5
int ts_secondary
Definition: hud.qh:117
float panel_fg_alpha
Definition: hud.qh:166
float autocvar_hud_panel_scoreboard_table_bg_scale
Definition: scoreboard.qc:75
const int NUM_SPECTATOR
Definition: teams.qh:23
float panel_bg_color_team
Definition: hud.qh:164
vector Scoreboard_Spectators_Draw(vector pos)
Definition: scoreboard.qc:1744
vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
Definition: scoreboard.qc:1212
const vector eY
Definition: vector.qh:45
float sbt_fg_alpha
Definition: scoreboard.qc:53
bool autocvar__hud_configure
Definition: hud_config.qh:3
vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size)
Definition: scoreboard.qc:1493
bool Scoreboard_ItemStats_WouldDraw(float ypos)
Definition: scoreboard.qc:1709
float respawn_time
Definition: client.qh:325
vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
Definition: scoreboard.qc:1096
vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector rgb, vector bg_size)
Definition: scoreboard.qc:1565
#define stringwidth
Definition: csprogsdefs.qh:29
#define draw_beginBoldFont()
Definition: draw.qh:4
float panel_fade_alpha
Definition: hud.qh:410
vector Team_ColorRGB(int teamid)
Definition: teams.qh:76
float autocvar_hud_panel_scoreboard_table_fg_alpha
Definition: scoreboard.qc:76
float sbt_highlight_alpha_self
Definition: scoreboard.qc:57
float autocvar_hud_panel_scoreboard_fadeinspeed
Definition: scoreboard.qc:71
bool scoreboard_active
Definition: scoreboard.qh:9
vector panel_size
Definition: hud.qh:160
string TranslateScoresLabel(string label)
Definition: scoreboard.qc:168
entity() spawn
bool hud_draw_maximized
Definition: hud.qh:68
#define getcommandkey(cmd_name, command)
Definition: main.qh:108
float intermission
Definition: csprogsdefs.qc:148
float autocvar_hud_panel_scoreboard_table_bg_alpha
Definition: scoreboard.qc:74
string MapInfo_Type_ToText(Gametype t)
Definition: mapinfo.qc:621
void HUD_Scale_Disable()
Definition: hud.qc:83
float autocvar_hud_panel_scoreboard_namesize
Definition: scoreboard.qc:83
float autocvar_con_notify
Definition: chat.qh:9
bool autocvar_hud_panel_scoreboard_dynamichud
Definition: scoreboard.qc:100
entity playerslots[255]
Definition: main.qh:70
int rankings_rows
Definition: scoreboard.qc:1562
float vid_conwidth
float autocvar_hud_panel_scoreboard_table_highlight_alpha_self
Definition: scoreboard.qc:80
float sbt_highlight_alpha
Definition: scoreboard.qc:56
int rankings_cnt
Definition: scoreboard.qc:1564
float autocvar_hud_panel_scoreboard_respawntime_decimals
Definition: scoreboard.qc:73
bool Scoreboard_AccuracyStats_WouldDraw(float ypos)
Definition: scoreboard.qc:1677
#define strcpy(this, s)
Definition: string.qh:49
entity teams
Definition: main.qh:44
#define teamscores_label(i)
Definition: scores.qh:147
string hud_fontsize_str
Definition: scoreboard.qc:49
vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
Definition: scoreboard.qc:1383
string race_speedaward_alltimebest_holder
Definition: racetimer.qh:27
float autocvar_hud_panel_scoreboard_table_highlight_alpha
Definition: scoreboard.qc:79
void HUD_Scale_Enable()
Definition: hud.qc:90
string autocvar_hud_fontsize
Definition: scoreboard.qc:48
float autocvar_hud_panel_scoreboard_bg_teams_color_team
Definition: scoreboard.qc:82
float RANKINGS_RECEIVED_CNT
Definition: main.qh:65
bool sbt_highlight
Definition: scoreboard.qc:55
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector HUD_GetFontsize(string cvarname)
Definition: hud.qc:111
ERASEABLE string ColorTranslateRGB(string s)
Definition: string.qh:177
float scoreboard_right
Definition: scoreboard.qh:17
float autocvar_hud_panel_scoreboard_table_highlight_alpha_eliminated
Definition: scoreboard.qc:81
float frametime
Definition: csprogsdefs.qc:17
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
entity gametype
Definition: main.qh:30
float autocvar_hud_panel_scoreboard_minwidth
Definition: scoreboard.qc:106
entity panel
Definition: hud.qh:144
float sbt_highlight_alpha_eliminated
Definition: scoreboard.qc:58
vector panel_pos
Definition: hud.qh:159
int autocvar_hud_panel_physics_speed_unit
Definition: physics.qh:17
float autocvar_hud_panel_scoreboard_team_size_position
Definition: scoreboard.qc:84
float race_speedaward
Definition: racetimer.qh:24
float teamplay
Definition: progsdefs.qc:31
#define count_seconds_decs(time, decs)
Definition: counting.qh:55
#define M_ARGV(x, type)
Definition: events.qh:17
#define scores_flags(this)
Definition: scores.qh:140
float scoreboard_time
Definition: scoreboard.qc:1675
float scale
Definition: projectile.qc:14
vector(float skel, float bonenum) _skel_get_boneabs_hidden
int rankings_columns
Definition: scoreboard.qc:1563
#define count_seconds(time)
Definition: counting.qh:56
float sbt_bg_alpha
Definition: scoreboard.qc:52
#define scores_label(this)
Definition: scores.qh:139
const vector eX
Definition: vector.qh:44
float autocvar_hud_panel_scoreboard_table_fg_alpha_self
Definition: scoreboard.qc:77
float sbt_fg_alpha_self
Definition: scoreboard.qc:54
void Scoreboard_initFieldSizes()
Definition: scoreboard.qc:834
float scoreboard_itemstats_fade_alpha
Definition: scoreboard.qh:12
string GetSpeedUnit(int speed_unit)
Definition: main.qc:1076
float scoreboard_acc_fade_alpha
Definition: scoreboard.qh:11
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
#define vec2(...)
Definition: vector.qh:90
PlayerScoreField ps_primary
Definition: hud.qh:116
float max_namesize
Definition: scoreboard.qc:50
vector hud_fontsize
Definition: main.qh:63
float hud_configure_menu_open
Definition: hud_config.qh:21
void Scoreboard_UpdatePlayerTeams()
Definition: scoreboard.qc:210
ERASEABLE string CTX(string s)
Definition: i18n.qh:45
float autocvar_con_notifysize
Definition: chat.qh:10
#define teamscores_flags(i)
Definition: scores.qh:149
float scoreboard_bottom
Definition: scoreboard.qh:15
float autocvar_hud_panel_scoreboard_fadeoutspeed
Definition: scoreboard.qc:72
bool autocvar_hud_panel_scoreboard_table_highlight
Definition: scoreboard.qc:78
float time
Definition: csprogsdefs.qc:16
int ts_primary
Definition: hud.qh:117
float player_localnum
Definition: csprogsdefs.qc:20
float scoreboard_top
Definition: scoreboard.qh:14
float scoreboard_fade_alpha
Definition: scoreboard.qh:10
float race_speedaward_alltimebest
Definition: racetimer.qh:26
void HUD_Panel_LoadCvars()
Definition: hud.qc:216
string race_speedaward_holder
Definition: racetimer.qh:25
vector panel_bg_color
Definition: hud.qh:162
+ Here is the call graph for this function:

◆ Scoreboard_InitScores()

void Scoreboard_InitScores ( )

Definition at line 172 of file scoreboard.qc.

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

Referenced by NET_HANDLE().

173 {
174  int i, f;
175 
177  ts_primary = ts_secondary = -1;
178  FOREACH(Scores, true, {
179  f = (scores_flags(it) & SFL_SORT_PRIO_MASK);
180  if(f == SFL_SORT_PRIO_PRIMARY)
181  ps_primary = it;
182  if(f == SFL_SORT_PRIO_SECONDARY)
183  ps_secondary = it;
184  if(ps_primary == it || ps_secondary == it)
185  continue;
186  if (scores_label(it) == "kills") sb_extra_sorting_field[0] = it;
187  if (scores_label(it) == "deaths") sb_extra_sorting_field[1] = it;
188  if (scores_label(it) == "suicides") sb_extra_sorting_field[2] = it;
189  if (scores_label(it) == "dmg") sb_extra_sorting_field[3] = it;
190  if (scores_label(it) == "dmgtaken") sb_extra_sorting_field[4] = it;
191  });
192  if(ps_secondary == NULL)
194 
195  for(i = 0; i < MAX_TEAMSCORE; ++i)
196  {
198  if(f == SFL_SORT_PRIO_PRIMARY)
199  ts_primary = i;
200  if(f == SFL_SORT_PRIO_SECONDARY)
201  ts_secondary = i;
202  }
203  if(ts_secondary == -1)
205 
207 }
int ts_secondary
Definition: hud.qh:117
const int SFL_SORT_PRIO_MASK
Definition: scores.qh:128
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit)
Definition: scores.qh:126
const int SFL_SORT_PRIO_PRIMARY
Definition: scores.qh:127
PlayerScoreField sb_extra_sorting_field[SB_EXTRA_SORTING_FIELDS]
Definition: scoreboard.qc:171
#define MAX_TEAMSCORE
Definition: scores.qh:142
PlayerScoreField ps_secondary
Definition: hud.qh:116
#define NULL
Definition: post.qh:17
#define scores_flags(this)
Definition: scores.qh:140
#define scores_label(this)
Definition: scores.qh:139
PlayerScoreField ps_primary
Definition: hud.qh:116
#define teamscores_flags(i)
Definition: scores.qh:149
int ts_primary
Definition: hud.qh:117
#define FOREACH(list, cond, body)
Definition: iter.qh:19
void Cmd_Scoreboard_SetFields(int argc)
Definition: scoreboard.qc:412
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Scoreboard_UpdatePlayerPos()

void Scoreboard_UpdatePlayerPos ( entity  pl)

Definition at line 298 of file scoreboard.qc.

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

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

299 {
300  entity ent;
301  for(ent = player.sort_next; ent && Scoreboard_ComparePlayerScores(player, ent); ent = player.sort_next)
302  {
303  SORT_SWAP(player, ent);
304  }
305  for(ent = player.sort_prev; ent != players && Scoreboard_ComparePlayerScores(ent, player); ent = player.sort_prev)
306  {
307  SORT_SWAP(ent, player);
308  }
309 }
entity() spawn
float Scoreboard_ComparePlayerScores(entity left, entity right)
Definition: scoreboard.qc:252
#define SORT_SWAP(a, b)
Swap two neighbours in a sortlist.
Definition: sortlist.qh:14
entity players
Definition: main.qh:43
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Scoreboard_UpdatePlayerTeams()

void Scoreboard_UpdatePlayerTeams ( )

Definition at line 210 of file scoreboard.qc.

References entity(), players, Scoreboard_UpdatePlayerPos(), and SetTeam().

Referenced by Scoreboard_Draw().

211 {
212  entity pl, tmp;
213  //int num = 0;
214  for(pl = players.sort_next; pl; pl = pl.sort_next)
215  {
216  //num += 1;
217  int Team = entcs_GetScoreTeam(pl.sv_entnum);
218  if(SetTeam(pl, Team))
219  {
220  tmp = pl.sort_prev;
222  if(tmp)
223  pl = tmp;
224  else
225  pl = players.sort_next;
226  }
227  }
228  /*
229  if(num != lastpnum)
230  print(strcat("PNUM: ", ftos(num), "\n"));
231  lastpnum = num;
232  */
233 }
entity() spawn
void Scoreboard_UpdatePlayerPos(entity player)
Definition: scoreboard.qc:298
entity players
Definition: main.qh:43
bool SetTeam(entity o, int Team)
Definition: main.qc:319
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Scoreboard_UpdateTeamPos()

void Scoreboard_UpdateTeamPos ( entity  Team)

Definition at line 344 of file scoreboard.qc.

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

Referenced by NET_HANDLE().

345 {
346  entity ent;
347  for(ent = Team.sort_next; ent && Scoreboard_CompareTeamScores(Team, ent); ent = Team.sort_next)
348  {
349  SORT_SWAP(Team, ent);
350  }
351  for(ent = Team.sort_prev; ent != teams && Scoreboard_CompareTeamScores(ent, Team); ent = Team.sort_prev)
352  {
353  SORT_SWAP(ent, Team);
354  }
355 }
entity() spawn
float Scoreboard_CompareTeamScores(entity left, entity right)
Definition: scoreboard.qc:311
entity teams
Definition: main.qh:44
#define SORT_SWAP(a, b)
Swap two neighbours in a sortlist.
Definition: sortlist.qh:14
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Scoreboard_WouldDraw()

bool Scoreboard_WouldDraw ( )

Definition at line 1187 of file scoreboard.qc.

References active_minigame, autocvar_cl_deathscoreboard, HUD_MinigameMenu_IsOpened(), HUD_Radar_Clickable(), intermission, MUTATOR_CALLHOOK, QuickMenu_IsOpened(), scoreboard_showscores, scoreboard_showscores_force, and spectatee_status.

Referenced by CSQC_UpdateView().

1188 {
1189  if (MUTATOR_CALLHOOK(DrawScoreboard))
1190  return false;
1191  else if (QuickMenu_IsOpened())
1192  return false;
1193  else if (HUD_Radar_Clickable())
1194  return false;
1195  else if (scoreboard_showscores)
1196  return true;
1197  else if (intermission == 1)
1198  return true;
1199  else if (intermission == 2)
1200  return false;
1201  else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && !MUTATOR_CALLHOOK(DrawDeathScoreboard)
1203  {
1204  return true;
1205  }
1206  else if (scoreboard_showscores_force || MUTATOR_CALLHOOK(DrawScoreboard_Force))
1207  return true;
1208  return false;
1209 }
bool HUD_MinigameMenu_IsOpened()
bool scoreboard_showscores
Definition: scoreboard.qh:7
float intermission
Definition: csprogsdefs.qc:148
bool autocvar_cl_deathscoreboard
Definition: scoreboard.qh:4
float scoreboard_showscores_force
Definition: racetimer.qh:40
bool HUD_Radar_Clickable()
Definition: radar.qc:25
entity active_minigame
Definition: cl_minigames.qh:85
float spectatee_status
Definition: main.qh:166
bool QuickMenu_IsOpened()
Definition: quickmenu.qc:244
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_cl_deathscoreboard

bool autocvar_cl_deathscoreboard

Definition at line 4 of file scoreboard.qh.

Referenced by Scoreboard_WouldDraw().

◆ autocvar_scoreboard_columns

string autocvar_scoreboard_columns

Definition at line 5 of file scoreboard.qh.

Referenced by Cmd_Scoreboard_SetFields().

◆ scoreboard_acc_fade_alpha

float scoreboard_acc_fade_alpha

Definition at line 11 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 15 of file scoreboard.qh.

Referenced by HUD_Notify().

◆ scoreboard_fade_alpha

◆ scoreboard_itemstats_fade_alpha

float scoreboard_itemstats_fade_alpha

Definition at line 12 of file scoreboard.qh.

Referenced by Scoreboard_Draw(), and Scoreboard_ItemStats_Draw().

◆ scoreboard_left

float scoreboard_left

Definition at line 16 of file scoreboard.qh.

Referenced by HUD_Notify(), and Scoreboard_Draw().

◆ scoreboard_right

float scoreboard_right

Definition at line 17 of file scoreboard.qh.

Referenced by HUD_Notify(), and Scoreboard_Draw().

◆ scoreboard_showscores

bool scoreboard_showscores

Definition at line 7 of file scoreboard.qh.

Referenced by Scoreboard_WouldDraw().

◆ scoreboard_top

float scoreboard_top

Definition at line 14 of file scoreboard.qh.

Referenced by HUD_Notify(), and Scoreboard_Draw().