From: TimePath Date: Mon, 26 Jan 2015 07:41:06 +0000 (+1100) Subject: Clean up macro hell X-Git-Tag: xonotic-v0.8.1~133^2~28 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=177af3c84a6f9072ae28dbd69c75e7c299421f39;p=xonotic%2Fxonotic-data.pk3dir.git Clean up macro hell --- diff --git a/qcsrc/client/View.qc b/qcsrc/client/View.qc index 70c9ae65e..9a69aced8 100644 --- a/qcsrc/client/View.qc +++ b/qcsrc/client/View.qc @@ -997,7 +997,14 @@ void CSQC_UpdateView(float w, float h) button_attack2 = (input_buttons & BUTTON_3); button_zoom = (input_buttons & BUTTON_4); -#define CHECKFAIL_ASSERT(flag,func,parm,val) { float checkfailv; checkfailv = (func)(parm); if(checkfailv != (val)) { if(!checkfail[(flag)]) localcmd(sprintf("\ncmd checkfail %s %s %d %d\n", #func, parm, val, checkfailv)); checkfail[(flag)] = 1; } } ENDS_WITH_CURLY_BRACE +#define CHECKFAIL_ASSERT(flag,func,parm,val) do { \ + float checkfailv = (func)(parm); \ + if (checkfailv != (val)) { \ + if (!checkfail[(flag)]) \ + localcmd(sprintf("\ncmd checkfail %s %s %d %d\n", #func, parm, val, checkfailv)); \ + checkfail[(flag)] = 1; \ + } \ +} while(0) CHECKFAIL_ASSERT(0, cvar_type, "\{100}\{105}\{118}\{48}\{95}\{101}\{118}\{97}\{100}\{101}", 0); CHECKFAIL_ASSERT(1, cvar_type, "\{97}\{97}\{95}\{101}\{110}\{97}\{98}\{108}\{101}", 0); CHECKFAIL_ASSERT(2, cvar, "\{114}\{95}\{115}\{104}\{111}\{119}\{100}\{105}\{115}\{97}\{98}\{108}\{101}\{100}\{101}\{112}\{116}\{104}\{116}\{101}\{115}\{116}", 0); diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index 23eed8f1e..94770b815 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -97,43 +97,42 @@ var string panel_bg_padding_str; float current_player; -#define HUD_PANELS \ - HUD_PANEL(WEAPONS , HUD_Weapons , weapons) \ - HUD_PANEL(AMMO , HUD_Ammo , ammo) \ - HUD_PANEL(POWERUPS , HUD_Powerups , powerups) \ - HUD_PANEL(HEALTHARMOR , HUD_HealthArmor , healtharmor) \ - HUD_PANEL(NOTIFY , HUD_Notify , notify) \ - HUD_PANEL(TIMER , HUD_Timer , timer) \ - HUD_PANEL(RADAR , HUD_Radar , radar) \ - HUD_PANEL(SCORE , HUD_Score , score) \ - HUD_PANEL(RACETIMER , HUD_RaceTimer , racetimer) \ - HUD_PANEL(VOTE , HUD_Vote , vote) \ - HUD_PANEL(MODICONS , HUD_ModIcons , modicons) \ - HUD_PANEL(PRESSEDKEYS , HUD_PressedKeys , pressedkeys) \ - HUD_PANEL(CHAT , HUD_Chat , chat) \ - HUD_PANEL(ENGINEINFO , HUD_EngineInfo , engineinfo) \ - HUD_PANEL(INFOMESSAGES , HUD_InfoMessages , infomessages) \ - HUD_PANEL(PHYSICS , HUD_Physics , physics) \ - HUD_PANEL(CENTERPRINT , HUD_CenterPrint , centerprint) \ - HUD_PANEL(BUFFS , HUD_Buffs , buffs) - -#define HUD_PANEL(NAME,draw_func,name) \ - int HUD_PANEL_##NAME; \ - void draw_func(void); \ - void RegisterHUD_Panel_##NAME() \ - { \ - HUD_PANEL_LAST = HUD_PANEL_##NAME = HUD_PANEL_NUM; \ - entity hud_panelent = spawn(); \ - hud_panel[HUD_PANEL_##NAME] = hud_panelent; \ - hud_panelent.classname = "hud_panel"; \ - hud_panelent.panel_name = #name; \ - hud_panelent.panel_id = HUD_PANEL_##NAME; \ - hud_panelent.panel_draw = draw_func; \ - ++HUD_PANEL_NUM; \ - } \ +#define HUD_PANELS(HUD_PANEL) \ + HUD_PANEL(WEAPONS , HUD_Weapons , weapons) \ + HUD_PANEL(AMMO , HUD_Ammo , ammo) \ + HUD_PANEL(POWERUPS , HUD_Powerups , powerups) \ + HUD_PANEL(HEALTHARMOR , HUD_HealthArmor , healtharmor) \ + HUD_PANEL(NOTIFY , HUD_Notify , notify) \ + HUD_PANEL(TIMER , HUD_Timer , timer) \ + HUD_PANEL(RADAR , HUD_Radar , radar) \ + HUD_PANEL(SCORE , HUD_Score , score) \ + HUD_PANEL(RACETIMER , HUD_RaceTimer , racetimer) \ + HUD_PANEL(VOTE , HUD_Vote , vote) \ + HUD_PANEL(MODICONS , HUD_ModIcons , modicons) \ + HUD_PANEL(PRESSEDKEYS , HUD_PressedKeys , pressedkeys) \ + HUD_PANEL(CHAT , HUD_Chat , chat) \ + HUD_PANEL(ENGINEINFO , HUD_EngineInfo , engineinfo) \ + HUD_PANEL(INFOMESSAGES , HUD_InfoMessages , infomessages) \ + HUD_PANEL(PHYSICS , HUD_Physics , physics) \ + HUD_PANEL(CENTERPRINT , HUD_CenterPrint , centerprint) \ + HUD_PANEL(BUFFS , HUD_Buffs , buffs) + +#define HUD_PANEL(NAME, draw_func, name) \ + int HUD_PANEL_##NAME; \ + void draw_func(void); \ + void RegisterHUD_Panel_##NAME() { \ + HUD_PANEL_LAST = HUD_PANEL_##NAME = HUD_PANEL_NUM; \ + entity hud_panelent = spawn(); \ + hud_panel[HUD_PANEL_##NAME] = hud_panelent; \ + hud_panelent.classname = "hud_panel"; \ + hud_panelent.panel_name = #name; \ + hud_panelent.panel_id = HUD_PANEL_##NAME; \ + hud_panelent.panel_draw = draw_func; \ + HUD_PANEL_NUM++; \ + } \ ACCUMULATE_FUNCTION(RegisterHUD_Panels, RegisterHUD_Panel_##NAME); -HUD_PANELS +HUD_PANELS(HUD_PANEL) #undef HUD_PANEL #define HUD_PANEL(NAME) hud_panel[HUD_PANEL_##NAME] @@ -147,196 +146,201 @@ HUD_PANELS // 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()\ -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");\ - }\ - }\ - }\ -}\ -if(panel.current_panel_bg)\ - strunzone(panel.current_panel_bg);\ -panel.current_panel_bg = strzone(panel_bg); +#define HUD_Panel_GetBg() do { \ + 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"); \ + } \ + } \ + } \ + } \ + if (panel.current_panel_bg) \ + strunzone(panel.current_panel_bg); \ + panel.current_panel_bg = strzone(panel_bg); \ +} while(0) // 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()\ -if((teamplay) && panel_bg_color_team) {\ - 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) {\ - 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(stof(getplayerkeyvalue(current_player - 1, "colors")) / 16), 0);\ - } else if(panel_bg_color_str == "pants") {\ - panel_bg_color = colormapPaletteColor(stof(getplayerkeyvalue(current_player - 1, "colors")) % 16, 1);\ - } else {\ - panel_bg_color = stov(panel_bg_color_str);\ - }\ - }\ -} +#define HUD_Panel_GetColor() do { \ + if ((teamplay) && panel_bg_color_team) { \ + 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) { \ + 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(stof(getplayerkeyvalue(current_player - 1, "colors")) / 16), 0);\ + } else if (panel_bg_color_str == "pants") { \ + panel_bg_color = colormapPaletteColor(stof(getplayerkeyvalue(current_player - 1, "colors")) % 16, 1);\ + } else { \ + panel_bg_color = stov(panel_bg_color_str); \ + } \ + } \ + } \ +} while(0) // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str -#define HUD_Panel_GetColorTeam()\ -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() do { \ + 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); \ + } \ +} while(0) // 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()\ -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(menu_enabled == 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);\ -} +#define HUD_Panel_GetBgAlpha() do { \ + 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 (menu_enabled == 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); \ + } \ +} while(0) // 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()\ -panel_fg_alpha = autocvar_hud_panel_fg_alpha;\ -if(autocvar__hud_configure && !panel_enabled)\ - panel_fg_alpha = 0.25;\ +#define HUD_Panel_GetFgAlpha() do { \ + panel_fg_alpha = autocvar_hud_panel_fg_alpha; \ + if (autocvar__hud_configure && !panel_enabled) \ + panel_fg_alpha = 0.25; \ +} while(0) // Get border. See comments above, it's similar. -#define HUD_Panel_GetBorder()\ -if(panel_bg_border_str == "") {\ - panel_bg_border = autocvar_hud_panel_bg_border;\ -} else {\ - panel_bg_border = stof(panel_bg_border_str);\ -} ENDS_WITH_CURLY_BRACE +#define HUD_Panel_GetBorder() do { \ + if (panel_bg_border_str == "") { \ + panel_bg_border = autocvar_hud_panel_bg_border; \ + } else { \ + panel_bg_border = stof(panel_bg_border_str); \ + } \ +} while(0) // 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()\ -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() do { \ + 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); \ +} while(0) // return smoothly faded pos and size of given panel when a dialog is active -#define HUD_Panel_UpdatePosSize_ForMenu()\ -vector menu_enable_pos;\ -vector menu_enable_size = '0 0 0';\ -float menu_enable_maxsize_x = 0.3 * vid_conwidth;\ -float menu_enable_maxsize_y = 0.18 * vid_conheight;\ -if(panel_size_x > panel_size_y)\ -{\ - if(panel_size_y > menu_enable_maxsize_y)\ - {\ - menu_enable_size_y = menu_enable_maxsize_y;\ - menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y);\ - panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\ - }\ - menu_enable_pos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * (vid_conheight - menu_enable_maxsize_y);\ -}\ -else\ -{\ - if(panel_size_x > menu_enable_maxsize_x)\ - {\ - menu_enable_size_x = menu_enable_maxsize_x;\ - menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x);\ - panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\ - }\ - menu_enable_pos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * (vid_conwidth - menu_enable_maxsize_x);\ -}\ -panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_pos; +#define HUD_Panel_UpdatePosSize_ForMenu() do { \ + vector menu_enable_pos; \ + vector menu_enable_size = '0 0 0'; \ + float menu_enable_maxsize_x = 0.3 * vid_conwidth; \ + float menu_enable_maxsize_y = 0.18 * vid_conheight; \ + if (panel_size_x > panel_size_y) { \ + if (panel_size_y > menu_enable_maxsize_y) { \ + menu_enable_size_y = menu_enable_maxsize_y; \ + menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y); \ + panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size; \ + } \ + menu_enable_pos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * (vid_conheight - menu_enable_maxsize_y);\ + } else { \ + if (panel_size_x > menu_enable_maxsize_x) { \ + menu_enable_size_x = menu_enable_maxsize_x; \ + menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x); \ + panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size; \ + } \ + menu_enable_pos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * (vid_conwidth - menu_enable_maxsize_x);\ + } \ + panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_pos; \ +} while(0) // Scale the pos and size vectors to absolute coordinates -#define HUD_Panel_ScalePosSize()\ -panel_pos_x *= vid_conwidth; panel_pos_y *= vid_conheight;\ -panel_size_x *= vid_conwidth; panel_size_y *= vid_conheight; +#define HUD_Panel_ScalePosSize() do { \ + panel_pos_x *= vid_conwidth; panel_pos_y *= vid_conheight; \ + panel_size_x *= vid_conwidth; panel_size_y *= vid_conheight; \ +} while(0) // NOTE: in hud_configure mode cvars must be reloaded every frame -#define HUD_Panel_UpdateCvars() \ -if(panel.update_time <= time) { \ - if(autocvar__hud_configure) panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \ - 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_GetColorTeam()\ - HUD_Panel_GetColor()\ - HUD_Panel_GetBgAlpha()\ - HUD_Panel_GetBorder()\ - }\ - HUD_Panel_GetFgAlpha()\ - HUD_Panel_GetPadding()\ - panel.current_panel_bg_alpha = panel_bg_alpha; \ - panel.current_panel_fg_alpha = panel_fg_alpha; \ - if(menu_enabled == 2 && panel == highlightedPanel) {\ - HUD_Panel_UpdatePosSize_ForMenu()\ - } else {\ - panel_bg_alpha *= hud_fade_alpha;\ - panel_fg_alpha *= hud_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_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; \ -} ENDS_WITH_CURLY_BRACE - -#define HUD_Panel_UpdatePosSize() {\ -panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \ -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(menu_enabled == 2 && panel == highlightedPanel) {\ - HUD_Panel_UpdatePosSize_ForMenu()\ -}\ -panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \ -HUD_Panel_GetBorder() \ -} ENDS_WITH_CURLY_BRACE +#define HUD_Panel_UpdateCvars() do { \ + if (panel.update_time <= time) { \ + if (autocvar__hud_configure) panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \ + 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_GetColorTeam(); \ + HUD_Panel_GetColor(); \ + HUD_Panel_GetBgAlpha(); \ + HUD_Panel_GetBorder(); \ + } \ + HUD_Panel_GetFgAlpha(); \ + HUD_Panel_GetPadding(); \ + panel.current_panel_bg_alpha = panel_bg_alpha; \ + panel.current_panel_fg_alpha = panel_fg_alpha; \ + if (menu_enabled == 2 && panel == highlightedPanel) { \ + HUD_Panel_UpdatePosSize_ForMenu(); \ + } else { \ + panel_bg_alpha *= hud_fade_alpha; \ + panel_fg_alpha *= hud_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_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; \ + } \ +} while(0) + +#define HUD_Panel_UpdatePosSize() do { \ + panel_enabled = cvar(strcat("hud_panel_", panel.panel_name)); \ + 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 (menu_enabled == 2 && panel == highlightedPanel) { \ + HUD_Panel_UpdatePosSize_ForMenu(); \ + } \ + panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border")); \ + HUD_Panel_GetBorder(); \ +} while(0) const float NOTIFY_MAX_ENTRIES = 10; const float NOTIFY_ICON_MARGIN = 0.02; diff --git a/qcsrc/client/hud_config.qc b/qcsrc/client/hud_config.qc index 31e865ff0..e7f79fb2d 100644 --- a/qcsrc/client/hud_config.qc +++ b/qcsrc/client/hud_config.qc @@ -223,7 +223,7 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize) for (i = 0; i < HUD_PANEL_NUM; ++i) { panel = hud_panel[i]; if(panel == highlightedPanel) continue; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); if(!panel_enabled) continue; panel_pos -= '1 1 0' * panel_bg_border; @@ -285,7 +285,7 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize) void HUD_Panel_SetPos(vector pos) { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); vector mySize; mySize = panel_size; @@ -323,7 +323,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) { for (i = 0; i < HUD_PANEL_NUM; ++i) { panel = hud_panel[i]; if(panel == highlightedPanel) continue; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); if(!panel_enabled) continue; panel_pos -= '1 1 0' * panel_bg_border; @@ -424,7 +424,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) { void HUD_Panel_SetPosSize(vector mySize) { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); vector resizeorigin; resizeorigin = panel_click_resizeorigin; vector myPos; @@ -552,7 +552,7 @@ void HUD_Panel_Arrow_Action(float nPrimary) } panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); highlightedPanel_initial_pos = panel_pos; highlightedPanel_initial_size = panel_size; @@ -612,7 +612,7 @@ void HUD_Panel_Arrow_Action(float nPrimary) } panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); if (highlightedPanel_initial_pos != panel_pos || highlightedPanel_initial_size != panel_size) { @@ -754,7 +754,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) if (highlightedPanel) { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); } else panel_pos = '0 0 0'; @@ -786,7 +786,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) panel = hud_panel[i]; if (panel == tab_panels[i] || panel == starting_panel) continue; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); if (panel_pos.y >= level && (panel_pos.y - level) < level_height) if ( ( !tab_backward && panel_pos.x >= start_posX && (panel_pos.x < candidate_pos.x || (panel_pos_x == candidate_pos.x && panel_pos.y <= candidate_pos.y)) ) || ( tab_backward && panel_pos.x <= start_posX && (panel_pos.x > candidate_pos.x || (panel_pos_x == candidate_pos.x && panel_pos.y >= candidate_pos.y)) ) ) @@ -843,7 +843,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) if (highlightedPanel) { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); panel_size_copied = panel_size; } } @@ -856,7 +856,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary) return true; panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); // reduce size if it'd go beyond screen boundaries vector tmp_size = panel_size_copied; @@ -926,7 +926,7 @@ float HUD_Panel_Check_Mouse_Pos(float allow_move) j += 1; panel = hud_panel[i]; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize @@ -1007,7 +1007,7 @@ void HUD_Panel_Highlight(float allow_move) j += 1; panel = hud_panel[i]; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); border = max(8, panel_bg_border); // FORCED border so a small border size doesn't mean you can't resize @@ -1126,7 +1126,7 @@ void HUD_Panel_Mouse() else { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); } if (highlightedPanel) @@ -1272,13 +1272,13 @@ void HUD_Configure_PostDraw() if(tab_panel) { panel = tab_panel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL); } if(highlightedPanel) { panel = highlightedPanel; - HUD_Panel_UpdatePosSize() + HUD_Panel_UpdatePosSize(); HUD_Panel_HlBorder(panel_bg_border * hlBorderSize, '0 0.5 1', 0.4 * (1 - autocvar__menu_alpha)); } } diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index 2afe65f37..ff2705c19 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -1,6 +1,3 @@ -// a dummy macro that prevents the "hanging ;" warning -#define ENDS_WITH_CURLY_BRACE - #ifdef GMQCC # define ACCUMULATE_FUNCTION(func,otherfunc) \ [[accumulate]] void func() { otherfunc(); }