From: terencehill Date: Sat, 9 Jan 2021 13:48:25 +0000 (+0100) Subject: Scoreboard: allow showing player id next to player name X-Git-Tag: xonotic-v0.8.5~603 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4a266a9c00b9092c24526f4be658587457834fcd;p=xonotic%2Fxonotic-data.pk3dir.git Scoreboard: allow showing player id next to player name --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 935f177d8..4973ef0bc 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -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" diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index d9c4d2bed..9965d58fb 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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) {