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, bool isInfinite, 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;
403 string text = isInfinite ? "\xE2\x88\x9E" : ftos(theTime); // Use infinity symbol (U+221E)
407 if(mySize.y/mySize.x > 2)
409 newSize.y = 2 * mySize.x;
410 newSize.x = mySize.x;
412 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
417 newSize.x = 1/2 * mySize.y;
418 newSize.y = mySize.y;
420 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
427 picpos = newPos + eY * newSize.x;
432 numpos = newPos + eY * newSize.x;
436 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
437 // make number smaller than icon, it looks better
438 // reduce only y to draw numbers with different number of digits with the same y size
439 numpos.y += newSize.y * ((1 - 0.7) / 2);
441 drawstring_aspect(numpos, text, newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
445 if(mySize.x/mySize.y > 3)
447 newSize.x = 3 * mySize.y;
448 newSize.y = mySize.y;
450 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
455 newSize.y = 1/3 * mySize.x;
456 newSize.x = mySize.x;
458 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
462 if(icon_right_align) // right align
465 picpos = newPos + eX * 2 * newSize.y;
469 numpos = newPos + eX * newSize.y;
473 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
474 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
475 drawstring_aspect_expanding(numpos, text, '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
476 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
479 void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, bool isInfinite, int icon_right_align, vector color, float theAlpha)
481 TC(bool, vertical); TC(int, icon_right_align);
482 DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, isInfinite, icon_right_align, color, theAlpha, 0);
492 float vh_notice_time;
495 if(autocvar__hud_configure) return;
496 if(intermission == 2) return;
498 if(hud == HUD_BUMBLEBEE_GUN)
499 CSQC_BUMBLE_GUN_HUD();
501 Vehicle info = REGISTRY_GET(Vehicles, hud);
505 if(hud != HUD_NORMAL && lasthud == HUD_NORMAL)
506 vh_notice_time = time + autocvar_cl_vehicles_notify_time;
511 void HUD_Panel_Draw(entity panent)
514 if (autocvar__hud_configure)
516 if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
518 panel_fade_alpha = 1;
519 Hud_Panel_GetPanelEnabled();
524 bool draw_allowed = false;
525 if (scoreboard_fade_alpha && panel.panel_showflags & PANEL_SHOW_WITH_SB)
529 else if (active_minigame && HUD_MinigameMenu_IsOpened())
531 if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
534 else if(intermission == 2)
536 if(panel.panel_showflags & PANEL_SHOW_MAPVOTE)
539 else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
544 if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
546 if (scoreboard_fade_alpha && intermission == 2 && !(panel.panel_showflags & PANEL_SHOW_MAPVOTE))
547 panel_fade_alpha = scoreboard_fade_alpha;
549 panel_fade_alpha = 1;
553 panel_fade_alpha = 1 - scoreboard_fade_alpha;
554 if(!panel_fade_alpha)
563 // reset gametype specific icons
564 if(gametype.m_modicons_reset)
565 gametype.m_modicons_reset();
568 float autocvar_hud_dynamic_shake = 1;
569 float autocvar_hud_dynamic_shake_damage_max = 130;
570 float autocvar_hud_dynamic_shake_damage_min = 10;
571 float autocvar_hud_dynamic_shake_scale = 0.2;
572 float hud_dynamic_shake_x[10] = {0, 1, -0.7, 0.5, -0.3, 0.2, -0.1, 0.1, 0.0, 0};
573 float hud_dynamic_shake_y[10] = {0, 0.4, 0.8, -0.2, -0.6, 0.0, 0.3, 0.1, -0.1, 0};
574 bool Hud_Shake_Update()
576 if(time - hud_dynamic_shake_time < 0)
579 float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
580 float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
581 int i = floor(elapsed_time);
585 float f = elapsed_time - i;
586 hud_dynamic_shake_realofs.x = (1 - f) * hud_dynamic_shake_x[i] + f * hud_dynamic_shake_x[i+1];
587 hud_dynamic_shake_realofs.y = (1 - f) * hud_dynamic_shake_y[i] + f * hud_dynamic_shake_y[i+1];
588 hud_dynamic_shake_realofs.z = 0;
589 hud_dynamic_shake_realofs *= hud_dynamic_shake_factor * autocvar_hud_dynamic_shake_scale;
590 hud_dynamic_shake_realofs.x = bound(-0.1, hud_dynamic_shake_realofs.x, 0.1) * vid_conwidth;
591 hud_dynamic_shake_realofs.y = bound(-0.1, hud_dynamic_shake_realofs.y, 0.1) * vid_conheight;
595 void Hud_Dynamic_Frame()
597 vector ofs = '0 0 0';
598 hud_scale_current = '1 1 0';
599 hud_shift_current = '0 0 0';
601 if (autocvar_hud_dynamic_follow)
603 entity view = CSQCModel_server2csqc(player_localentnum - 1);
604 calc_followmodel_ofs(view);
605 ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
606 ofs.x *= autocvar_hud_dynamic_follow_scale_xyz.z;
607 ofs.y *= autocvar_hud_dynamic_follow_scale_xyz.x;
608 ofs.z *= autocvar_hud_dynamic_follow_scale_xyz.y;
610 if (fabs(ofs.x) < 0.001) ofs.x = 0;
611 if (fabs(ofs.y) < 0.001) ofs.y = 0;
612 if (fabs(ofs.z) < 0.001) ofs.z = 0;
613 ofs.x = bound(-0.1, ofs.x, 0.1);
614 ofs.y = bound(-0.1, ofs.y, 0.1);
615 ofs.z = bound(-0.1, ofs.z, 0.1);
617 hud_shift_current.x = ofs.y * vid_conwidth;
618 hud_shift_current.y = ofs.z * vid_conheight;
619 hud_shift_current.z = ofs.x;
621 hud_scale_current.x = (1 + hud_shift_current.z);
622 hud_scale_current.y = hud_scale_current.x;
625 if(autocvar_hud_dynamic_shake > 0)
627 static float old_health = 0;
628 float health = max(-1, STAT(HEALTH));
629 if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
631 hud_dynamic_shake_factor = 0;
636 float new_hud_dynamic_shake_factor = 0;
637 if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
638 && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
639 && old_health > 0 && !intermission)
641 float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
642 new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
643 if(new_hud_dynamic_shake_factor >= 1)
644 new_hud_dynamic_shake_factor = 1;
645 if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
647 hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
648 hud_dynamic_shake_time = time;
652 if(hud_dynamic_shake_factor)
653 if(!Hud_Shake_Update())
654 hud_dynamic_shake_factor = 0;
657 if(hud_dynamic_shake_factor > 0)
659 hud_shift_current.x += hud_dynamic_shake_realofs.x;
660 hud_shift_current.y += hud_dynamic_shake_realofs.y;
664 hud_scale_center.x = 0.5 * vid_conwidth;
665 hud_scale_center.y = 0.5 * vid_conheight;
670 bool HUD_WouldShowCursor()
672 if(autocvar__hud_configure)
676 //entity local_player = ((csqcplayer) ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
677 //if(local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
679 if(HUD_Radar_Clickable())
681 if(HUD_MinigameMenu_IsOpened())
683 if(QuickMenu_IsOpened())
692 if(hud_configure_menu_open == 1)
695 hud_fade_alpha = 1 - autocvar__menu_alpha;
697 if(myteam != prev_myteam)
699 myteamcolors = colormapPaletteColor(myteam, 1);
700 FOREACH(hud_panels, true, it.update_time = time);
701 prev_myteam = myteam;
704 HUD_Configure_Frame();
706 if(scoreboard_fade_alpha == 1)
707 if(autocvar__menu_alpha == 1)
711 if (hud_skin_prev != autocvar_hud_skin)
713 strcpy(hud_skin_path, strcat("gfx/hud/", autocvar_hud_skin));
714 strcpy(hud_skin_prev, autocvar_hud_skin);
718 if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
722 float hud_dock_color_team = autocvar_hud_dock_color_team;
723 if((teamplay) && hud_dock_color_team) {
724 if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
725 color = '1 0 0' * hud_dock_color_team;
727 color = myteamcolors * hud_dock_color_team;
729 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
730 color = '1 0 0' * hud_dock_color_team;
734 string hud_dock_color = autocvar_hud_dock_color;
735 if(hud_dock_color == "shirt") {
736 f = entcs_GetClientColors(current_player);
737 color = colormapPaletteColor(floor(f / 16), 0);
739 else if(hud_dock_color == "pants") {
740 f = entcs_GetClientColors(current_player);
741 color = colormapPaletteColor(f % 16, 1);
744 color = stov(hud_dock_color);
748 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
749 if(precache_pic(pic) == "") {
750 pic = strcat(hud_skin_path, "/dock_medium");
751 if(precache_pic(pic) == "") {
752 pic = "gfx/hud/default/dock_medium";
755 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...
758 // cache the panel order into the panel_order array
759 if(autocvar__hud_panelorder != hud_panelorder_prev) {
760 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
764 bool warning = false;
765 int argc = tokenize_console(autocvar__hud_panelorder);
766 if (argc > REGISTRY_COUNT(hud_panels))
768 //first detect wrong/missing panel numbers
769 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
770 p_num = stoi(argv(i));
771 if (p_num >= 0 && p_num < REGISTRY_COUNT(hud_panels)) { //correct panel number?
772 if (panel_order[p_num] == -1) //found for the first time?
773 s = strcat(s, ftos(p_num), " ");
774 panel_order[p_num] = 1; //mark as found
779 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
780 if (panel_order[i] == -1) {
782 s = strcat(s, ftos(i), " "); //add missing panel number
786 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
788 cvar_set("_hud_panelorder", s);
789 strcpy(hud_panelorder_prev, s);
791 //now properly set panel_order
793 for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
794 panel_order[i] = stof(argv(i));
798 hud_draw_maximized = 0;
799 // draw panels in the order specified by panel_order array
800 for(i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
801 HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
805 hud_draw_maximized = 1; // panels that may be maximized must check this var
806 // draw maximized panels on top
807 if(hud_panel_radar_maximized)
808 HUD_Panel_Draw(HUD_PANEL(RADAR));
809 if(autocvar__con_chat_maximized)
810 HUD_Panel_Draw(HUD_PANEL(CHAT));
811 if (QuickMenu_IsOpened())
812 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
813 HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
815 int cursor_active_prev = cursor_active;
816 cursor_active = HUD_WouldShowCursor();
817 if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
819 setcursormode(cursor_active);
820 // cursor inactive this frame, will be set to 1 the next frame
825 if (intermission == 2)
828 HUD_Configure_PostDraw();
830 hud_configure_prev = autocvar__hud_configure;