3 #include <client/draw.qh>
4 #include <client/items/items.qh>
5 #include <client/view.qh>
6 #include "panel/scoreboard.qh"
7 #include "hud_config.qh"
8 #include "../mapvoting.qh"
9 #include "../teamradar.qh"
10 #include <common/minigames/cl_minigames.qh>
11 #include <common/deathtypes/all.qh>
12 #include <common/ent_cs.qh>
13 #include <common/items/_mod.qh>
14 #include <common/mapinfo.qh>
15 #include <common/vehicles/all.qh>
16 #include <common/vehicles/vehicle/bumblebee.qh>
17 #include <common/mutators/mutator/waypoints/all.qh>
18 #include <common/stats.qh>
19 #include <lib/csqcmodel/cl_player.qh>
20 #include <lib/csqcmodel/cl_model.qh>
21 #include <common/gamemodes/_mod.qh>
30 void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
32 ofs = vec2(ofs.x * SIZE_CURSOR.x, ofs.y * SIZE_CURSOR.y);
33 drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL);
36 void draw_cursor_normal(vector pos, vector col, float a)
38 draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a);
41 void LoadMenuSkinValues()
44 if(cvar_string("menu_skin") != "")
46 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
47 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
49 if(fh < 0 && cvar_defstring("menu_skin") != "")
51 cvar_set("menu_skin", cvar_defstring("menu_skin"));
52 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
53 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
57 draw_currentSkin = "gfx/menu/default";
58 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
61 draw_currentSkin = strzone(draw_currentSkin);
66 while((s = fgets(fh)))
68 int n = tokenize_console(s);
71 if(substring(argv(0), 0, 2) == "//")
73 if(argv(0) == "SIZE_CURSOR")
74 SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
75 else if(argv(0) == "OFFSET_CURSOR")
76 OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
82 void HUD_Scale_Disable()
86 drawfontscale = hud_scale;
89 void HUD_Scale_Enable()
91 hud_scale = hud_scale_current;
92 hud_shift = hud_shift_current;
93 drawfontscale = hud_scale;
96 vector HUD_Scale(vector v)
98 v.x = HUD_ScaleX(v.x);
99 v.y = HUD_ScaleY(v.y);
103 vector HUD_Shift(vector v)
105 v.x = HUD_ShiftX(v.x);
106 v.y = HUD_ShiftY(v.y);
110 vector HUD_GetFontsize(string cvarname)
113 v = stov(cvar_string(cvarname));
122 vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
124 const vector COLOR100 = '0 1 0'; // green
125 const vector COLOR75 = '0.4 0.9 0'; // lightgreen
126 const vector COLOR50 = '1 1 1'; // white
127 const vector COLOR25 = '1 1 0.2'; // lightyellow
128 const vector COLOR10 = '1 0 0'; // red
131 float hp_percent = hp / maxvalue * 100;
132 #define CASE_COLOR_BETWEEN(min, max) \
133 if(hp_percent > min) \
134 color = COLOR##min + (COLOR##max - COLOR##min) * ((hp_percent - min) / (max - min))
136 if(hp_percent > 100) color = COLOR100;
137 else CASE_COLOR_BETWEEN(75, 100);
138 else CASE_COLOR_BETWEEN(50, 75);
139 else CASE_COLOR_BETWEEN(25, 50);
140 else CASE_COLOR_BETWEEN(10, 25);
141 else color = COLOR10;
143 #undef CASE_COLOR_BETWEEN
147 if(hp_percent >= 100)
149 float f = sin(2*M_PI*time);
150 if (color.x == 0) color.x = f;
151 if (color.y == 0) color.y = f;
152 if (color.z == 0) color.z = f;
154 else if(hp_percent < 25)
156 float f = (1 - hp_percent / 25) * sin(2*M_PI*time);
164 float HUD_GetRowCount(int item_count, vector size, float item_aspect)
167 float aspect = size_y / size_x;
168 return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
171 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
175 float ratio, best_ratio = 0;
176 float best_columns = 1, best_rows = 1;
177 bool vertical = (psize.x / psize.y >= item_aspect);
180 psize = eX * psize.y + eY * psize.x;
181 item_aspect = 1 / item_aspect;
184 rows = ceil(sqrt(item_count));
185 columns = ceil(item_count/rows);
188 ratio = (psize.x/columns) / (psize.y/rows);
189 if(ratio > item_aspect)
190 ratio = item_aspect * item_aspect / ratio;
192 if(ratio <= best_ratio)
193 break; // ratio starts decreasing by now, skip next configurations
195 best_columns = columns;
203 rows = ceil(item_count/columns);
206 return (vertical) ? vec2(best_rows, best_columns) : vec2(best_columns, best_rows);
215 void HUD_Panel_LoadCvars()
217 // NOTE: in hud_configure mode cvars must be reloaded every frame
218 if (panel.update_time <= time)
220 panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos")));
221 panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size")));
222 HUD_Panel_ScalePosSize();
223 panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg"));
224 panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color"));
225 panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team"));
226 panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha"));
227 panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border"));
228 panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding"));
230 if (panel.current_panel_bg != "0")
232 HUD_Panel_GetBgAlpha();
233 HUD_Panel_GetBorder();
235 HUD_Panel_GetColorTeam();
236 HUD_Panel_GetColor();
237 HUD_Panel_GetFgAlpha();
238 HUD_Panel_GetPadding();
239 panel.current_panel_bg_alpha = panel_bg_alpha;
240 panel.current_panel_fg_alpha = panel_fg_alpha;
241 if (hud_configure_menu_open == 2 && panel == highlightedPanel)
242 HUD_Panel_UpdatePosSize_ForMenu();
245 panel_bg_alpha *= hud_fade_alpha * panel_fade_alpha;
246 panel_fg_alpha *= hud_fade_alpha * panel_fade_alpha;
248 panel.current_panel_pos = panel_pos;
249 panel.current_panel_size = panel_size;
250 panel.current_panel_bg_border = panel_bg_border;
251 panel.current_panel_bg_color = panel_bg_color;
252 panel.current_panel_bg_color_team = panel_bg_color_team;
253 panel.current_panel_bg_padding = panel_bg_padding;
254 panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval;
258 panel_pos = panel.current_panel_pos;
259 panel_size = panel.current_panel_size;
260 panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha * panel_fade_alpha;
261 panel_bg_border = panel.current_panel_bg_border;
262 panel_bg_color = panel.current_panel_bg_color;
263 panel_bg_color_team = panel.current_panel_bg_color_team;
264 panel_bg_padding = panel.current_panel_bg_padding;
265 panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha * panel_fade_alpha;
268 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
269 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
271 TC(bool, vertical); TC(int, drawflag);
272 if(!length_ratio || !theAlpha)
278 if(length_ratio < -1)
281 else if(length_ratio < 0)
284 theOrigin = HUD_Shift(theOrigin);
285 theSize = HUD_Scale(theSize);
288 vector width, height;
290 pic = strcat(hud_skin_path, "/", pic, "_vertical");
291 if(precache_pic(pic) == "") {
292 pic = "gfx/hud/default/progressbar_vertical";
295 if (baralign == 1) // bottom align
296 theOrigin.y += (1 - length_ratio) * theSize.y;
297 else if (baralign == 2) // center align
298 theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
299 else if (baralign == 3) // center align, positive values down, negative up
302 if (length_ratio > 0)
303 theOrigin.y += theSize.y;
306 theOrigin.y += (1 + length_ratio) * theSize.y;
307 length_ratio = -length_ratio;
310 theSize.y *= length_ratio;
313 width = eX * theSize.x;
314 height = eY * theSize.y;
315 if(theSize.y <= theSize.x * 2)
317 // button not high enough
318 // draw just upper and lower part then
319 square = eY * theSize.y * 0.5;
320 bH = eY * (0.25 * theSize.y / (theSize.x * 2));
321 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
322 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
326 square = eY * theSize.x;
327 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
328 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
329 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
332 pic = strcat(hud_skin_path, "/", pic);
333 if(precache_pic(pic) == "") {
334 pic = "gfx/hud/default/progressbar";
337 if (baralign == 1) // right align
338 theOrigin.x += (1 - length_ratio) * theSize.x;
339 else if (baralign == 2) // center align
340 theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
341 else if (baralign == 3) // center align, positive values on the right, negative on the left
344 if (length_ratio > 0)
345 theOrigin.x += theSize.x;
348 theOrigin.x += (1 + length_ratio) * theSize.x;
349 length_ratio = -length_ratio;
352 theSize.x *= length_ratio;
355 width = eX * theSize.x;
356 height = eY * theSize.y;
357 if(theSize.x <= theSize.y * 2)
359 // button not wide enough
360 // draw just left and right part then
361 square = eX * theSize.x * 0.5;
362 bW = eX * (0.25 * theSize.x / (theSize.y * 2));
363 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
364 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
368 square = eX * theSize.y;
369 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
370 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
371 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
376 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
382 pos = HUD_Shift(pos);
383 mySize = HUD_Scale(mySize);
386 pic = strcat(hud_skin_path, "/num_leading");
387 if(precache_pic(pic) == "") {
388 pic = "gfx/hud/default/num_leading";
391 drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
392 if(mySize.x/mySize.y > 2)
393 drawsubpic(pos + eX * mySize.y, eX * (mySize.x - 2 * mySize.y) + eY * mySize.y, pic, '0.25 0 0', '0.5 1 0', color, theAlpha, drawflag);
394 drawsubpic(pos + eX * mySize.x - eX * min(mySize.x * 0.5, mySize.y), eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0.75 0 0', '0.25 1 0', color, theAlpha, drawflag);
397 void DrawNumIcon_expanding(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
399 TC(bool, vertical); TC(int, icon_right_align);
400 vector newPos = '0 0 0', newSize = '0 0 0';
401 vector picpos, numpos;
405 if(mySize.y/mySize.x > 2)
407 newSize.y = 2 * mySize.x;
408 newSize.x = mySize.x;
410 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
415 newSize.x = 1/2 * mySize.y;
416 newSize.y = mySize.y;
418 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
425 picpos = newPos + eY * newSize.x;
430 numpos = newPos + eY * newSize.x;
434 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
435 // make number smaller than icon, it looks better
436 // reduce only y to draw numbers with different number of digits with the same y size
437 numpos.y += newSize.y * ((1 - 0.7) / 2);
439 drawstring_aspect(numpos, ftos(theTime), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
443 if(mySize.x/mySize.y > 3)
445 newSize.x = 3 * mySize.y;
446 newSize.y = mySize.y;
448 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
453 newSize.y = 1/3 * mySize.x;
454 newSize.x = mySize.x;
456 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
460 if(icon_right_align) // right align
463 picpos = newPos + eX * 2 * newSize.y;
467 numpos = newPos + eX * newSize.y;
471 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
472 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
473 drawstring_aspect_expanding(numpos, ftos(theTime), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
474 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
477 void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha)
479 TC(bool, vertical); TC(int, icon_right_align);
480 DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, icon_right_align, color, theAlpha, 0);
490 float vh_notice_time;
493 if(autocvar__hud_configure) return;
494 if(intermission == 2) return;
496 if(hud == HUD_BUMBLEBEE_GUN)
497 CSQC_BUMBLE_GUN_HUD();
499 Vehicle info = REGISTRY_GET(Vehicles, hud);
503 if(hud != HUD_NORMAL && lasthud == HUD_NORMAL)
504 vh_notice_time = time + autocvar_cl_vehicles_notify_time;
509 void HUD_Panel_Draw(entity panent)
512 if (autocvar__hud_configure)
514 if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
516 panel_fade_alpha = 1;
517 Hud_Panel_GetPanelEnabled();
522 bool draw_allowed = false;
523 if (scoreboard_fade_alpha && panel.panel_showflags & PANEL_SHOW_WITH_SB)
527 else if (active_minigame && HUD_MinigameMenu_IsOpened())
529 if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
532 else if(intermission == 2)
534 if(panel.panel_showflags & PANEL_SHOW_MAPVOTE)
537 else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
542 if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
544 if (scoreboard_fade_alpha && intermission == 2 && !(panel.panel_showflags & PANEL_SHOW_MAPVOTE))
545 panel_fade_alpha = scoreboard_fade_alpha;
547 panel_fade_alpha = 1;
551 panel_fade_alpha = 1 - scoreboard_fade_alpha;
552 if(!panel_fade_alpha)
561 // reset gametype specific icons
562 if(gametype.m_modicons_reset)
563 gametype.m_modicons_reset();
566 float autocvar_hud_dynamic_shake = 1;
567 float autocvar_hud_dynamic_shake_damage_max = 130;
568 float autocvar_hud_dynamic_shake_damage_min = 10;
569 float autocvar_hud_dynamic_shake_scale = 0.2;
570 float hud_dynamic_shake_x[10] = {0, 1, -0.7, 0.5, -0.3, 0.2, -0.1, 0.1, 0.0, 0};
571 float hud_dynamic_shake_y[10] = {0, 0.4, 0.8, -0.2, -0.6, 0.0, 0.3, 0.1, -0.1, 0};
572 bool Hud_Shake_Update()
574 if(time - hud_dynamic_shake_time < 0)
577 float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
578 float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
579 int i = floor(elapsed_time);
583 float f = elapsed_time - i;
584 hud_dynamic_shake_realofs.x = (1 - f) * hud_dynamic_shake_x[i] + f * hud_dynamic_shake_x[i+1];
585 hud_dynamic_shake_realofs.y = (1 - f) * hud_dynamic_shake_y[i] + f * hud_dynamic_shake_y[i+1];
586 hud_dynamic_shake_realofs.z = 0;
587 hud_dynamic_shake_realofs *= hud_dynamic_shake_factor * autocvar_hud_dynamic_shake_scale;
588 hud_dynamic_shake_realofs.x = bound(-0.1, hud_dynamic_shake_realofs.x, 0.1) * vid_conwidth;
589 hud_dynamic_shake_realofs.y = bound(-0.1, hud_dynamic_shake_realofs.y, 0.1) * vid_conheight;
593 void Hud_Dynamic_Frame()
595 vector ofs = '0 0 0';
596 hud_scale_current = '1 1 0';
597 hud_shift_current = '0 0 0';
599 if (autocvar_hud_dynamic_follow)
601 entity view = CSQCModel_server2csqc(player_localentnum - 1);
602 calc_followmodel_ofs(view);
603 ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
604 ofs.x *= autocvar_hud_dynamic_follow_scale_xyz.z;
605 ofs.y *= autocvar_hud_dynamic_follow_scale_xyz.x;
606 ofs.z *= autocvar_hud_dynamic_follow_scale_xyz.y;
608 if (fabs(ofs.x) < 0.001) ofs.x = 0;
609 if (fabs(ofs.y) < 0.001) ofs.y = 0;
610 if (fabs(ofs.z) < 0.001) ofs.z = 0;
611 ofs.x = bound(-0.1, ofs.x, 0.1);
612 ofs.y = bound(-0.1, ofs.y, 0.1);
613 ofs.z = bound(-0.1, ofs.z, 0.1);
615 hud_shift_current.x = ofs.y * vid_conwidth;
616 hud_shift_current.y = ofs.z * vid_conheight;
617 hud_shift_current.z = ofs.x;
619 hud_scale_current.x = (1 + hud_shift_current.z);
620 hud_scale_current.y = hud_scale_current.x;
623 if(autocvar_hud_dynamic_shake > 0)
625 static float old_health = 0;
626 float health = max(-1, STAT(HEALTH));
627 if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
629 hud_dynamic_shake_factor = 0;
634 float new_hud_dynamic_shake_factor = 0;
635 if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
636 && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
637 && old_health > 0 && !intermission)
639 float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
640 new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
641 if(new_hud_dynamic_shake_factor >= 1)
642 new_hud_dynamic_shake_factor = 1;
643 if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
645 hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
646 hud_dynamic_shake_time = time;
650 if(hud_dynamic_shake_factor)
651 if(!Hud_Shake_Update())
652 hud_dynamic_shake_factor = 0;
655 if(hud_dynamic_shake_factor > 0)
657 hud_shift_current.x += hud_dynamic_shake_realofs.x;
658 hud_shift_current.y += hud_dynamic_shake_realofs.y;
662 hud_scale_center.x = 0.5 * vid_conwidth;
663 hud_scale_center.y = 0.5 * vid_conheight;
668 bool HUD_WouldShowCursor()
670 if(autocvar__hud_configure)
674 //entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
675 //if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
677 if(HUD_Radar_Clickable())
679 if(HUD_MinigameMenu_IsOpened())
681 if(QuickMenu_IsOpened())
690 if(hud_configure_menu_open == 1)
693 hud_fade_alpha = 1 - autocvar__menu_alpha;
695 if(myteam != prev_myteam)
697 myteamcolors = colormapPaletteColor(myteam, 1);
698 FOREACH(hud_panels, true, it.update_time = time);
699 prev_myteam = myteam;
702 HUD_Configure_Frame();
704 if(scoreboard_fade_alpha == 1)
705 if(autocvar__menu_alpha == 1)
709 if (hud_skin_prev != autocvar_hud_skin)
711 strcpy(hud_skin_path, strcat("gfx/hud/", autocvar_hud_skin));
712 strcpy(hud_skin_prev, autocvar_hud_skin);
716 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
720 float hud_dock_color_team = autocvar_hud_dock_color_team;
721 if((teamplay) && hud_dock_color_team) {
722 if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
723 color = '1 0 0' * hud_dock_color_team;
725 color = myteamcolors * hud_dock_color_team;
727 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
728 color = '1 0 0' * hud_dock_color_team;
732 string hud_dock_color = autocvar_hud_dock_color;
733 if(hud_dock_color == "shirt") {
734 f = entcs_GetClientColors(current_player);
735 color = colormapPaletteColor(floor(f / 16), 0);
737 else if(hud_dock_color == "pants") {
738 f = entcs_GetClientColors(current_player);
739 color = colormapPaletteColor(f % 16, 1);
742 color = stov(hud_dock_color);
746 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
747 if(precache_pic(pic) == "") {
748 pic = strcat(hud_skin_path, "/dock_medium");
749 if(precache_pic(pic) == "") {
750 pic = "gfx/hud/default/dock_medium";
753 drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
756 // cache the panel order into the panel_order array
757 if(autocvar__hud_panelorder != hud_panelorder_prev) {
758 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
762 bool warning = false;
763 int argc = tokenize_console(autocvar__hud_panelorder);
764 if (argc > REGISTRY_COUNT(hud_panels))
766 //first detect wrong/missing panel numbers
767 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
768 p_num = stoi(argv(i));
769 if (p_num >= 0 && p_num < REGISTRY_COUNT(hud_panels)) { //correct panel number?
770 if (panel_order[p_num] == -1) //found for the first time?
771 s = strcat(s, ftos(p_num), " ");
772 panel_order[p_num] = 1; //mark as found
777 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
778 if (panel_order[i] == -1) {
780 s = strcat(s, ftos(i), " "); //add missing panel number
784 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
786 cvar_set("_hud_panelorder", s);
787 strcpy(hud_panelorder_prev, s);
789 //now properly set panel_order
791 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
792 panel_order[i] = stof(argv(i));
796 hud_draw_maximized = 0;
797 // draw panels in the order specified by panel_order array
798 for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
799 HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
803 hud_draw_maximized = 1; // panels that may be maximized must check this var
804 // draw maximized panels on top
805 if(hud_panel_radar_maximized)
806 HUD_Panel_Draw(HUD_PANEL(RADAR));
807 if(autocvar__con_chat_maximized)
808 HUD_Panel_Draw(HUD_PANEL(CHAT));
809 if (QuickMenu_IsOpened())
810 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
811 HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
813 int cursor_active_prev = cursor_active;
814 cursor_active = HUD_WouldShowCursor();
815 if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
817 setcursormode(cursor_active);
818 // cursor inactive this frame, will be set to 1 the next frame
823 if (intermission == 2)
826 HUD_Configure_PostDraw();
828 hud_configure_prev = autocvar__hud_configure;