From aa4ae235fdf5c617847714a152012b65bae547d9 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 25 Aug 2016 14:59:46 +0200 Subject: [PATCH] Reload hud_fontsize and fix scoreboard layout as soon as user changes hud_fontsize and displays the scoreboard --- qcsrc/client/hud/panel/scoreboard.qc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index c283be1c4..541e34eb3 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -10,6 +10,9 @@ // Scoreboard (#24) +string autocvar_hud_fontsize; +string hud_fontsize_str; + float sbt_bg_alpha; float sbt_fg_alpha; float sbt_fg_alpha_self; @@ -754,6 +757,12 @@ string Scoreboard_FixColumnWidth(int i, string str) return str; } +void Scoreboard_initFieldSizes() +{ + for(int i = 0; i < sbt_num_fields; ++i) + sbt_field_size[i] = stringwidth(sbt_field_title[i], false, hud_fontsize); +} + vector Scoreboard_DrawHeader(vector pos, vector rgb) { int i; @@ -1290,6 +1299,14 @@ void Scoreboard_Draw() scoreboard_fade_alpha = min(1, scoreboard_fade_alpha + frametime * scoreboard_fadeinspeed); else scoreboard_fade_alpha = 1; + if(hud_fontsize_str != autocvar_hud_fontsize) + { + hud_fontsize = HUD_GetFontsize("hud_fontsize"); + Scoreboard_initFieldSizes(); + if(hud_fontsize_str) + strunzone(hud_fontsize_str); + hud_fontsize_str = strzone(autocvar_hud_fontsize); + } } else { float scoreboard_fadeoutspeed = autocvar_hud_panel_scoreboard_fadeoutspeed; -- 2.39.2