]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Turn a very long macro into a function, cuts down csprogs.dat size of ~70KB
authorterencehill <piuntn@gmail.com>
Thu, 1 Sep 2016 16:10:27 +0000 (18:10 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 1 Sep 2016 16:10:27 +0000 (18:10 +0200)
qcsrc/client/hud/hud.qc
qcsrc/client/hud/hud.qh

index d200e2c6c522e67f05b009f301f9a03f5677d9db..8ac6a4d991727ede9dbd1528eb5cb7c03667f2a5 100644 (file)
@@ -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)
 {
index 5087fa526929a086937b16d0dadb3463739045a1..4cd0ee88e32e0a1e50ae67920994b277dfb0feae 100644 (file)
@@ -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) \