2 vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
3 vector panel_click_resizeorigin; // coordinates for opposite point when resizing
4 float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
5 float highlightedPanel;
6 float highlightedPanel_prev;
7 float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
9 const float BORDER_MULTIPLIER = 0.25;
10 float hud_color_bg_team;
11 float scoreboard_bottom;
12 float weapon_hits[WEP_MAXCOUNT];
13 float weapon_fired[WEP_MAXCOUNT];
16 float complain_weapon;
17 string complain_weapon_name;
18 float complain_weapon_type;
19 float complain_weapon_time;
21 float ps_primary, ps_secondary;
22 float ts_primary, ts_secondary;
29 float hud_accuracy_hud;
30 float hud_border_thickness;
31 float hud_accuracy_border_thickness;
33 float hud_configure_checkcollisions;
34 float hud_configure_prev;
37 const float S_SHIFT = 1;
38 const float S_CTRL = 2;
39 const float S_ALT = 4;
41 float disable_menu_alphacheck; // 0 = enable alpha check, 1 = disable for entire hud, 2 = disable for one panel
42 float menu_fade_alpha;
46 var vector progressbar_color;
48 var float active_panel; // this panel has recently referred the UpdateCvars macro
49 var string panel_name;
50 var float panel_enabled;
52 var vector panel_size;
54 var string panel_bg_str; // "_str" vars contain the raw value of the cvar, non-"_str" contains what hud.qc code should use
55 var vector panel_bg_color;
56 var string panel_bg_color_str;
57 var float panel_bg_color_team;
58 var string panel_bg_color_team_str;
59 var float panel_fg_alpha;
60 var float panel_bg_alpha;
61 var string panel_bg_alpha_str;
62 var float panel_bg_border;
63 var string panel_bg_border_str;
64 var float panel_bg_padding;
65 var string panel_bg_padding_str;
66 var float panel_accuracy_yellow;
67 var float panel_accuracy_onlycurrent;
68 var float panel_accuracy_flip;
69 var float panel_accuracy_iconalign;
70 var float panel_accuracy_baralign;
71 var float panel_accuracy_info_top;
72 var float panel_accuracy_foreground_alpha;
73 var float panel_accuracy_alreadyvoted_alpha;
75 // Because calling lots of functions in QC apparently cuts fps in half on many machines:
76 // ----------------------
77 // MACRO HELL STARTS HERE
78 // ----------------------
79 // Little help for the poor people who have to make sense of this: Start from the bottom
81 #define HUD_Panel_GetProgressBarColor(item) \
83 case "strength": progressbar_color = autocvar_hud_progressbar_strength_color; break;\
84 case "shield": progressbar_color = autocvar_hud_progressbar_shield_color; break;\
85 case "health": progressbar_color = autocvar_hud_progressbar_health_color; break;\
86 case "armor": progressbar_color = autocvar_hud_progressbar_armor_color; break;\
87 case "fuel": progressbar_color = autocvar_hud_progressbar_fuel_color; break;\
88 case "nexball": progressbar_color = autocvar_hud_progressbar_nexball_color; break;\
91 // Get value for panel_bg: if "" fetch default, else use panel_bg_str
92 // comment on last line of macro: // we probably want to see a background in config mode at all times...
93 #define HUD_Panel_GetBg()\
94 if(!autocvar__hud_configure && panel_bg_str == "0") {\
97 if(panel_bg_str == "") {\
98 panel_bg = autocvar_hud_bg;\
99 } else if(panel_bg_str == "0" && autocvar__hud_configure) {\
100 panel_bg = "border";\
102 panel_bg = panel_bg_str;\
106 // Get value for panel_bg_color: if "" fetch default, else use panel_bg_color. Convert pants, shirt or teamcolor into a vector.
107 #define HUD_Panel_GetColor()\
108 if(panel_bg_color_str == "") {\
109 panel_bg_color = autocvar_hud_bg_color;\
110 } if(teamplay && panel_bg_color_team) {\
111 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1) * panel_bg_color_team;\
113 if(panel_bg_color_str == "shirt") {\
114 panel_bg_color = colormapPaletteColor(floor(stof(getplayerkey(player_localentnum - 1, "colors")) / 16), 0);\
115 } else if(panel_bg_color_str == "pants") {\
116 panel_bg_color = colormapPaletteColor(mod(stof(getplayerkey(player_localentnum - 1, "colors")), 16), 1);\
120 // Get value for panel_bg_color_team: if "" fetch default, else use panel_bg_color_team_str
121 #define HUD_Panel_GetColorTeam()\
122 if(panel_bg_color_team_str == "") {\
123 panel_bg_color_team = autocvar_hud_bg_color_team;\
125 panel_bg_color_team = stof(panel_bg_color_team_str);\
128 // 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
129 // comment on line 3 of macro: // do not set a minalpha cap when showing the config dialog for this panel
130 #define HUD_Panel_GetBgAlpha()\
131 if(panel_bg_alpha_str == "") {\
132 panel_bg_alpha_str = ftos(autocvar_hud_bg_alpha);\
134 panel_bg_alpha = stof(panel_bg_alpha_str);\
135 if(autocvar__hud_configure && disable_menu_alphacheck == 2 && highlightedPanel == active_panel) {\
136 panel_bg_alpha = (1 - autocvar__menu_alpha) * max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha) + autocvar__menu_alpha * panel_bg_alpha;\
137 } else if(autocvar__hud_configure) {\
138 panel_bg_alpha = max(autocvar_hud_configure_bg_minalpha, panel_bg_alpha);\
139 } if(autocvar__hud_configure && !panel_enabled) {\
140 panel_bg_alpha = 0.25;\
141 } if(!(disable_menu_alphacheck == 2 && highlightedPanel == active_panel)) {\
142 panel_bg_alpha *= menu_fade_alpha;\
145 // Get value for panel_fg_alpha. Also do various minalpha checks
146 // comment on line 2 of macro: // ALWAYS show disabled panels at 0.25 alpha when in config mode
147 // comment on line 4 of macro: // don't fade this panel when showing the panel-specific menu dialog
148 #define HUD_Panel_GetFgAlpha()\
149 panel_fg_alpha = autocvar_hud_fg_alpha;\
150 if(autocvar__hud_configure && !panel_enabled)\
151 panel_fg_alpha = 0.25;\
152 if(!(disable_menu_alphacheck == 2 && highlightedPanel == active_panel))\
153 panel_fg_alpha *= menu_fade_alpha;
155 // Get border. See comments above, it's similar.
156 #define HUD_Panel_GetBorder()\
157 if(panel_bg_border_str == "") {\
158 panel_bg_border = autocvar_hud_bg_border;\
160 panel_bg_border = stof(panel_bg_border_str);\
163 // Scale the pos and size vectors to absolute coordinates
164 #define HUD_Panel_GetScaledVectors()\
165 panel_pos_x *= vid_conwidth;\
166 panel_pos_y *= vid_conheight;\
167 panel_size_x *= vid_conwidth;\
168 panel_size_y *= vid_conheight;
170 // Get padding. See comments above, it's similar.
171 // 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
172 #define HUD_Panel_GetPadding()\
173 if(panel_bg_padding_str == "") {\
174 panel_bg_padding = autocvar_hud_bg_padding;\
176 panel_bg_padding = stof(panel_bg_padding_str);\
178 panel_bg_padding = min(min(panel_size_x, panel_size_y)/2 - 5, panel_bg_padding);
180 // Point to the macros above (stupid max macro length)
181 #define HUD_Panel_StringVars()\
183 HUD_Panel_GetColorTeam()\
184 HUD_Panel_GetColor()\
185 HUD_Panel_GetBgAlpha()\
186 HUD_Panel_GetFgAlpha()\
187 HUD_Panel_GetBorder()\
188 HUD_Panel_GetScaledVectors()\
189 HUD_Panel_GetPadding()
191 // Update all common cvars of given panel name
192 #define HUD_Panel_UpdateCvars(name) \
193 panel_enabled = autocvar_hud_##name; \
194 panel_pos = autocvar_hud_##name##_pos; \
195 panel_size = autocvar_hud_##name##_size; \
196 panel_bg_str = autocvar_hud_##name##_bg; \
197 panel_bg_color_str = autocvar_hud_##name##_bg_color; \
198 panel_bg_color_team_str = autocvar_hud_##name##_bg_color_team; \
199 panel_bg_alpha_str = autocvar_hud_##name##_bg_alpha; \
200 panel_bg_border_str = autocvar_hud_##name##_bg_border; \
201 panel_bg_padding_str = autocvar_hud_##name##_bg_padding; \
202 HUD_Panel_StringVars()
204 // Update all common cvars of given panel id
205 #define HUD_Panel_UpdateCvarsForId(id) \
208 case HUD_PANEL_WEAPONICONS: HUD_Panel_UpdateCvars(weaponicons) break; \
209 case HUD_PANEL_INVENTORY: HUD_Panel_UpdateCvars(inventory) break; \
210 case HUD_PANEL_POWERUPS: HUD_Panel_UpdateCvars(powerups) break; \
211 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdateCvars(healtharmor) break; \
212 case HUD_PANEL_NOTIFY: HUD_Panel_UpdateCvars(notify) break; \
213 case HUD_PANEL_TIMER: HUD_Panel_UpdateCvars(timer) break; \
214 case HUD_PANEL_RADAR: HUD_Panel_UpdateCvars(radar) break; \
215 case HUD_PANEL_SCORE: HUD_Panel_UpdateCvars(score) break; \
216 case HUD_PANEL_RACETIMER: HUD_Panel_UpdateCvars(racetimer) break; \
217 case HUD_PANEL_VOTE: HUD_Panel_UpdateCvars(vote) break; \
218 case HUD_PANEL_MODICONS: HUD_Panel_UpdateCvars(modicons) break; \
219 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
220 case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
221 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
224 #define HUD_Panel_UpdatePosSize(name) \
225 panel_pos = autocvar_hud_##name##_pos; \
226 panel_size = autocvar_hud_##name##_size; \
227 HUD_Panel_GetScaledVectors()
229 // Update pos and size of given panel id
230 #define HUD_Panel_UpdatePosSizeForId(id) \
232 case HUD_PANEL_WEAPONICONS: HUD_Panel_UpdatePosSize(weaponicons) break; \
233 case HUD_PANEL_INVENTORY: HUD_Panel_UpdatePosSize(inventory) break; \
234 case HUD_PANEL_POWERUPS: HUD_Panel_UpdatePosSize(powerups) break; \
235 case HUD_PANEL_HEALTHARMOR: HUD_Panel_UpdatePosSize(healtharmor) break; \
236 case HUD_PANEL_NOTIFY: HUD_Panel_UpdatePosSize(notify) break; \
237 case HUD_PANEL_TIMER: HUD_Panel_UpdatePosSize(timer) break; \
238 case HUD_PANEL_RADAR: HUD_Panel_UpdatePosSize(radar) break; \
239 case HUD_PANEL_SCORE: HUD_Panel_UpdatePosSize(score) break; \
240 case HUD_PANEL_RACETIMER: HUD_Panel_UpdatePosSize(racetimer) break; \
241 case HUD_PANEL_VOTE: HUD_Panel_UpdatePosSize(vote) break; \
242 case HUD_PANEL_MODICONS: HUD_Panel_UpdatePosSize(modicons) break; \
243 case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdatePosSize(pressedkeys) break; \
244 case HUD_PANEL_CHAT: HUD_Panel_UpdatePosSize(chat) break; \
245 case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdatePosSize(engineinfo) break; \