3 float panel_order[HUD_PANEL_NUM];
4 string hud_panelorder_prev;
7 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
8 vector panel_click_resizeorigin; // coordinates for opposite point when resizing
9 float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
10 var float highlightedPanel = -1;
11 var float highlightedPanel_prev = -1;
12 float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
14 const float BORDER_MULTIPLIER = 0.25;
15 float scoreboard_bottom;
16 float weapon_hits[WEP_MAXCOUNT];
17 float weapon_fired[WEP_MAXCOUNT];
19 #define acc_color(i) stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))))
20 #define MAX_ACCURACY_LEVELS 10
21 float acc_lev[MAX_ACCURACY_LEVELS];
24 float complain_weapon;
25 string complain_weapon_name;
26 float complain_weapon_type;
27 float complain_weapon_time;
29 float ps_primary, ps_secondary;
30 float ts_primary, ts_secondary;
36 float hud_accuracy_hud;
37 float hud_border_thickness;
38 float hud_accuracy_border_thickness;
40 float hud_configure_checkcollisions;
41 float hud_configure_prev;
44 const float S_SHIFT = 1;
45 const float S_CTRL = 2;
46 const float S_ALT = 4;
48 float disable_menu_alphacheck; // 0 = enable alpha check, 1 = disable for entire hud, 2 = disable for one panel
49 float menu_fade_alpha;
53 var vector progressbar_color;
55 var float active_panel; // this panel has recently referred the UpdateCvars macro
56 var string panel_name;
57 var float panel_enabled;
59 var vector panel_size;
61 var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
62 var vector panel_bg_color;
63 var string panel_bg_color_str;
64 var float panel_bg_color_team;
65 var string panel_bg_color_team_str;
66 var float panel_fg_alpha;
67 var float panel_bg_alpha;
68 var string panel_bg_alpha_str;
69 var float panel_bg_border;
70 var string panel_bg_border_str;
71 var float panel_bg_padding;
72 var string panel_bg_padding_str;
73 var float panel_accuracy_yellow;
74 var float panel_accuracy_onlycurrent;
75 var float panel_accuracy_flip;
76 var float panel_accuracy_iconalign;
77 var float panel_accuracy_baralign;
78 var float panel_accuracy_info_top;
79 var float panel_accuracy_foreground_alpha;
80 var float panel_accuracy_alreadyvoted_alpha;
84 // Because calling lots of functions in QC apparently cuts fps in half on many machines:
85 // ----------------------
86 // MACRO HELL STARTS HERE
87 // ----------------------
88 // Little help for the poor people who have to make sense of this: Start from the bottom
90 #define HUD_Panel_GetProgressBarColor(item) \
92 case "strength": progressbar_color = autocvar_hud_progressbar_strength_color; break;\
93 case "shield": progressbar_color = autocvar_hud_progressbar_shield_color; break;\
94 case "health": progressbar_color = autocvar_hud_progressbar_health_color; break;\
95 case "armor": progressbar_color = autocvar_hud_progressbar_armor_color; break;\
96 case "fuel": progressbar_color = autocvar_hud_progressbar_fuel_color; break;\
97 case "nexball": progressbar_color = autocvar_hud_progressbar_nexball_color; break;\
100 // Get value for panel_bg: if "" fetch default, else use panel_bg_str
101 // comment on last line of macro: // we probably want to see a background in config mode at all times...
102 #define HUD_Panel_GetBg()\
103 if(!autocvar__hud_configure && panel_bg_str == "0") {\
106 if(panel_bg_str == "") {\
107 panel_bg = autocvar_hud_panel_bg;\
108 } else if(panel_bg_str == "0" && autocvar__hud_configure) {\
109 panel_bg = autocvar_hud_panel_bg;\
110 panel_bg_alpha_str = "0";\
112 panel_bg = panel_bg_str;\
114 panel_bg = strcat(hud_skin_path, "/", panel_bg);\
115 if(precache_pic(panel_bg) == "") {\
116 panel_bg = strcat(hud_skin_path, "/", "border");\
117 if(precache_pic(panel_bg) == "") {\
118 panel_bg = strcat("gfx/hud/default/", "border");\
123 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
124 #define HUD_Panel_GetColor()\
125 if((teamplay) && panel_bg_color_team) {\
126 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1) * panel_bg_color_team;\
127 } else if (autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && panel_bg_color_team) {\
128 panel_bg_color = '1 0 0' * panel_bg_color_team;\
130 if(panel_bg_color_str == "") {\
131 panel_bg_color = autocvar_hud_panel_bg_color;\
133 if(panel_bg_color_str == "shirt") {\
134 panel_bg_color = colormapPaletteColor(floor(stof(getplayerkey(player_localentnum - 1, "colors")) / 16), 0);\
135 } else if(panel_bg_color_str == "pants") {\
136 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1);\
138 panel_bg_color = stov(panel_bg_color_str);\
143 // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
144 #define HUD_Panel_GetColorTeam()\
145 if(panel_bg_color_team_str == "") {\
146 panel_bg_color_team = autocvar_hud_panel_bg_color_team;\
148 panel_bg_color_team = stof(panel_bg_color_team_str);\
151 // 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
152 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
153 #define HUD_Panel_GetBgAlpha()\
154 if(panel_bg_alpha_str == "") {\
155 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);\
157 panel_bg_alpha = stof(panel_bg_alpha_str);\
158 if(autocvar__hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == active_panel) {\
159 panel_bg_alpha = (1 - autocvar__menu_alpha) * max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha) + autocvar__menu_alpha * panel_bg_alpha;\
160 } else if(autocvar__hud_configure) {\
161 panel_bg_alpha = max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha);\
162 } if(autocvar__hud_configure && !panel_enabled) {\
163 panel_bg_alpha = 0.25;\
164 } if(!(disable_menu_alphacheck == 2 && highlightedPanel == active_panel)) {\
165 panel_bg_alpha *= menu_fade_alpha;\
168 // Get value for panel_fg_alpha. Also do various minalpha checks
169 // comment on line 2 of macro: // ALWAYS show disabled panels at 0.25 alpha when in config mode
170 // comment on line 4 of macro: // don't fade this panel when showing the panel-specific menu dialog
171 #define HUD_Panel_GetFgAlpha()\
172 panel_fg_alpha = autocvar_hud_panel_fg_alpha;\
173 if(autocvar__hud_configure && !panel_enabled)\
174 panel_fg_alpha = 0.25;\
175 if(!(disable_menu_alphacheck == 2 && highlightedPanel == active_panel))\
176 panel_fg_alpha *= menu_fade_alpha;
178 // Get border. See comments above, it's similar.
179 #define HUD_Panel_GetBorder()\
180 if(panel_bg_border_str == "") {\
181 panel_bg_border = autocvar_hud_panel_bg_border;\
183 panel_bg_border = stof(panel_bg_border_str);\
186 // Scale the pos and size vectors to absolute coordinates
187 #define HUD_Panel_GetScaledVectors()\
188 panel_pos_x *= vid_conwidth;\
189 panel_pos_y *= vid_conheight;\
190 panel_size_x *= vid_conwidth;\
191 panel_size_y *= vid_conheight;
193 // Get padding. See comments above, it's similar.
194 // 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
195 #define HUD_Panel_GetPadding()\
196 if(panel_bg_padding_str == "") {\
197 panel_bg_padding = autocvar_hud_panel_bg_padding;\
199 panel_bg_padding = stof(panel_bg_padding_str);\
201 panel_bg_padding = min(min(panel_size_x, panel_size_y)/2 - 5, panel_bg_padding);
203 // Point to the macros above (stupid max macro length)
204 #define HUD_Panel_StringVars()\
206 HUD_Panel_GetColorTeam()\
207 HUD_Panel_GetColor()\
208 HUD_Panel_GetBgAlpha()\
209 HUD_Panel_GetFgAlpha()\
210 HUD_Panel_GetBorder()\
211 HUD_Panel_GetScaledVectors()\
212 HUD_Panel_GetPadding()
214 // return smoothly faded pos of given panel when a dialog is active
215 var vector menu_enable_panelpos;
216 #define HUD_Panel_GetMenuPos() \
217 if(panel_size_x > panel_size_y)\
218 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * 0.82 * vid_conheight;\
220 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * 0.7 * vid_conwidth;\
221 panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_panelpos;
223 // return smoothly faded size of given panel when a dialog is active
224 var vector menu_enable_maxsize;
225 var vector menu_enable_size;
226 #define HUD_Panel_GetMenuSize()\
227 menu_enable_maxsize_x = 0.3 * vid_conwidth;\
228 menu_enable_maxsize_y = 0.18 * vid_conheight;\
229 if(panel_size_x > panel_size_y)\
231 if(panel_size_y > menu_enable_maxsize_y)\
233 menu_enable_size_y = menu_enable_maxsize_y;\
234 menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y);\
235 panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
240 if(panel_size_x > menu_enable_maxsize_x)\
242 menu_enable_size_x = menu_enable_maxsize_x;\
243 menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x);\
244 panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
248 // Update all common cvars of given panel name
249 #define HUD_Panel_UpdateCvars(name) \
250 panel_enabled = autocvar_hud_panel_##name; \
251 panel_pos = autocvar_hud_panel_##name##_pos; \
252 panel_size = autocvar_hud_panel_##name##_size; \
253 panel_bg_str = autocvar_hud_panel_##name##_bg; \
254 panel_bg_color_str = autocvar_hud_panel_##name##_bg_color; \
255 panel_bg_color_team_str = autocvar_hud_panel_##name##_bg_color_team; \
256 panel_bg_alpha_str = autocvar_hud_panel_##name##_bg_alpha; \
257 panel_bg_border_str = autocvar_hud_panel_##name##_bg_border; \
258 panel_bg_padding_str = autocvar_hud_panel_##name##_bg_padding; \
259 HUD_Panel_StringVars()\
260 if(disable_menu_alphacheck == 2 && active_panel == highlightedPanel) {\
261 HUD_Panel_GetMenuSize()\
262 HUD_Panel_GetMenuPos()\
265 // Update all common cvars of given panel id
266 #define HUD_Panel_UpdateCvarsForId(id) \
268 case HUD_PANEL_WEAPONS: HUD_Panel_UpdateCvars(weapons) break; \
269 case HUD_PANEL_AMMO: HUD_Panel_UpdateCvars(ammo) break; \
270 case HUD_PANEL_POWERUPS: HUD_Panel_UpdateCvars(powerups) break; \
271 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdateCvars(healtharmor) break; \
272 case HUD_PANEL_NOTIFY: HUD_Panel_UpdateCvars(notify) break; \
273 case HUD_PANEL_TIMER: HUD_Panel_UpdateCvars(timer) break; \
274 case HUD_PANEL_RADAR: HUD_Panel_UpdateCvars(radar) break; \
275 case HUD_PANEL_SCORE: HUD_Panel_UpdateCvars(score) break; \
276 case HUD_PANEL_RACETIMER: HUD_Panel_UpdateCvars(racetimer) break; \
277 case HUD_PANEL_VOTE: HUD_Panel_UpdateCvars(vote) break; \
278 case HUD_PANEL_MODICONS: HUD_Panel_UpdateCvars(modicons) break; \
279 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
280 case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
281 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
282 case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
285 #define HUD_Panel_UpdatePosSize(name) \
286 panel_pos = autocvar_hud_panel_##name##_pos; \
287 panel_size = autocvar_hud_panel_##name##_size; \
288 HUD_Panel_GetScaledVectors()\
289 if(disable_menu_alphacheck == 2 && active_panel == highlightedPanel) {\
290 HUD_Panel_GetMenuSize()\
291 HUD_Panel_GetMenuPos()\
293 panel_bg_border_str = autocvar_hud_panel_##name##_bg_border; \
294 HUD_Panel_GetBorder()
296 // Update pos and size of given panel id
297 #define HUD_Panel_UpdatePosSizeForId(id) \
299 case HUD_PANEL_WEAPONS: HUD_Panel_UpdatePosSize(weapons) break;\
300 case HUD_PANEL_AMMO: HUD_Panel_UpdatePosSize(ammo) break;\
301 case HUD_PANEL_POWERUPS: HUD_Panel_UpdatePosSize(powerups) break;\
302 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdatePosSize(healtharmor) break;\
303 case HUD_PANEL_NOTIFY: HUD_Panel_UpdatePosSize(notify) break;\
304 case HUD_PANEL_TIMER: HUD_Panel_UpdatePosSize(timer) break;\
305 case HUD_PANEL_RADAR: HUD_Panel_UpdatePosSize(radar) break;\
306 case HUD_PANEL_SCORE: HUD_Panel_UpdatePosSize(score) break;\
307 case HUD_PANEL_RACETIMER: HUD_Panel_UpdatePosSize(racetimer) break;\
308 case HUD_PANEL_VOTE: HUD_Panel_UpdatePosSize(vote) break;\
309 case HUD_PANEL_MODICONS: HUD_Panel_UpdatePosSize(modicons) break;\
310 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdatePosSize(pressedkeys) break;\
311 case HUD_PANEL_CHAT: HUD_Panel_UpdatePosSize(chat) break;\
312 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdatePosSize(engineinfo) break;\
313 case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages)\