From: terencehill Date: Thu, 1 Sep 2016 16:10:27 +0000 (+0200) Subject: Turn a very long macro into a function, cuts down csprogs.dat size of ~70KB X-Git-Tag: xonotic-v0.8.2~624 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5c4c48917aabaa83ad249280d36bd317f4627420;p=xonotic%2Fxonotic-data.pk3dir.git Turn a very long macro into a function, cuts down csprogs.dat size of ~70KB --- diff --git a/qcsrc/client/hud/hud.qc b/qcsrc/client/hud/hud.qc index d200e2c6c..8ac6a4d99 100644 --- a/qcsrc/client/hud/hud.qc +++ b/qcsrc/client/hud/hud.qc @@ -120,6 +120,59 @@ HUD panels ================== */ +void HUD_Panel_LoadCvars() +{ + // NOTE: in hud_configure mode cvars must be reloaded every frame + if (panel.update_time <= time) + { + panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); + panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); + HUD_Panel_ScalePosSize(); + panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg")); + panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color")); + panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team")); + panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha")); + panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); + panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding")); + HUD_Panel_GetBg(); + if (panel.current_panel_bg != "0") + { + HUD_Panel_GetBgAlpha(); + HUD_Panel_GetBorder(); + } + HUD_Panel_GetColorTeam(); + HUD_Panel_GetColor(); + HUD_Panel_GetFgAlpha(); + HUD_Panel_GetPadding(); + panel.current_panel_bg_alpha = panel_bg_alpha; + panel.current_panel_fg_alpha = panel_fg_alpha; + if (hud_configure_menu_open == 2 && panel == highlightedPanel) + HUD_Panel_UpdatePosSize_ForMenu(); + else + { + panel_bg_alpha *= hud_fade_alpha * panel_fade_alpha; + panel_fg_alpha *= hud_fade_alpha * panel_fade_alpha; + } + panel.current_panel_pos = panel_pos; + panel.current_panel_size = panel_size; + panel.current_panel_bg_border = panel_bg_border; + panel.current_panel_bg_color = panel_bg_color; + panel.current_panel_bg_color_team = panel_bg_color_team; + panel.current_panel_bg_padding = panel_bg_padding; + panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval; + return; + } + + panel_pos = panel.current_panel_pos; + panel_size = panel.current_panel_size; + panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha * panel_fade_alpha; + panel_bg_border = panel.current_panel_bg_border; + panel_bg_color = panel.current_panel_bg_color; + panel_bg_color_team = panel.current_panel_bg_color_team; + panel_bg_padding = panel.current_panel_bg_padding; + panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha * panel_fade_alpha; +} + //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag) { diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 5087fa526..4cd0ee88e 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -365,54 +365,8 @@ REGISTER_HUD_PANEL(SCOREBOARD, Scoreboard_Draw, scoreboard, PANEL_CO panel_size.x *= vid_conwidth; panel_size.y *= vid_conheight; \ } MACRO_END -// NOTE: in hud_configure mode cvars must be reloaded every frame float panel_fade_alpha; -#define HUD_Panel_LoadCvars() MACRO_BEGIN { \ - if (panel.update_time <= time) { \ - panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos"))); \ - panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size"))); \ - HUD_Panel_ScalePosSize(); \ - panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg")); \ - panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color")); \ - panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team")); \ - panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha")); \ - panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \ - panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding")); \ - HUD_Panel_GetBg(); \ - if (panel.current_panel_bg != "0") { \ - HUD_Panel_GetBgAlpha(); \ - HUD_Panel_GetBorder(); \ - } \ - HUD_Panel_GetColorTeam(); \ - HUD_Panel_GetColor(); \ - HUD_Panel_GetFgAlpha(); \ - HUD_Panel_GetPadding(); \ - panel.current_panel_bg_alpha = panel_bg_alpha; \ - panel.current_panel_fg_alpha = panel_fg_alpha; \ - if (hud_configure_menu_open == 2 && panel == highlightedPanel) { \ - HUD_Panel_UpdatePosSize_ForMenu(); \ - } else { \ - panel_bg_alpha *= hud_fade_alpha * panel_fade_alpha; \ - panel_fg_alpha *= hud_fade_alpha * panel_fade_alpha; \ - } \ - panel.current_panel_pos = panel_pos; \ - panel.current_panel_size = panel_size; \ - panel.current_panel_bg_border = panel_bg_border; \ - panel.current_panel_bg_color = panel_bg_color; \ - panel.current_panel_bg_color_team = panel_bg_color_team; \ - panel.current_panel_bg_padding = panel_bg_padding; \ - panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval; \ - } else { \ - panel_pos = panel.current_panel_pos; \ - panel_size = panel.current_panel_size; \ - panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha * panel_fade_alpha; \ - panel_bg_border = panel.current_panel_bg_border; \ - panel_bg_color = panel.current_panel_bg_color; \ - panel_bg_color_team = panel.current_panel_bg_color_team; \ - panel_bg_padding = panel.current_panel_bg_padding; \ - panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha * panel_fade_alpha; \ - } \ -} MACRO_END +void HUD_Panel_LoadCvars(); #define Hud_Panel_GetPanelEnabled() \ panel_enabled = ((panel.panel_configflags & PANEL_CONFIG_CANBEOFF) \