]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Scoreboard: allow showing player id next to player name
authorterencehill <piuntn@gmail.com>
Sat, 9 Jan 2021 13:48:25 +0000 (14:48 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 9 Jan 2021 14:46:30 +0000 (15:46 +0100)
_hud_common.cfg
qcsrc/client/hud/panel/scoreboard.qc

index 935f177d8a343c1e1488581bd27b3328b05e953b..4973ef0bc008d88d2dc1e1f6dda768c30c451961 100644 (file)
@@ -120,6 +120,9 @@ seta hud_panel_scoreboard_others_showscore 1 "show scores of players listed in t
 seta hud_panel_scoreboard_spectators_showping 1 "show ping of spectators"
 seta hud_panel_scoreboard_spectators_aligned 0 "align spectators in columns"
 seta hud_panel_scoreboard_minwidth 0.6 "minimum width of the scoreboard"
+seta hud_panel_scoreboard_playerid 0 "show player id (server entity number) next to player's name"
+seta hud_panel_scoreboard_playerid_prefix "#" "player id prefix"
+seta hud_panel_scoreboard_playerid_suffix " " "player id suffix"
 
 seta hud_panel_scoreboard_accuracy_showdelay 2 "how long to delay displaying accuracy below the scoreboard if it's too far down"
 seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the accuracy panel only if its position is lower than this percentage of the screen height from the top"
index d9c4d2bedf0899a44a83dc056f22e94321e9cdf5..9965d58fb4ed257d341596517b046a33be301e48 100644 (file)
@@ -93,6 +93,9 @@ bool autocvar_hud_panel_scoreboard_others_showscore = true;
 bool autocvar_hud_panel_scoreboard_spectators_showping = true;
 bool autocvar_hud_panel_scoreboard_spectators_aligned = false;
 float autocvar_hud_panel_scoreboard_minwidth = 0.4;
+bool autocvar_hud_panel_scoreboard_playerid = false;
+string autocvar_hud_panel_scoreboard_playerid_prefix = "#";
+string autocvar_hud_panel_scoreboard_playerid_suffix = " ";
 
 // mode 0: returns translated label
 // mode 1: prints name and description of all the labels
@@ -571,6 +574,13 @@ LABEL(found)
        sbt_field[sbt_num_fields] = SP_END;
 }
 
+string Scoreboard_AddPlayerId(string pl_name, entity pl)
+{
+       string pref = autocvar_hud_panel_scoreboard_playerid_prefix;
+       string suf = autocvar_hud_panel_scoreboard_playerid_suffix;
+       return strcat(pref, itos(pl.sv_entnum + 1), suf, pl_name);
+}
+
 // MOVEUP::
 vector sbt_field_rgb;
 string sbt_field_icon0;
@@ -639,7 +649,10 @@ string Scoreboard_GetField(entity pl, PlayerScoreField field)
                        return str;
 
                case SP_NAME:
-                       return Scoreboard_GetName(pl);
+                       str = Scoreboard_GetName(pl);
+                       if (autocvar_hud_panel_scoreboard_playerid)
+                               str = Scoreboard_AddPlayerId(str, pl);
+                       return str;
 
                case SP_FRAGS:
                        f = pl.(scores(SP_KILLS));
@@ -987,7 +1000,10 @@ vector Scoreboard_DrawOthers(vector item_pos, vector rgb, int this_team, entity
                else if(autocvar_hud_panel_scoreboard_others_showscore)
                        field = Scoreboard_GetField(pl, SP_SCORE);
 
-               string str = textShortenToWidth(entcs_GetName(pl.sv_entnum), namesize, hud_fontsize, stringwidth_colors);
+               string str = entcs_GetName(pl.sv_entnum);
+               if (autocvar_hud_panel_scoreboard_playerid)
+                       str = Scoreboard_AddPlayerId(str, pl);
+               str = textShortenToWidth(str, namesize, hud_fontsize, stringwidth_colors);
                float column_width = stringwidth(str, true, hud_fontsize);
                if((this_team == NUM_SPECTATOR) && autocvar_hud_panel_scoreboard_spectators_aligned)
                {