From: Mario Date: Thu, 12 Dec 2024 13:56:50 +0000 (+1000) Subject: Add an option to shorten player names in checkpoint messages to reduce overflow X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=10fc5423821522705be9549c8372d6fc8712808e;p=xonotic%2Fxonotic-data.pk3dir.git Add an option to shorten player names in checkpoint messages to reduce overflow --- diff --git a/qcsrc/client/hud/panel/racetimer.qc b/qcsrc/client/hud/panel/racetimer.qc index e26b72bc3..3ce7e55ef 100644 --- a/qcsrc/client/hud/panel/racetimer.qc +++ b/qcsrc/client/hud/panel/racetimer.qc @@ -22,6 +22,7 @@ string MakeRaceString(int cp, float mytime, float theirtime, float othertime, fl { TC(int, cp); string cpname, lapstr = "", timestr = "", col = "^7", othercol = "^7", othertimestr = ""; + float namesize = autocvar_cl_race_cptimes_namesize * hud_fontsize.x; if(theirname == "" || !autocvar_cl_race_cptimes_showself) othertime = 0; // don't count personal time @@ -93,14 +94,17 @@ string MakeRaceString(int cp, float mytime, float theirtime, float othertime, fl else cpname = _("Finish line"); + if(theirname != "" && theirtime >= 0) + theirname = textShortenToWidth(ColorTranslateRGB(theirname), namesize, hud_fontsize, stringwidth_colors); + if(theirtime < 0) return strcat(col, cpname); else if(theirname == "") return strcat(col, sprintf("%s (%s)", cpname, timestr)); else if(othertime) - return strcat(col, sprintf("%s %s(%s)%s (%s %s)", cpname, othercol, othertimestr, col, timestr, strcat(ColorTranslateRGB(theirname), col, lapstr))); + return strcat(col, sprintf("%s %s(%s)%s (%s %s)", cpname, othercol, othertimestr, col, timestr, strcat(theirname, col, lapstr))); else - return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(ColorTranslateRGB(theirname), col, lapstr))); + return strcat(col, sprintf("%s (%s %s)", cpname, timestr, strcat(theirname, col, lapstr))); } void ClearRaceSplits() { diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 66d10cdae..c5efafb5e 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -25,11 +25,13 @@ bool autocvar_cl_race_checkpoint_splits_console; bool autocvar_cl_race_checkpoint_splits_hud; bool autocvar_cl_race_cptimes_showspeed = false; bool autocvar_cl_race_cptimes_showspeed_unit = true; +float autocvar_cl_race_cptimes_namesize = 10; #else AUTOCVAR_SAVE(cl_race_checkpoint_splits_console, bool, 1, "Print checkpoint splits to console"); AUTOCVAR_SAVE(cl_race_checkpoint_splits_hud, bool, 1, "Show race checkpoint splits on HUD in infomessages"); AUTOCVAR_SAVE(cl_race_cptimes_showspeed, bool, 0, "Show race checkpoint speed (NOTE: ignores vertical speed)"); AUTOCVAR_SAVE(cl_race_cptimes_showspeed_unit, bool, 1, "Show race checkpoint speed units"); +AUTOCVAR_SAVE(cl_race_cptimes_namesize, float, 10, "Maximum player name length in checkpoint messages"); #endif bool autocvar_cl_race_cptimes_onlyself; // TODO: move to race gamemode bool autocvar_cl_race_cptimes_showself = false; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 58c29f8b9..6668db2b4 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -716,6 +716,7 @@ seta cl_race_cptimes_showself 1 "Always show your own times as well as the curre seta cl_race_cptimes_onlyself 0 "Only show your own times on checkpoints in Race/CTS. Can be forced on by the server via g_race_cptimes_onlyself" seta cl_race_cptimes_showspeed 0 "Show race checkpoint speed (NOTE: ignores vertical speed)" seta cl_race_cptimes_showspeed_unit 1 "Show race checkpoint speed units" +seta cl_race_cptimes_namesize 10 "Maximum length of player names in checkpoint messages" seta cl_race_checkpoint_splits_console 1 "Print checkpoint splits to console" seta cl_race_checkpoint_splits_hud 1 "Show race checkpoint splits on HUD in infomessages"