]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reveal macro continuation character in some macros
authorterencehill <piuntn@gmail.com>
Fri, 1 Feb 2019 15:40:12 +0000 (16:40 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 1 Feb 2019 15:40:12 +0000 (16:40 +0100)
qcsrc/client/hud/hud.qh

index d2349a6a5c60bef7f384b1c31d41cb89114c88e6..c710fd6518f90205c2c16e6258cb1a818777ca74 100644 (file)
@@ -240,107 +240,107 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
 
 // Get value for panel.current_panel_bg: if "" fetch default, else use panel_bg_str
 // comment on last line of macro: // we probably want to see a background in config mode at all times...
-#define HUD_Panel_GetBg() MACRO_BEGIN {                                                                             \
-       string panel_bg;                                                                                                \
-       if (!autocvar__hud_configure && panel_bg_str == "0") {                                                          \
-               panel_bg = "0";                                                                                             \
-       } else {                                                                                                        \
-               if (panel_bg_str == "") {                                                                                   \
-                       panel_bg_str = autocvar_hud_panel_bg;                                                                   \
-               }                                                                                                           \
-               if (panel_bg_str == "0" && !autocvar__hud_configure) {                                                      \
-                       panel_bg = "0";                                                                                         \
-               } else {                                                                                                    \
-                       if (panel_bg_str == "0" && autocvar__hud_configure)                                                     \
-                               panel_bg_alpha_str = "0";                                                                           \
-                       panel_bg = strcat(hud_skin_path, "/", panel_bg_str);                                                    \
-                       if (precache_pic(panel_bg) == "") {                                                                     \
-                               panel_bg = strcat(hud_skin_path, "/", "border_default");                                            \
-                               if (precache_pic(panel_bg) == "") {                                                                 \
-                                       panel_bg = strcat("gfx/hud/default/", "border_default");                                        \
-                               }                                                                                                   \
-                       }                                                                                                       \
-               }                                                                                                           \
-       }                                                                                                               \
-       strcpy(panel.current_panel_bg, panel_bg);                                                                       \
+#define HUD_Panel_GetBg() MACRO_BEGIN { \
+       string panel_bg; \
+       if (!autocvar__hud_configure && panel_bg_str == "0") { \
+               panel_bg = "0"; \
+       } else { \
+               if (panel_bg_str == "") { \
+                       panel_bg_str = autocvar_hud_panel_bg; \
+               } \
+               if (panel_bg_str == "0" && !autocvar__hud_configure) { \
+                       panel_bg = "0"; \
+               } else { \
+                       if (panel_bg_str == "0" && autocvar__hud_configure) \
+                               panel_bg_alpha_str = "0"; \
+                       panel_bg = strcat(hud_skin_path, "/", panel_bg_str); \
+                       if (precache_pic(panel_bg) == "") { \
+                               panel_bg = strcat(hud_skin_path, "/", "border_default"); \
+                               if (precache_pic(panel_bg) == "") { \
+                                       panel_bg = strcat("gfx/hud/default/", "border_default"); \
+                               } \
+                       } \
+               } \
+       } \
+       strcpy(panel.current_panel_bg, panel_bg); \
 } MACRO_END
 
 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
-#define HUD_Panel_GetColor() MACRO_BEGIN {                                                                          \
-       if ((teamplay) && panel_bg_color_team > 0) {                                                                        \
-               if (autocvar__hud_configure && myteam == NUM_SPECTATOR)                                                     \
-                       panel_bg_color = '1 0 0' * panel_bg_color_team;                                                         \
-               else                                                                                                        \
-                       panel_bg_color = myteamcolors * panel_bg_color_team;                                                    \
-       } else if (autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && panel_bg_color_team > 0) {          \
-               panel_bg_color = '1 0 0' * panel_bg_color_team;                                                             \
-       } else {                                                                                                        \
-               if (panel_bg_color_str == "") {                                                                             \
-                       panel_bg_color = autocvar_hud_panel_bg_color;                                                           \
-               } else {                                                                                                    \
-                       if (panel_bg_color_str == "shirt") {                                                                    \
+#define HUD_Panel_GetColor() MACRO_BEGIN { \
+       if ((teamplay) && panel_bg_color_team > 0) { \
+               if (autocvar__hud_configure && myteam == NUM_SPECTATOR) \
+                       panel_bg_color = '1 0 0' * panel_bg_color_team; \
+               else \
+                       panel_bg_color = myteamcolors * panel_bg_color_team; \
+       } else if (autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && panel_bg_color_team > 0) { \
+               panel_bg_color = '1 0 0' * panel_bg_color_team; \
+       } else { \
+               if (panel_bg_color_str == "") { \
+                       panel_bg_color = autocvar_hud_panel_bg_color; \
+               } else { \
+                       if (panel_bg_color_str == "shirt") { \
                                panel_bg_color = colormapPaletteColor(floor(entcs_GetClientColors(current_player) / 16), 0); \
-                       } else if (panel_bg_color_str == "pants") {                                                             \
+                       } else if (panel_bg_color_str == "pants") { \
                                panel_bg_color = colormapPaletteColor(entcs_GetClientColors(current_player) % 16, 1); \
-                       } else {                                                                                                \
-                               panel_bg_color = stov(panel_bg_color_str);                                                          \
-                       }                                                                                                       \
-               }                                                                                                           \
-       }                                                                                                               \
+                       } else { \
+                               panel_bg_color = stov(panel_bg_color_str); \
+                       } \
+               } \
+       } \
 } MACRO_END
 
 // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
-#define HUD_Panel_GetColorTeam() MACRO_BEGIN {                                                                      \
-       if (panel_bg_color_team_str == "") {                                                                            \
-               panel_bg_color_team = autocvar_hud_panel_bg_color_team;                                                     \
-       } else {                                                                                                        \
-               panel_bg_color_team = stof(panel_bg_color_team_str);                                                        \
-       }                                                                                                               \
+#define HUD_Panel_GetColorTeam() MACRO_BEGIN { \
+       if (panel_bg_color_team_str == "") { \
+               panel_bg_color_team = autocvar_hud_panel_bg_color_team; \
+       } else { \
+               panel_bg_color_team = stof(panel_bg_color_team_str); \
+       } \
 } MACRO_END
 
 // Get value for panel_bg_alpha: if "" fetch default, else use panel_bg_alpha. Also do various menu dialog fadeout/in checks, and minalpha checks
 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
-#define HUD_Panel_GetBgAlpha() MACRO_BEGIN {                                                                        \
-       if (panel_bg_alpha_str == "") {                                                                                 \
-               panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);                                                     \
-       }                                                                                                               \
-       panel_bg_alpha = stof(panel_bg_alpha_str);                                                                      \
-       if (autocvar__hud_configure) {                                                                                  \
-               if (!panel_enabled)                                                                                         \
-                       panel_bg_alpha = 0.25;                                                                                  \
-               else if (hud_configure_menu_open == 2 && panel == highlightedPanel)                                                    \
+#define HUD_Panel_GetBgAlpha() MACRO_BEGIN { \
+       if (panel_bg_alpha_str == "") { \
+               panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha); \
+       } \
+       panel_bg_alpha = stof(panel_bg_alpha_str); \
+       if (autocvar__hud_configure) { \
+               if (!panel_enabled) \
+                       panel_bg_alpha = 0.25; \
+               else if (hud_configure_menu_open == 2 && panel == highlightedPanel) \
                        panel_bg_alpha = (1 - autocvar__menu_alpha) * max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha) + autocvar__menu_alpha * panel_bg_alpha;\
-               else                                                                                                        \
-                       panel_bg_alpha = max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha);                                \
-       }                                                                                                               \
+               else \
+                       panel_bg_alpha = max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha); \
+       } \
 } MACRO_END
 
 // Get value for panel_fg_alpha. Also do various minalpha checks
 // comment on line 2 of macro: // ALWAYS show disabled panels at 0.25 alpha when in config mode
-#define HUD_Panel_GetFgAlpha() MACRO_BEGIN {                                                                        \
-       panel_fg_alpha = autocvar_hud_panel_fg_alpha;                                                                   \
-       if (autocvar__hud_configure && !panel_enabled)                                                                  \
-               panel_fg_alpha = 0.25;                                                                                      \
+#define HUD_Panel_GetFgAlpha() MACRO_BEGIN { \
+       panel_fg_alpha = autocvar_hud_panel_fg_alpha; \
+       if (autocvar__hud_configure && !panel_enabled) \
+               panel_fg_alpha = 0.25; \
 } MACRO_END
 
 // Get border. See comments above, it's similar.
-#define HUD_Panel_GetBorder() MACRO_BEGIN {                                                                         \
-       if (panel_bg_border_str == "") {                                                                                \
-               panel_bg_border = autocvar_hud_panel_bg_border;                                                             \
-       } else {                                                                                                        \
-               panel_bg_border = stof(panel_bg_border_str);                                                                \
-       }                                                                                                               \
+#define HUD_Panel_GetBorder() MACRO_BEGIN { \
+       if (panel_bg_border_str == "") { \
+               panel_bg_border = autocvar_hud_panel_bg_border; \
+       } else { \
+               panel_bg_border = stof(panel_bg_border_str); \
+       } \
 } MACRO_END
 
 // Get padding. See comments above, it's similar.
 // last line is a port of the old function, basically always make sure the panel contents are at least 5 pixels tall/wide, to disallow extreme padding values
-#define HUD_Panel_GetPadding() MACRO_BEGIN {                                                                        \
-       if (panel_bg_padding_str == "") {                                                                               \
-               panel_bg_padding = autocvar_hud_panel_bg_padding;                                                           \
-       } else {                                                                                                        \
-               panel_bg_padding = stof(panel_bg_padding_str);                                                              \
-       }                                                                                                               \
-       panel_bg_padding = min(min(panel_size.x, panel_size.y)/2 - 5, panel_bg_padding);                                \
+#define HUD_Panel_GetPadding() MACRO_BEGIN { \
+       if (panel_bg_padding_str == "") { \
+               panel_bg_padding = autocvar_hud_panel_bg_padding; \
+       } else { \
+               panel_bg_padding = stof(panel_bg_padding_str); \
+       } \
+       panel_bg_padding = min(min(panel_size.x, panel_size.y)/2 - 5, panel_bg_padding); \
 } MACRO_END
 
 // return smoothly faded pos and size of given panel when a dialog is active
@@ -359,9 +359,9 @@ REGISTER_HUD_PANEL(SCOREBOARD,      Scoreboard_Draw,    PANEL_CONFIG_NO
 } MACRO_END
 
 // Scale the pos and size vectors to absolute coordinates
-#define HUD_Panel_ScalePosSize() MACRO_BEGIN {                                                                      \
-       panel_pos.x *= vid_conwidth;  panel_pos.y *= vid_conheight;                                                     \
-       panel_size.x *= vid_conwidth; panel_size.y *= vid_conheight;                                                    \
+#define HUD_Panel_ScalePosSize() MACRO_BEGIN { \
+       panel_pos.x *= vid_conwidth; panel_pos.y *= vid_conheight; \
+       panel_size.x *= vid_conwidth; panel_size.y *= vid_conheight; \
 } MACRO_END
 
 float panel_fade_alpha;
@@ -371,16 +371,16 @@ void HUD_Panel_LoadCvars();
        panel_enabled = ((panel.panel_configflags & PANEL_CONFIG_CANBEOFF) \
                                        ? cvar(strcat("hud_panel_", panel.panel_name)) : true)
 
-#define HUD_Panel_UpdatePosSize() MACRO_BEGIN {                                                                     \
+#define HUD_Panel_UpdatePosSize() MACRO_BEGIN { \
        Hud_Panel_GetPanelEnabled(); \
-       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();                                                                                       \
-       if (hud_configure_menu_open == 2 && panel == highlightedPanel) {                                                           \
-               HUD_Panel_UpdatePosSize_ForMenu();                                                                          \
-       }                                                                                                               \
-       panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border"));                        \
-       HUD_Panel_GetBorder();                                                                                          \
+       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(); \
+       if (hud_configure_menu_open == 2 && panel == highlightedPanel) { \
+               HUD_Panel_UpdatePosSize_ForMenu(); \
+       } \
+       panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \
+       HUD_Panel_GetBorder(); \
 } MACRO_END
 
 const int NOTIFY_MAX_ENTRIES = 10;