3 #include <client/draw.qh>
4 #include <client/hud/hud_config.qh>
5 #include <client/hud/panel/chat.qh>
6 #include <client/hud/panel/scoreboard.qh>
7 #include <client/items/items.qh>
8 #include <client/mapvoting.qh>
9 #include <client/teamradar.qh>
10 #include <client/view.qh>
11 #include <common/deathtypes/all.qh>
12 #include <common/ent_cs.qh>
13 #include <common/gamemodes/_mod.qh>
14 #include <common/items/_mod.qh>
15 #include <common/mapinfo.qh>
16 #include <common/minigames/cl_minigames.qh>
17 #include <common/mutators/mutator/waypoints/all.qh>
18 #include <common/stats.qh>
19 #include <common/vehicles/all.qh>
20 #include <common/vehicles/vehicle/bumblebee.qh>
21 #include <lib/csqcmodel/cl_model.qh>
22 #include <lib/csqcmodel/cl_player.qh>
31 void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
33 ofs = vec2(ofs.x * SIZE_CURSOR.x, ofs.y * SIZE_CURSOR.y);
34 drawpic(pos - ofs, strcat(draw_currentSkin, img), SIZE_CURSOR, col, a, DRAWFLAG_NORMAL);
37 void draw_cursor_normal(vector pos, vector col, float a)
39 draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a);
42 void LoadMenuSkinValues()
45 if(cvar_string("menu_skin") != "")
47 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
48 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
50 if(fh < 0 && cvar_defstring("menu_skin") != "")
52 cvar_set("menu_skin", cvar_defstring("menu_skin"));
53 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
54 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
58 draw_currentSkin = "gfx/menu/default";
59 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
62 draw_currentSkin = strzone(draw_currentSkin);
67 while((s = fgets(fh)))
69 int n = tokenize_console(s);
72 if(substring(argv(0), 0, 2) == "//")
74 if(argv(0) == "SIZE_CURSOR")
75 SIZE_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
76 else if(argv(0) == "OFFSET_CURSOR")
77 OFFSET_CURSOR = stov(substring(s, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
83 void HUD_Scale_Disable()
87 drawfontscale = hud_scale;
90 void HUD_Scale_Enable()
92 hud_scale = hud_scale_current;
93 hud_shift = hud_shift_current;
94 drawfontscale = hud_scale;
97 vector HUD_Scale(vector v)
99 v.x = HUD_ScaleX(v.x);
100 v.y = HUD_ScaleY(v.y);
104 vector HUD_Shift(vector v)
106 v.x = HUD_ShiftX(v.x);
107 v.y = HUD_ShiftY(v.y);
111 vector HUD_GetFontsize(string cvarname)
114 v = stov(cvar_string(cvarname));
123 vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
125 const vector COLOR100 = '0 1 0'; // green
126 const vector COLOR75 = '0.4 0.9 0'; // lightgreen
127 const vector COLOR50 = '1 1 1'; // white
128 const vector COLOR25 = '1 1 0.2'; // lightyellow
129 const vector COLOR10 = '1 0 0'; // red
132 float hp_percent = hp / maxvalue * 100;
133 #define CASE_COLOR_BETWEEN(min, max) \
134 if(hp_percent > min) \
135 color = COLOR##min + (COLOR##max - COLOR##min) * ((hp_percent - min) / (max - min))
137 if(hp_percent > 100) color = COLOR100;
138 else CASE_COLOR_BETWEEN(75, 100);
139 else CASE_COLOR_BETWEEN(50, 75);
140 else CASE_COLOR_BETWEEN(25, 50);
141 else CASE_COLOR_BETWEEN(10, 25);
142 else color = COLOR10;
144 #undef CASE_COLOR_BETWEEN
148 if(hp_percent >= 100)
150 float f = sin(2*M_PI*time);
151 if (color.x == 0) color.x = f;
152 if (color.y == 0) color.y = f;
153 if (color.z == 0) color.z = f;
155 else if(hp_percent < 25)
157 float f = (1 - hp_percent / 25) * sin(2*M_PI*time);
165 float HUD_GetRowCount(int item_count, vector size, float item_aspect)
168 float aspect = size_y / size_x;
169 return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
172 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
176 float ratio, best_ratio = 0;
177 float best_columns = 1, best_rows = 1;
178 bool vertical = (psize.x / psize.y >= item_aspect);
181 psize = eX * psize.y + eY * psize.x;
182 item_aspect = 1 / item_aspect;
185 rows = ceil(sqrt(item_count));
186 columns = ceil(item_count/rows);
189 ratio = (psize.x/columns) / (psize.y/rows);
190 if(ratio > item_aspect)
191 ratio = item_aspect * item_aspect / ratio;
193 if(ratio <= best_ratio)
194 break; // ratio starts decreasing by now, skip next configurations
196 best_columns = columns;
204 rows = ceil(item_count/columns);
207 return (vertical) ? vec2(best_rows, best_columns) : vec2(best_columns, best_rows);
216 void HUD_Panel_LoadCvars()
218 // NOTE: in hud_configure mode cvars must be reloaded every frame
219 if (panel.update_time <= time)
221 panel_pos = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_pos")));
222 panel_size = stov(cvar_string(strcat("hud_panel_", panel.panel_name, "_size")));
223 HUD_Panel_ScalePosSize();
224 panel_bg_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg"));
225 panel_bg_color_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color"));
226 panel_bg_color_team_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_color_team"));
227 panel_bg_alpha_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_alpha"));
228 panel_bg_border_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_border"));
229 panel_bg_padding_str = cvar_string(strcat("hud_panel_", panel.panel_name, "_bg_padding"));
231 if (panel.current_panel_bg != "0")
233 HUD_Panel_GetBgAlpha();
234 HUD_Panel_GetBorder();
236 HUD_Panel_GetColorTeam();
237 HUD_Panel_GetColor();
238 HUD_Panel_GetFgAlpha();
239 HUD_Panel_GetPadding();
240 panel.current_panel_bg_alpha = panel_bg_alpha;
241 panel.current_panel_fg_alpha = panel_fg_alpha;
242 if (hud_configure_menu_open == 2 && panel == highlightedPanel)
243 HUD_Panel_UpdatePosSize_ForMenu();
246 panel_bg_alpha *= hud_fade_alpha * panel_fade_alpha;
247 panel_fg_alpha *= hud_fade_alpha * panel_fade_alpha;
249 panel.current_panel_pos = panel_pos;
250 panel.current_panel_size = panel_size;
251 panel.current_panel_bg_border = panel_bg_border;
252 panel.current_panel_bg_color = panel_bg_color;
253 panel.current_panel_bg_color_team = panel_bg_color_team;
254 panel.current_panel_bg_padding = panel_bg_padding;
255 panel.update_time = (autocvar__hud_configure) ? time : time + autocvar_hud_panel_update_interval;
259 panel_pos = panel.current_panel_pos;
260 panel_size = panel.current_panel_size;
261 panel_bg_alpha = panel.current_panel_bg_alpha * hud_fade_alpha * panel_fade_alpha;
262 panel_bg_border = panel.current_panel_bg_border;
263 panel_bg_color = panel.current_panel_bg_color;
264 panel_bg_color_team = panel.current_panel_bg_color_team;
265 panel_bg_padding = panel.current_panel_bg_padding;
266 panel_fg_alpha = panel.current_panel_fg_alpha * hud_fade_alpha * panel_fade_alpha;
269 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
270 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
272 TC(bool, vertical); TC(int, drawflag);
273 if(!length_ratio || !theAlpha)
279 if(length_ratio < -1)
282 else if(length_ratio < 0)
285 theOrigin = HUD_Shift(theOrigin);
286 theSize = HUD_Scale(theSize);
289 vector width, height;
291 pic = strcat(hud_skin_path, "/", pic, "_vertical");
292 if(precache_pic(pic) == "") {
293 pic = "gfx/hud/default/progressbar_vertical";
296 if (baralign == 1) // bottom align
297 theOrigin.y += (1 - length_ratio) * theSize.y;
298 else if (baralign == 2) // center align
299 theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
300 else if (baralign == 3) // center align, positive values down, negative up
303 if (length_ratio > 0)
304 theOrigin.y += theSize.y;
307 theOrigin.y += (1 + length_ratio) * theSize.y;
308 length_ratio = -length_ratio;
311 theSize.y *= length_ratio;
314 width = eX * theSize.x;
315 height = eY * theSize.y;
316 if(theSize.y <= theSize.x * 2)
318 // button not high enough
319 // draw just upper and lower part then
320 square = eY * theSize.y * 0.5;
321 bH = eY * (0.25 * theSize.y / (theSize.x * 2));
322 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
323 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
327 square = eY * theSize.x;
328 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
329 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
330 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
333 pic = strcat(hud_skin_path, "/", pic);
334 if(precache_pic(pic) == "") {
335 pic = "gfx/hud/default/progressbar";
338 if (baralign == 1) // right align
339 theOrigin.x += (1 - length_ratio) * theSize.x;
340 else if (baralign == 2) // center align
341 theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
342 else if (baralign == 3) // center align, positive values on the right, negative on the left
345 if (length_ratio > 0)
346 theOrigin.x += theSize.x;
349 theOrigin.x += (1 + length_ratio) * theSize.x;
350 length_ratio = -length_ratio;
353 theSize.x *= length_ratio;
356 width = eX * theSize.x;
357 height = eY * theSize.y;
358 if(theSize.x <= theSize.y * 2)
360 // button not wide enough
361 // draw just left and right part then
362 square = eX * theSize.x * 0.5;
363 bW = eX * (0.25 * theSize.x / (theSize.y * 2));
364 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
365 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
369 square = eX * theSize.y;
370 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
371 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
372 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
377 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
383 pos = HUD_Shift(pos);
384 mySize = HUD_Scale(mySize);
387 pic = strcat(hud_skin_path, "/num_leading");
388 if(precache_pic(pic) == "") {
389 pic = "gfx/hud/default/num_leading";
392 drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
393 if(mySize.x/mySize.y > 2)
394 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);
395 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);
398 void DrawNumIcon_expanding(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
400 TC(bool, vertical); TC(int, icon_right_align);
401 vector newPos = '0 0 0', newSize = '0 0 0';
402 vector picpos, numpos;
406 if(mySize.y/mySize.x > 2)
408 newSize.y = 2 * mySize.x;
409 newSize.x = mySize.x;
411 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
416 newSize.x = 1/2 * mySize.y;
417 newSize.y = mySize.y;
419 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
426 picpos = newPos + eY * newSize.x;
431 numpos = newPos + eY * newSize.x;
435 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
436 // make number smaller than icon, it looks better
437 // reduce only y to draw numbers with different number of digits with the same y size
438 numpos.y += newSize.y * ((1 - 0.7) / 2);
440 drawstring_aspect(numpos, ftos(theTime), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
444 if(mySize.x/mySize.y > 3)
446 newSize.x = 3 * mySize.y;
447 newSize.y = mySize.y;
449 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
454 newSize.y = 1/3 * mySize.x;
455 newSize.x = mySize.x;
457 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
461 if(icon_right_align) // right align
464 picpos = newPos + eX * 2 * newSize.y;
468 numpos = newPos + eX * newSize.y;
472 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
473 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
474 drawstring_aspect_expanding(numpos, ftos(theTime), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
475 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
478 void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, int icon_right_align, vector color, float theAlpha)
480 TC(bool, vertical); TC(int, icon_right_align);
481 DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, icon_right_align, color, theAlpha, 0);
491 float vh_notice_time;
494 if(autocvar__hud_configure) return;
495 if(intermission == 2) return;
497 if(hud == HUD_BUMBLEBEE_GUN)
498 CSQC_BUMBLE_GUN_HUD();
500 Vehicle info = REGISTRY_GET(Vehicles, hud);
504 if(hud != HUD_NORMAL && lasthud == HUD_NORMAL)
505 vh_notice_time = time + autocvar_cl_vehicles_notify_time;
510 void HUD_Panel_Draw(entity panent)
513 if (autocvar__hud_configure)
515 if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
517 panel_fade_alpha = 1;
518 Hud_Panel_GetPanelEnabled();
523 bool draw_allowed = false;
524 if (scoreboard_fade_alpha && panel.panel_showflags & PANEL_SHOW_WITH_SB)
528 else if (active_minigame && HUD_MinigameMenu_IsOpened())
530 if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
533 else if(intermission == 2)
535 if(panel.panel_showflags & PANEL_SHOW_MAPVOTE)
538 else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
543 if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
545 if (scoreboard_fade_alpha && intermission == 2 && !(panel.panel_showflags & PANEL_SHOW_MAPVOTE))
546 panel_fade_alpha = scoreboard_fade_alpha;
548 panel_fade_alpha = 1;
552 panel_fade_alpha = 1 - scoreboard_fade_alpha;
553 if(!panel_fade_alpha)
562 // reset gametype specific icons
563 if(gametype.m_modicons_reset)
564 gametype.m_modicons_reset();
567 float autocvar_hud_dynamic_shake = 1;
568 float autocvar_hud_dynamic_shake_damage_max = 130;
569 float autocvar_hud_dynamic_shake_damage_min = 10;
570 float autocvar_hud_dynamic_shake_scale = 0.2;
571 float hud_dynamic_shake_x[10] = {0, 1, -0.7, 0.5, -0.3, 0.2, -0.1, 0.1, 0.0, 0};
572 float hud_dynamic_shake_y[10] = {0, 0.4, 0.8, -0.2, -0.6, 0.0, 0.3, 0.1, -0.1, 0};
573 bool Hud_Shake_Update()
575 if(time - hud_dynamic_shake_time < 0)
578 float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
579 float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
580 int i = floor(elapsed_time);
584 float f = elapsed_time - i;
585 hud_dynamic_shake_realofs.x = (1 - f) * hud_dynamic_shake_x[i] + f * hud_dynamic_shake_x[i+1];
586 hud_dynamic_shake_realofs.y = (1 - f) * hud_dynamic_shake_y[i] + f * hud_dynamic_shake_y[i+1];
587 hud_dynamic_shake_realofs.z = 0;
588 hud_dynamic_shake_realofs *= hud_dynamic_shake_factor * autocvar_hud_dynamic_shake_scale;
589 hud_dynamic_shake_realofs.x = bound(-0.1, hud_dynamic_shake_realofs.x, 0.1) * vid_conwidth;
590 hud_dynamic_shake_realofs.y = bound(-0.1, hud_dynamic_shake_realofs.y, 0.1) * vid_conheight;
594 void Hud_Dynamic_Frame()
596 vector ofs = '0 0 0';
597 hud_scale_current = '1 1 0';
598 hud_shift_current = '0 0 0';
600 if (autocvar_hud_dynamic_follow)
602 entity view = CSQCModel_server2csqc(player_localentnum - 1);
603 calc_followmodel_ofs(view);
604 ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
605 ofs.x *= autocvar_hud_dynamic_follow_scale_xyz.z;
606 ofs.y *= autocvar_hud_dynamic_follow_scale_xyz.x;
607 ofs.z *= autocvar_hud_dynamic_follow_scale_xyz.y;
609 if (fabs(ofs.x) < 0.001) ofs.x = 0;
610 if (fabs(ofs.y) < 0.001) ofs.y = 0;
611 if (fabs(ofs.z) < 0.001) ofs.z = 0;
612 ofs.x = bound(-0.1, ofs.x, 0.1);
613 ofs.y = bound(-0.1, ofs.y, 0.1);
614 ofs.z = bound(-0.1, ofs.z, 0.1);
616 hud_shift_current.x = ofs.y * vid_conwidth;
617 hud_shift_current.y = ofs.z * vid_conheight;
618 hud_shift_current.z = ofs.x;
620 hud_scale_current.x = (1 + hud_shift_current.z);
621 hud_scale_current.y = hud_scale_current.x;
624 if(autocvar_hud_dynamic_shake > 0)
626 static float old_health = 0;
627 float health = max(-1, STAT(HEALTH));
628 if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
630 hud_dynamic_shake_factor = 0;
635 float new_hud_dynamic_shake_factor = 0;
636 if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
637 && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
638 && old_health > 0 && !intermission)
640 float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
641 new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
642 if(new_hud_dynamic_shake_factor >= 1)
643 new_hud_dynamic_shake_factor = 1;
644 if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
646 hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
647 hud_dynamic_shake_time = time;
651 if(hud_dynamic_shake_factor)
652 if(!Hud_Shake_Update())
653 hud_dynamic_shake_factor = 0;
656 if(hud_dynamic_shake_factor > 0)
658 hud_shift_current.x += hud_dynamic_shake_realofs.x;
659 hud_shift_current.y += hud_dynamic_shake_realofs.y;
663 hud_scale_center.x = 0.5 * vid_conwidth;
664 hud_scale_center.y = 0.5 * vid_conheight;
669 bool HUD_WouldShowCursor()
671 if(autocvar__hud_configure)
675 //entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
676 //if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
678 if(HUD_Radar_Clickable())
680 if(HUD_MinigameMenu_IsOpened())
682 if(QuickMenu_IsOpened())
691 if(hud_configure_menu_open == 1)
694 hud_fade_alpha = 1 - autocvar__menu_alpha;
696 if(myteam != prev_myteam)
698 myteamcolors = colormapPaletteColor(myteam, 1);
699 FOREACH(hud_panels, true, it.update_time = time);
700 prev_myteam = myteam;
703 HUD_Configure_Frame();
705 if(scoreboard_fade_alpha == 1)
706 if(autocvar__menu_alpha == 1)
710 if (hud_skin_prev != autocvar_hud_skin)
712 strcpy(hud_skin_path, strcat("gfx/hud/", autocvar_hud_skin));
713 strcpy(hud_skin_prev, autocvar_hud_skin);
717 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
721 float hud_dock_color_team = autocvar_hud_dock_color_team;
722 if((teamplay) && hud_dock_color_team) {
723 if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
724 color = '1 0 0' * hud_dock_color_team;
726 color = myteamcolors * hud_dock_color_team;
728 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
729 color = '1 0 0' * hud_dock_color_team;
733 string hud_dock_color = autocvar_hud_dock_color;
734 if(hud_dock_color == "shirt") {
735 f = entcs_GetClientColors(current_player);
736 color = colormapPaletteColor(floor(f / 16), 0);
738 else if(hud_dock_color == "pants") {
739 f = entcs_GetClientColors(current_player);
740 color = colormapPaletteColor(f % 16, 1);
743 color = stov(hud_dock_color);
747 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
748 if(precache_pic(pic) == "") {
749 pic = strcat(hud_skin_path, "/dock_medium");
750 if(precache_pic(pic) == "") {
751 pic = "gfx/hud/default/dock_medium";
754 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...
757 // cache the panel order into the panel_order array
758 if(autocvar__hud_panelorder != hud_panelorder_prev) {
759 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
763 bool warning = false;
764 int argc = tokenize_console(autocvar__hud_panelorder);
765 if (argc > REGISTRY_COUNT(hud_panels))
767 //first detect wrong/missing panel numbers
768 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
769 p_num = stoi(argv(i));
770 if (p_num >= 0 && p_num < REGISTRY_COUNT(hud_panels)) { //correct panel number?
771 if (panel_order[p_num] == -1) //found for the first time?
772 s = strcat(s, ftos(p_num), " ");
773 panel_order[p_num] = 1; //mark as found
778 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
779 if (panel_order[i] == -1) {
781 s = strcat(s, ftos(i), " "); //add missing panel number
785 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
787 cvar_set("_hud_panelorder", s);
788 strcpy(hud_panelorder_prev, s);
790 //now properly set panel_order
792 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
793 panel_order[i] = stof(argv(i));
797 hud_draw_maximized = 0;
798 // draw panels in the order specified by panel_order array
799 for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
800 HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
804 hud_draw_maximized = 1; // panels that may be maximized must check this var
805 // draw maximized panels on top
806 if(hud_panel_radar_maximized)
807 HUD_Panel_Draw(HUD_PANEL(RADAR));
808 if(autocvar__con_chat_maximized)
809 HUD_Panel_Draw(HUD_PANEL(CHAT));
810 if (QuickMenu_IsOpened())
811 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
812 HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
814 int cursor_active_prev = cursor_active;
815 cursor_active = HUD_WouldShowCursor();
816 if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
818 setcursormode(cursor_active);
819 // cursor inactive this frame, will be set to 1 the next frame
824 if (intermission == 2)
827 HUD_Configure_PostDraw();
829 hud_configure_prev = autocvar__hud_configure;