From e8e2c6fc5d418d3451c51838ea318b1ab052ac85 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 30 May 2013 19:50:17 +0200 Subject: [PATCH] Use panel.current_panel_bg to keep and display panel bg instead of panel_bg (which now is a temp var) so that only one must be zoned. Previous code could crash sometimes. --- qcsrc/client/hud.qc | 21 ++++++++++++++------- qcsrc/client/hud.qh | 15 +++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index c6c91c763..1a8157513 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -264,8 +264,8 @@ HUD panels // draw the background/borders #define HUD_Panel_DrawBg(theAlpha)\ -if(panel_bg != "0")\ - draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER)) +if(panel.current_panel_bg != "0")\ + draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER)) //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, float vertical, float baralign, vector theColor, float theAlpha, float drawflag) @@ -1839,10 +1839,14 @@ void HUD_Radar(void) panel_size_y = bound(0.2, panel_size_y, 1) * vid_conheight; panel_pos_x = (vid_conwidth - panel_size_x) / 2; panel_pos_y = (vid_conheight - panel_size_y) / 2; - + panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized - if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback - + if(precache_pic(panel_bg) == "") + panel_bg = "gfx/hud/default/border_default"; // fallback + if(panel.current_panel_bg) + strunzone(panel.current_panel_bg); + panel.current_panel_bg = strzone(panel_bg); + switch(hud_panel_radar_maximized_zoommode) { default: @@ -3456,13 +3460,16 @@ void HUD_Chat(void) { panel_pos_y = panel_bg_border; panel_size_y = vid_conheight - panel_bg_border * 2; - if(panel_bg == "0") // force a border when maximized + if(panel.current_panel_bg == "0") // force a border when maximized { - if(precache_pic(panel_bg) == "") { + if(precache_pic(panel.current_panel_bg) == "") { panel_bg = strcat(hud_skin_path, "/border_default"); if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } + if(panel.current_panel_bg) + strunzone(panel.current_panel_bg); + panel.current_panel_bg = strzone(panel_bg); } } panel_bg_alpha = max(0.75, panel_bg_alpha); // force an theAlpha of at least 0.75 diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index e2a7442b8..1df77cde1 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -77,7 +77,7 @@ entity panel; var float panel_enabled; var vector panel_pos; var vector panel_size; -var string panel_bg; +var string panel_bg; // exceptionally this a temporary var, panel.current_panel_bg keeps the real value var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use var vector panel_bg_color; var string panel_bg_color_str; @@ -143,7 +143,7 @@ HUD_PANELS // ---------------------- // Little help for the poor people who have to make sense of this: Start from the bottom ;) -// Get value for panel_bg: if "" fetch default, else use panel_bg_str +// 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()\ if(!autocvar__hud_configure && panel_bg_str == "0") {\ @@ -165,7 +165,10 @@ if(!autocvar__hud_configure && panel_bg_str == "0") {\ }\ }\ }\ -} +}\ +if(panel.current_panel_bg)\ + strunzone(panel.current_panel_bg);\ +panel.current_panel_bg = strzone(panel_bg); // 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()\ @@ -286,7 +289,7 @@ if(panel.update_time <= time) { \ 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_bg != "0") {\ + if (panel.current_panel_bg != "0") {\ HUD_Panel_GetColorTeam()\ HUD_Panel_GetColor()\ HUD_Panel_GetBgAlpha()\ @@ -304,9 +307,6 @@ if(panel.update_time <= time) { \ }\ panel.current_panel_pos = panel_pos; \ panel.current_panel_size = panel_size; \ - if(panel.current_panel_bg != "") \ - strunzone(panel.current_panel_bg); \ - panel.current_panel_bg = strzone(panel_bg); \ 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; \ @@ -315,7 +315,6 @@ if(panel.update_time <= time) { \ } else { \ panel_pos = panel.current_panel_pos; \ panel_size = panel.current_panel_size; \ - panel_bg = panel.current_panel_bg; \ 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; \ -- 2.39.2