3 vector centerprint_start;
5 float panel_order[HUD_PANEL_NUM];
6 string hud_panelorder_prev;
9 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
10 vector panel_click_resizeorigin; // coordinates for opposite point when resizing
11 float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
12 var float highlightedPanel = -1;
13 var float highlightedPanel_prev = -1;
14 float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
16 const float BORDER_MULTIPLIER = 0.25;
17 float scoreboard_bottom;
18 float weapon_accuracy[WEP_MAXCOUNT];
20 #define MAX_ACCURACY_LEVELS 10
21 float acc_lev[MAX_ACCURACY_LEVELS];
22 vector acc_col[MAX_ACCURACY_LEVELS];
24 string acc_color_levels;
26 float complain_weapon;
27 string complain_weapon_name;
28 float complain_weapon_type;
29 float complain_weapon_time;
31 float ps_primary, ps_secondary;
32 float ts_primary, ts_secondary;
40 float hud_configure_checkcollisions;
41 float hud_configure_prev;
42 vector hud_configure_gridSize;
43 vector hud_configure_realGridSize;
46 const float S_SHIFT = 1;
47 const float S_CTRL = 2;
48 const float S_ALT = 4;
50 float menu_enabled; // 1 showing the entire HUD, 2 showing only the clicked panel
51 float menu_enabled_time;
57 var vector progressbar_color;
59 var float highlightedPanel_backup = -1;
60 var vector panel_pos_backup;
61 var vector panel_size_backup;
63 var float highlightedPanel_copied = -1; //this is good only to know if there is something copied
64 var vector panel_size_copied;
66 var float active_panel; // this panel has recently referred the UpdateCvars macro
67 var string panel_name;
68 var float panel_enabled;
70 var vector panel_size;
72 var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
73 var vector panel_bg_color;
74 var string panel_bg_color_str;
75 var float panel_bg_color_team;
76 var string panel_bg_color_team_str;
77 var float panel_fg_alpha;
78 var float panel_bg_alpha;
79 var string panel_bg_alpha_str;
80 var float panel_bg_border;
81 var string panel_bg_border_str;
82 var float panel_bg_padding;
83 var string panel_bg_padding_str;
85 // Because calling lots of functions in QC apparently cuts fps in half on many machines:
86 // ----------------------
87 // MACRO HELL STARTS HERE
88 // ----------------------
89 // Little help for the poor people who have to make sense of this: Start from the bottom ;)
91 #define HUD_Panel_GetProgressBarColor(item) \
92 progressbar_color = stov(cvar_string("hud_progressbar_" #item "_color"))
93 #define HUD_Panel_GetProgressBarColorForString(item) \
95 case "health": HUD_Panel_GetProgressBarColor(health); break;\
96 case "armor": HUD_Panel_GetProgressBarColor(armor); break;\
97 case "strength": HUD_Panel_GetProgressBarColor(strength); break;\
98 case "shield": HUD_Panel_GetProgressBarColor(shield); break;\
99 case "fuel": HUD_Panel_GetProgressBarColor(fuel); break;\
100 case "nexball": HUD_Panel_GetProgressBarColor(nexball); break;\
101 case "speed": HUD_Panel_GetProgressBarColor(speed); break;\
102 case "acceleration": HUD_Panel_GetProgressBarColor(acceleration); break;\
103 case "acceleration_neg": HUD_Panel_GetProgressBarColor(acceleration_neg); break;\
104 } ENDS_WITH_CURLY_BRACE
106 // Get value for panel_bg: if "" fetch default, else use panel_bg_str
107 // comment on last line of macro: // we probably want to see a background in config mode at all times...
108 #define HUD_Panel_GetBg()\
109 if(!autocvar__hud_configure && panel_bg_str == "0") {\
112 if(panel_bg_str == "") {\
113 panel_bg_str = autocvar_hud_panel_bg;\
115 if(panel_bg_str == "0" && !autocvar__hud_configure) {\
118 if (panel_bg_str == "0" && autocvar__hud_configure)\
119 panel_bg_alpha_str = "0";\
120 panel_bg = strcat(hud_skin_path, "/", panel_bg_str);\
121 if(precache_pic(panel_bg) == "") {\
122 panel_bg = strcat(hud_skin_path, "/", "border_default");\
123 if(precache_pic(panel_bg) == "") {\
124 panel_bg = strcat("gfx/hud/default/", "border_default");\
130 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
131 #define HUD_Panel_GetColor()\
132 if((teamplay) && panel_bg_color_team) {\
133 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1) * panel_bg_color_team;\
134 } else if (autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && panel_bg_color_team) {\
135 panel_bg_color = '1 0 0' * panel_bg_color_team;\
137 if(panel_bg_color_str == "") {\
138 panel_bg_color = autocvar_hud_panel_bg_color;\
140 if(panel_bg_color_str == "shirt") {\
141 panel_bg_color = colormapPaletteColor(floor(stof(getplayerkey(player_localentnum - 1, "colors")) / 16), 0);\
142 } else if(panel_bg_color_str == "pants") {\
143 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1);\
145 panel_bg_color = stov(panel_bg_color_str);\
150 // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
151 #define HUD_Panel_GetColorTeam()\
152 if(panel_bg_color_team_str == "") {\
153 panel_bg_color_team = autocvar_hud_panel_bg_color_team;\
155 panel_bg_color_team = stof(panel_bg_color_team_str);\
158 // 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
159 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
160 #define HUD_Panel_GetBgAlpha()\
161 if(panel_bg_alpha_str == "") {\
162 panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);\
164 panel_bg_alpha = stof(panel_bg_alpha_str);\
165 if(autocvar__hud_configure) {\
167 panel_bg_alpha = 0.25;\
168 else if(menu_enabled == 2 && highlightedPanel == active_panel)\
169 panel_bg_alpha = (1 - autocvar__menu_alpha) * max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha) + autocvar__menu_alpha * panel_bg_alpha;\
171 panel_bg_alpha = max(cvar("hud_configure_bg_minalpha"), panel_bg_alpha);\
172 } if(!(menu_enabled == 2 && highlightedPanel == active_panel)) {\
173 panel_bg_alpha *= hud_fade_alpha;\
176 // Get value for panel_fg_alpha. Also do various minalpha checks
177 // comment on line 2 of macro: // ALWAYS show disabled panels at 0.25 alpha when in config mode
178 // comment on line 4 of macro: // don't fade this panel when showing the panel-specific menu dialog
179 #define HUD_Panel_GetFgAlpha()\
180 panel_fg_alpha = autocvar_hud_panel_fg_alpha;\
181 if(autocvar__hud_configure && !panel_enabled)\
182 panel_fg_alpha = 0.25;\
183 if(!(menu_enabled == 2 && highlightedPanel == active_panel))\
184 panel_fg_alpha *= hud_fade_alpha;
186 // Get border. See comments above, it's similar.
187 #define HUD_Panel_GetBorder()\
188 if(panel_bg_border_str == "") {\
189 panel_bg_border = autocvar_hud_panel_bg_border;\
191 panel_bg_border = stof(panel_bg_border_str);\
192 } ENDS_WITH_CURLY_BRACE
194 // Scale the pos and size vectors to absolute coordinates
195 #define HUD_Panel_GetScaledVectors()\
196 panel_pos_x *= vid_conwidth;\
197 panel_pos_y *= vid_conheight;\
198 panel_size_x *= vid_conwidth;\
199 panel_size_y *= vid_conheight;
201 // Get padding. See comments above, it's similar.
202 // 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
203 #define HUD_Panel_GetPadding()\
204 if(panel_bg_padding_str == "") {\
205 panel_bg_padding = autocvar_hud_panel_bg_padding;\
207 panel_bg_padding = stof(panel_bg_padding_str);\
209 panel_bg_padding = min(min(panel_size_x, panel_size_y)/2 - 5, panel_bg_padding);
211 // Point to the macros above (stupid max macro length)
212 #define HUD_Panel_GetStringVars()\
214 if (panel_bg != "0") {\
215 HUD_Panel_GetColorTeam()\
216 HUD_Panel_GetColor()\
217 HUD_Panel_GetBgAlpha()\
218 HUD_Panel_GetBorder()\
220 HUD_Panel_GetFgAlpha()\
221 HUD_Panel_GetScaledVectors()\
222 HUD_Panel_GetPadding()
224 // return smoothly faded pos of given panel when a dialog is active
225 var vector menu_enable_panelpos;
226 #define HUD_Panel_GetMenuPos() \
227 if(panel_size_x > panel_size_y)\
228 menu_enable_panelpos = eX * 0.5 * vid_conwidth - eX * 0.5 * panel_size_x + eY * 0.82 * vid_conheight;\
230 menu_enable_panelpos = eY * 0.5 * vid_conheight - eY * 0.5 * panel_size_y + eX * 0.7 * vid_conwidth;\
231 panel_pos = (1 - autocvar__menu_alpha) * panel_pos + (autocvar__menu_alpha) * menu_enable_panelpos;
233 // return smoothly faded size of given panel when a dialog is active
234 var vector menu_enable_maxsize; FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(menu_enable_maxsize);
235 var vector menu_enable_size;
236 #define HUD_Panel_GetMenuSize()\
237 menu_enable_maxsize_x = 0.3 * vid_conwidth;\
238 menu_enable_maxsize_y = 0.18 * vid_conheight;\
239 if(panel_size_x > panel_size_y)\
241 if(panel_size_y > menu_enable_maxsize_y)\
243 menu_enable_size_y = menu_enable_maxsize_y;\
244 menu_enable_size_x = panel_size_x * (menu_enable_maxsize_y/panel_size_y);\
245 panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
250 if(panel_size_x > menu_enable_maxsize_x)\
252 menu_enable_size_x = menu_enable_maxsize_x;\
253 menu_enable_size_y = panel_size_y * (menu_enable_maxsize_x/panel_size_x);\
254 panel_size = (1 - autocvar__menu_alpha) * panel_size + (autocvar__menu_alpha) * menu_enable_size;\
258 // Update all common cvars of given panel name
259 #define HUD_Panel_UpdateCvars(name) \
260 panel_enabled = autocvar_hud_panel_##name; \
261 panel_pos = stov(cvar_string("hud_panel_" #name "_pos")); \
262 panel_size = stov(cvar_string("hud_panel_" #name "_size")); \
263 panel_bg_str = cvar_string("hud_panel_" #name "_bg"); \
264 panel_bg_color_str = cvar_string("hud_panel_" #name "_bg_color"); \
265 panel_bg_color_team_str = cvar_string("hud_panel_" #name "_bg_color_team"); \
266 panel_bg_alpha_str = cvar_string("hud_panel_" #name "_bg_alpha"); \
267 panel_bg_border_str = cvar_string("hud_panel_" #name "_bg_border"); \
268 panel_bg_padding_str = cvar_string("hud_panel_" #name "_bg_padding"); \
269 HUD_Panel_GetStringVars()\
270 if(menu_enabled == 2 && active_panel == highlightedPanel) {\
271 HUD_Panel_GetMenuSize()\
272 HUD_Panel_GetMenuPos()\
273 } ENDS_WITH_CURLY_BRACE
275 // Update all common cvars of given panel id
276 #define HUD_Panel_UpdateCvarsForId_Part2(id) \
278 case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
279 case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
282 #define HUD_Panel_UpdateCvarsForId(id) \
284 case HUD_PANEL_WEAPONS: HUD_Panel_UpdateCvars(weapons) break; \
285 case HUD_PANEL_AMMO: HUD_Panel_UpdateCvars(ammo) break; \
286 case HUD_PANEL_POWERUPS: HUD_Panel_UpdateCvars(powerups) break; \
287 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdateCvars(healtharmor) break; \
288 case HUD_PANEL_NOTIFY: HUD_Panel_UpdateCvars(notify) break; \
289 case HUD_PANEL_TIMER: HUD_Panel_UpdateCvars(timer) break; \
290 case HUD_PANEL_RADAR: HUD_Panel_UpdateCvars(radar) break; \
291 case HUD_PANEL_SCORE: HUD_Panel_UpdateCvars(score) break; \
292 case HUD_PANEL_RACETIMER: HUD_Panel_UpdateCvars(racetimer) break; \
293 case HUD_PANEL_VOTE: HUD_Panel_UpdateCvars(vote) break; \
294 case HUD_PANEL_MODICONS: HUD_Panel_UpdateCvars(modicons) break; \
295 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
296 case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
297 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
299 HUD_Panel_UpdateCvarsForId_Part2(id)
301 #define HUD_Panel_UpdatePosSize(name) \
302 panel_pos = stov(cvar_string("hud_panel_" #name "_pos")); \
303 panel_size = stov(cvar_string("hud_panel_" #name "_size")); \
304 HUD_Panel_GetScaledVectors()\
305 if(menu_enabled == 2 && active_panel == highlightedPanel) {\
306 HUD_Panel_GetMenuSize()\
307 HUD_Panel_GetMenuPos()\
309 panel_bg_border_str = cvar_string("hud_panel_" #name "_bg_border"); \
310 HUD_Panel_GetBorder()
312 // Update pos and size of given panel id
313 #define HUD_Panel_UpdatePosSizeForId_Part2(id) \
315 case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
316 case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
318 #define HUD_Panel_UpdatePosSizeForId(id) \
320 case HUD_PANEL_WEAPONS: HUD_Panel_UpdatePosSize(weapons) break;\
321 case HUD_PANEL_AMMO: HUD_Panel_UpdatePosSize(ammo) break;\
322 case HUD_PANEL_POWERUPS: HUD_Panel_UpdatePosSize(powerups) break;\
323 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdatePosSize(healtharmor) break;\
324 case HUD_PANEL_NOTIFY: HUD_Panel_UpdatePosSize(notify) break;\
325 case HUD_PANEL_TIMER: HUD_Panel_UpdatePosSize(timer) break;\
326 case HUD_PANEL_RADAR: HUD_Panel_UpdatePosSize(radar) break;\
327 case HUD_PANEL_SCORE: HUD_Panel_UpdatePosSize(score) break;\
328 case HUD_PANEL_RACETIMER: HUD_Panel_UpdatePosSize(racetimer) break;\
329 case HUD_PANEL_VOTE: HUD_Panel_UpdatePosSize(vote) break;\
330 case HUD_PANEL_MODICONS: HUD_Panel_UpdatePosSize(modicons) break;\
331 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdatePosSize(pressedkeys) break;\
332 case HUD_PANEL_CHAT: HUD_Panel_UpdatePosSize(chat) break;\
333 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdatePosSize(engineinfo) break;\
335 HUD_Panel_UpdatePosSizeForId_Part2(id)