Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
hud.qc
Go to the documentation of this file.
1#include "hud.qh"
2
3#include <client/draw.qh>
8#include <client/mapvoting.qh>
9#include <client/teamradar.qh>
10#include <client/view.qh>
12#include <common/ent_cs.qh>
14#include <common/items/_mod.qh>
15#include <common/mapinfo.qh>
18#include <common/stats.qh>
23
24
25/*
26==================
27Misc HUD functions
28==================
29*/
30
31void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
32{
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);
35}
36
37void draw_cursor_normal(vector pos, vector col, float a)
38{
39 draw_cursor(pos, OFFSET_CURSOR, "/cursor", col, a);
40}
41
43{
44 int fh = -1;
45 if (cvar_string("menu_skin") != "")
46 {
47 draw_currentSkin = strcat("gfx/menu/", cvar_string("menu_skin"));
48 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
49 }
50 if (fh < 0 && cvar_defstring("menu_skin") != "")
51 {
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);
55 }
56 if (fh < 0)
57 {
58 draw_currentSkin = "gfx/menu/wickedx"; // default menu skin
59 fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
60 }
61
62 draw_currentSkin = strzone(draw_currentSkin);
63
64 if (fh >= 0)
65 {
66 string s;
67 int n;
68 while ((s = fgets(fh)))
69 {
70 n = tokenize_console(s);
71 if (n < 2)
72 continue;
73 if (substring(argv(0), 0, 2) == "//")
74 continue;
75 if (argv(0) == "SIZE_CURSOR")
77 else if (argv(0) == "OFFSET_CURSOR")
79 }
80 fclose(fh);
81 }
82}
83
85{
86 hud_scale = '1 1 0';
87 hud_shift = '0 0 0';
89}
90
97
99{
100 v.x = HUD_ScaleX(v.x);
101 v.y = HUD_ScaleY(v.y);
102 return v;
103}
104
106{
107 v.x = HUD_ShiftX(v.x);
108 v.y = HUD_ShiftY(v.y);
109 return v;
110}
111
112vector HUD_GetFontsize(string cvarname)
113{
114 vector v = stov(cvar_string(cvarname));
115 if (v.x == 0)
116 v = '8 8 0';
117 if (v.y == 0)
118 v.y = v.x;
119 v.z = 0;
120 return v;
121}
122
123vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
124{
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
131
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))
136
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;
143
144 #undef CASE_COLOR_BETWEEN
145
146 if (blink)
147 {
148 if (hp_percent >= 100)
149 {
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;
154 }
155 else if (hp_percent < 25)
156 {
157 float f = (1 - hp_percent / 25) * sin(2*M_PI * time);
158 color *= 1 - f;
159 }
160 }
161
162 return color;
163}
164
165float HUD_GetRowCount(int item_count, vector size, float item_aspect)
166{
167 TC(int, item_count);
168 float aspect = size_y / size_x;
169 return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) * 0.5), item_count);
170}
171
172vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
173{
174 TC(int, item_count);
175 bool vertical = psize.x / psize.y >= item_aspect;
176 if (vertical)
177 {
178 psize = eX * psize.y + eY * psize.x;
179 item_aspect = 1 / item_aspect;
180 }
181
182 float rows = ceil(sqrt(item_count));
183 float columns = ceil(item_count / rows);
184 float ratio, best_ratio = 0;
185 float best_columns = 1, best_rows = 1;
186 while (columns >= 1)
187 {
188 ratio = (psize.x / columns) / (psize.y / rows);
189 if (ratio > item_aspect)
190 ratio = item_aspect * item_aspect / ratio;
191
192 if (ratio <= best_ratio)
193 break; // ratio starts decreasing by now, skip next configurations
194
195 best_columns = columns;
196 best_rows = rows;
197 best_ratio = ratio;
198
199 if (columns == 1)
200 break;
201
202 --columns;
203 rows = ceil(item_count/columns);
204 }
205
206 return vertical ? vec2(best_rows, best_columns) : vec2(best_columns, best_rows);
207}
208
209/*
210==================
211HUD panels
212==================
213*/
214
216{
217 // NOTE: in hud_configure mode cvars must be reloaded every frame
218 if (panel.update_time <= time)
219 {
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")));
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")
231 {
234 }
239 panel.current_panel_bg_alpha = panel_bg_alpha;
240 panel.current_panel_fg_alpha = panel_fg_alpha;
243 else
244 {
247 }
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;
255 return;
256 }
257
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;
266}
267
268// basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
269void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
270{
271 TC(bool, vertical); TC(int, drawflag);
272 if (!length_ratio || !theAlpha)
273 return;
274 if (length_ratio > 1)
275 length_ratio = 1;
276 if (baralign == 3)
277 {
278 if (length_ratio < -1)
279 length_ratio = -1;
280 }
281 else if (length_ratio < 0)
282 return;
283
284 theOrigin = HUD_Shift(theOrigin);
285 theSize = HUD_Scale(theSize);
286
287 vector square, width, height;
288 if (vertical)
289 {
290 pic = strcat(hud_skin_path, "/", pic, "_vertical");
291 if (precache_pic(pic) == "")
292 pic = "gfx/hud/default/progressbar_vertical";
293
294 if (baralign == 1) // bottom align
295 theOrigin.y += (1 - length_ratio) * theSize.y;
296 else if (baralign == 2) // center align
297 theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
298 else if (baralign == 3) // center align, positive values down, negative up
299 {
300 theSize.y *= 0.5;
301 if (length_ratio > 0)
302 theOrigin.y += theSize.y;
303 else
304 {
305 theOrigin.y += (1 + length_ratio) * theSize.y;
306 length_ratio = -length_ratio;
307 }
308 }
309 theSize.y *= length_ratio;
310
311 width = eX * theSize.x;
312 height = eY * theSize.y;
313 if (theSize.y <= theSize.x * 2)
314 {
315 // button not high enough
316 // draw just upper and lower part then
317 square = eY * theSize.y * 0.5;
318 vector bH = eY * (0.25 * theSize.y / (theSize.x * 2));
319 drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
320 drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
321 }
322 else
323 {
324 square = eY * theSize.x;
325 drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag);
326 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag);
327 drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
328 }
329 }
330 else
331 {
332 pic = strcat(hud_skin_path, "/", pic);
333 if (precache_pic(pic) == "")
334 pic = "gfx/hud/default/progressbar";
335
336 if (baralign == 1) // right align
337 theOrigin.x += (1 - length_ratio) * theSize.x;
338 else if (baralign == 2) // center align
339 theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
340 else if (baralign == 3) // center align, positive values on the right, negative on the left
341 {
342 theSize.x *= 0.5;
343 if (length_ratio > 0)
344 theOrigin.x += theSize.x;
345 else
346 {
347 theOrigin.x += (1 + length_ratio) * theSize.x;
348 length_ratio = -length_ratio;
349 }
350 }
351 theSize.x *= length_ratio;
352
353 width = eX * theSize.x;
354 height = eY * theSize.y;
355 if (theSize.x <= theSize.y * 2)
356 {
357 // button not wide enough
358 // draw just left and right part then
359 square = eX * theSize.x * 0.5;
360 vector bW = eX * (0.25 * theSize.x / (theSize.y * 2));
361 drawsubpic(theOrigin, square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
362 drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
363 }
364 else
365 {
366 square = eX * theSize.y;
367 drawsubpic(theOrigin, height + square, pic, '0 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
368 drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0.25 0 0', '0.5 1 0', theColor, theAlpha, drawflag);
369 drawsubpic(theOrigin + width - square, height + square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
370 }
371 }
372}
373
374void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
375{
376 TC(int, drawflag);
377 if (!theAlpha)
378 return;
379
380 pos = HUD_Shift(pos);
381 mySize = HUD_Scale(mySize);
382
383 string pic = strcat(hud_skin_path, "/num_leading");
384 if (precache_pic(pic) == "")
385 pic = "gfx/hud/default/num_leading";
386
387 drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
388 if (mySize.x / mySize.y > 2)
389 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);
390 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);
391}
392
393void DrawNumIcon_expanding(vector myPos, vector mySize, float theTime, string icon, bool vertical, bool isInfinite, int icon_right_align, vector color, float theAlpha, float fadelerp)
394{
395 TC(bool, vertical); TC(int, icon_right_align);
396 vector newPos = '0 0 0', newSize = '0 0 0';
397 vector picpos, numpos;
398 string text = isInfinite ? "\xE2\x88\x9E" : ftos(theTime); // Use infinity symbol (U+221E)
399
400 if (vertical)
401 {
402 if (mySize.y / mySize.x > 2)
403 {
404 newSize.y = 2 * mySize.x;
405 newSize.x = mySize.x;
406
407 newPos.y = myPos.y + (mySize.y - newSize.y) * 0.5;
408 newPos.x = myPos.x;
409 }
410 else
411 {
412 newSize.x = 1/2 * mySize.y;
413 newSize.y = mySize.y;
414
415 newPos.x = myPos.x + (mySize.x - newSize.x) * 0.5;
416 newPos.y = myPos.y;
417 }
418
419 if (icon_right_align)
420 {
421 numpos = newPos;
422 picpos = newPos + eY * newSize.x;
423 }
424 else
425 {
426 picpos = newPos;
427 numpos = newPos + eY * newSize.x;
428 }
429
430 newSize.y *= 0.5;
431 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
432 // make number smaller than icon, it looks better
433 // reduce only y to draw numbers with different number of digits with the same y size
434 numpos.y += newSize.y * ((1 - 0.7) / 2);
435 newSize.y *= 0.7;
436 drawstring_aspect(numpos, text, newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
437 return;
438 }
439
440 if (mySize.x / mySize.y > 3)
441 {
442 newSize.x = 3 * mySize.y;
443 newSize.y = mySize.y;
444
445 newPos.x = myPos.x + (mySize.x - newSize.x) * 0.5;
446 newPos.y = myPos.y;
447 }
448 else
449 {
450 newSize.y = 1/3 * mySize.x;
451 newSize.x = mySize.x;
452
453 newPos.y = myPos.y + (mySize.y - newSize.y) * 0.5;
454 newPos.x = myPos.x;
455 }
456
457 if (icon_right_align) // right align
458 {
459 numpos = newPos;
460 picpos = newPos + eX * 2 * newSize.y;
461 }
462 else // left align
463 {
464 numpos = newPos + eX * newSize.y;
465 picpos = newPos;
466 }
467
468 // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
469 // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
470 drawstring_aspect_expanding(numpos, text, '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
471 drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
472}
473
474void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, bool isInfinite, int icon_right_align, vector color, float theAlpha)
475{
476 TC(bool, vertical); TC(int, icon_right_align);
477 DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, isInfinite, icon_right_align, color, theAlpha, 0);
478}
479
480/*
481==================
482Main HUD system
483==================
484*/
485
489{
491 return;
492
493 if (hud == HUD_BUMBLEBEE_GUN)
495 else
496 {
497 Vehicle info = REGISTRY_GET(Vehicles, hud);
498 info.vr_hud(info);
499 }
500
501 if (hud != HUD_NORMAL && lasthud == HUD_NORMAL)
503
504 lasthud = hud;
505}
506
508{
509 panel = panent;
511 {
512 if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
513 return;
516 panel.panel_draw();
517 return;
518 }
519
520 bool draw_allowed = false;
521 if (scoreboard_fade_alpha && panel.panel_showflags & PANEL_SHOW_WITH_SB)
522 draw_allowed = true;
524 {
525 if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
526 draw_allowed = true;
527 }
528 else if (intermission == 2)
529 {
530 if (panel.panel_showflags & PANEL_SHOW_MAPVOTE)
531 draw_allowed = true;
532 }
533 else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
534 draw_allowed = true;
535
536 if (draw_allowed)
537 {
538 if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
539 {
540 if (scoreboard_fade_alpha && intermission == 2 && !(panel.panel_showflags & PANEL_SHOW_MAPVOTE))
542 else
544 }
545 else
546 {
548 if (!panel_fade_alpha)
549 return;
550 }
551 panel.panel_draw();
552 }
553}
554
556{
557 // reset gametype specific icons
558 if (gametype.m_modicons_reset)
559 gametype.m_modicons_reset();
560}
561
566float hud_dynamic_shake_x[10] = {0, 1, -0.7, 0.5, -0.3, 0.2, -0.1, 0.1, 0.0, 0};
567float hud_dynamic_shake_y[10] = {0, 0.4, 0.8, -0.2, -0.6, 0.0, 0.3, 0.1, -0.1, 0};
569{
571 return false;
572
573 float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
574 float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
575 int i = floor(elapsed_time);
576 if (i >= 9)
577 return false;
578
579 float f = elapsed_time - i;
586 return true;
587}
588
590{
591 vector ofs = '0 0 0';
592 hud_scale_current = '1 1 0';
593 hud_shift_current = '0 0 0';
594
596 {
603
604 if (fabs(ofs.x) < 0.001) ofs.x = 0;
605 if (fabs(ofs.y) < 0.001) ofs.y = 0;
606 if (fabs(ofs.z) < 0.001) ofs.z = 0;
607 ofs.x = bound(-0.1, ofs.x, 0.1);
608 ofs.y = bound(-0.1, ofs.y, 0.1);
609 ofs.z = bound(-0.1, ofs.z, 0.1);
610
613 hud_shift_current.z = ofs.x;
614
617 }
618
620 {
621 static float old_health = 0;
622 float health = max(-1, STAT(HEALTH));
623 if (hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
624 {
626 old_health = health;
627 }
628 else
629 {
630 float new_hud_dynamic_shake_factor = 0;
633 && old_health > 0 && !intermission)
634 {
636 new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
637 if (new_hud_dynamic_shake_factor >= 1)
638 new_hud_dynamic_shake_factor = 1;
639 if (new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
640 {
641 hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
643 }
644 }
645 old_health = health;
648 }
649
651 {
654 }
655 }
656
659
661}
662
664{
666 return true;
667 if (mv_active && !isdemo())
668 return true;
669 //entity local_player = (csqcplayer ? csqcplayer : CSQCModel_server2csqc(player_localentnum - 1)); // TODO: doesn't use regular cursor handling
670 //if (local_player.viewloc && (local_player.viewloc.spawnflags & VIEWLOC_FREEAIM))
671 //return true;
673 return true;
675 return true;
676 if (QuickMenu_IsOpened())
677 return true;
678 return false;
679}
680
683{
685 hud_fade_alpha = 1;
686 else
688
689 if (myteam != prev_myteam)
690 {
692 FOREACH(hud_panels, true, it.update_time = time);
694 }
695
697
699 return;
700
701 // Drawing stuff
703 {
706 }
707
708 // draw the dock
709 if (autocvar_hud_dock != "" && autocvar_hud_dock != "0")
710 {
712 float hud_dock_color_team = autocvar_hud_dock_color_team;
713 if (teamplay && hud_dock_color_team)
714 {
716 color = '1 0 0' * hud_dock_color_team;
717 else
718 color = myteamcolors * hud_dock_color_team;
719 }
720 else if (autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team)
721 color = '1 0 0' * hud_dock_color_team;
722 else
723 {
724 string hud_dock_color = autocvar_hud_dock_color;
725 int f;
726 if (hud_dock_color == "shirt")
727 {
729 color = colormapPaletteColor(floor(f / 16), 0);
730 }
731 else if (hud_dock_color == "pants")
732 {
734 color = colormapPaletteColor(f % 16, 1);
735 }
736 else
737 color = stov(hud_dock_color);
738 }
739
740 string pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
741 if (precache_pic(pic) == "")
742 {
743 pic = strcat(hud_skin_path, "/dock_medium");
744 if (precache_pic(pic) == "")
745 pic = "gfx/hud/default/dock_medium";
746 }
747 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...
748 }
749
750 // cache the panel order into the panel_order array
751 int i;
753 {
754 for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
755 panel_order[i] = -1;
756 string s = "";
757 int p_num;
759 bool warning = (argc > REGISTRY_COUNT(hud_panels));
760 // first detect wrong/missing panel numbers
761 for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
762 {
763 p_num = stoi(argv(i));
764 if (p_num >= 0 && p_num < REGISTRY_COUNT(hud_panels)) // correct panel number?
765 {
766 if (panel_order[p_num] == -1) // found for the first time?
767 s = strcat(s, ftos(p_num), " ");
768 panel_order[p_num] = 1; // mark as found
769 }
770 else
771 warning = true;
772 }
773 for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
774 if (panel_order[i] == -1)
775 {
776 warning = true;
777 s = strcat(s, ftos(i), " "); // add missing panel number
778 }
779 if (warning)
780 LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
781
782 cvar_set("_hud_panelorder", s);
784
785 // now properly set panel_order
787 for (i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
788 panel_order[i] = stof(argv(i));
789 }
790
792 // draw panels in the order specified by panel_order array
793 for (i = REGISTRY_COUNT(hud_panels) - 1; i >= 0; --i)
794 HUD_Panel_Draw(REGISTRY_GET(hud_panels, panel_order[i]));
795
796 HUD_Vehicle();
797
798 hud_draw_maximized = 1; // panels that may be maximized must check this var
799 // draw maximized panels on top
804 if (QuickMenu_IsOpened())
805 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
806 HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
807
808 int cursor_active_prev = cursor_active;
810 if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
811 {
812 setcursormode(cursor_active);
813 // cursor inactive this frame, will be set to 1 the next frame
814 if (cursor_active)
815 cursor_active = -1;
816 }
817
818 if (intermission == 2)
819 HUD_Reset();
820
822
824}
float height
Definition bobbing.qc:3
void CSQC_BUMBLE_GUN_HUD()
Definition bumblebee.qc:934
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity active_minigame
bool HUD_MinigameMenu_IsOpened()
float autocvar_cl_vehicles_notify_time
Definition cl_vehicles.qh:6
virtual void vr_hud()
(CLIENT) logic to run every frame
Definition vehicle.qh:78
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition draw.qc:110
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition draw.qc:61
void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp)
Definition draw.qc:139
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition draw.qh:78
#define drawpic(position, pic, size, rgb, alpha, flag)
Definition draw.qh:21
vector drawfontscale
Definition draw.qh:3
bool autocvar__con_chat_maximized
Definition chat.qh:6
entity gametype
Definition main.qh:43
int hud
Definition main.qh:173
bool mv_active
Definition mapvoting.qh:19
#define colormapPaletteColor(c, isPants)
Definition color.qh:5
ERASEABLE float blink(float base, float range, float freq)
Definition util.qc:2178
const int HUD_BUMBLEBEE_GUN
Definition constants.qh:48
const int HUD_NORMAL
Definition constants.qh:47
float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag)
const float DRAWFLAG_NORMAL
const float FILE_READ
float time
vector size
float player_localentnum
float intermission
#define argv_end_index
#define tokenize_console
#define argv_start_index
vector color
Definition dynlight.qc:15
entity CSQCModel_server2csqc(int i)
Definition cl_model.qc:314
int entcs_GetClientColors(int i)
Definition ent_cs.qh:115
float autocvar_hud_dynamic_shake_damage_max
Definition hud.qc:563
float autocvar_hud_dynamic_shake
Definition hud.qc:562
void draw_cursor_normal(vector pos, vector col, float a)
Definition hud.qc:37
void HUD_Reset()
Definition hud.qc:555
bool Hud_Shake_Update()
Definition hud.qc:568
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
Definition hud.qc:269
void HUD_Panel_Draw(entity panent)
Definition hud.qc:507
void HUD_Panel_LoadCvars()
Definition hud.qc:215
vector HUD_Shift(vector v)
Definition hud.qc:105
float hud_dynamic_shake_x[10]
Definition hud.qc:566
void LoadMenuSkinValues()
Definition hud.qc:42
void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, bool isInfinite, int icon_right_align, vector color, float theAlpha)
Definition hud.qc:474
void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
Definition hud.qc:31
bool HUD_WouldShowCursor()
Definition hud.qc:663
void HUD_Vehicle()
Definition hud.qc:488
vector HUD_GetFontsize(string cvarname)
Definition hud.qc:112
void HUD_Main()
Definition hud.qc:682
float vh_notice_time
Definition hud.qc:487
float prev_myteam
Definition hud.qc:681
float lasthud
Definition hud.qc:486
float HUD_GetRowCount(int item_count, vector size, float item_aspect)
Definition hud.qc:165
float autocvar_hud_dynamic_shake_scale
Definition hud.qc:565
vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
Definition hud.qc:172
float autocvar_hud_dynamic_shake_damage_min
Definition hud.qc:564
void HUD_Scale_Enable()
Definition hud.qc:91
vector HUD_Scale(vector v)
Definition hud.qc:98
void Hud_Dynamic_Frame()
Definition hud.qc:589
#define CASE_COLOR_BETWEEN(min, max)
float hud_dynamic_shake_y[10]
Definition hud.qc:567
vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
Definition hud.qc:123
void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
Definition hud.qc:374
void HUD_Scale_Disable()
Definition hud.qc:84
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)
Definition hud.qc:393
entity highlightedPanel
Definition hud.qh:107
float panel_fade_alpha
Definition hud.qh:421
string panel_bg_color_team_str
Definition hud.qh:168
string autocvar_hud_dock
Definition hud.qh:192
#define HUD_ScaleX(f)
Definition hud.qh:15
vector panel_size
Definition hud.qh:163
float hud_dynamic_shake_time
Definition hud.qh:215
float panel_fg_alpha
Definition hud.qh:169
float autocvar_hud_dock_alpha
Definition hud.qh:193
#define HUD_PANEL(NAME)
Definition hud.qh:52
string panel_bg_border_str
Definition hud.qh:173
#define HUD_ShiftY(f)
Definition hud.qh:18
string hud_skin_prev
Definition hud.qh:137
string autocvar__hud_panelorder
Definition hud.qh:189
float autocvar__menu_alpha
Definition hud.qh:187
float hud_dynamic_shake_factor
Definition hud.qh:214
#define HUD_Panel_GetBg()
Definition hud.qh:294
float panel_bg_padding
Definition hud.qh:174
string panel_bg_alpha_str
Definition hud.qh:171
vector hud_dynamic_shake_realofs
Definition hud.qh:213
bool hud_draw_maximized
Definition hud.qh:69
string autocvar_hud_skin
Definition hud.qh:203
vector autocvar_hud_dynamic_follow_scale_xyz
Definition hud.qh:211
bool hud_panel_radar_maximized
Definition hud.qh:70
#define HUD_Panel_GetPadding()
Definition hud.qh:390
int panel_order[REGISTRY_MAX(hud_panels)]
Definition hud.qh:66
#define HUD_ScaleY(f)
Definition hud.qh:16
float autocvar_hud_dynamic_follow
Definition hud.qh:209
float panel_bg_border
Definition hud.qh:172
float panel_bg_color_team
Definition hud.qh:167
string panel_bg_str
Definition hud.qh:164
vector hud_scale_current
Definition hud.qh:222
string panel_bg_color_str
Definition hud.qh:166
bool autocvar_hud_dock_color_team
Definition hud.qh:195
string hud_panelorder_prev
Definition hud.qh:67
#define HUD_Panel_GetColor()
Definition hud.qh:321
const int PANEL_SHOW_MAPVOTE
Definition hud.qh:232
const int PANEL_SHOW_MINIGAME
Definition hud.qh:231
bool QuickMenu_IsOpened()
Definition quickmenu.qc:291
float hud_fade_alpha
Definition hud.qh:134
const int PANEL_SHOW_MAINGAME
Definition hud.qh:230
vector hud_scale_center
Definition hud.qh:225
string autocvar_hud_dock_color
Definition hud.qh:194
float autocvar_hud_panel_update_interval
Definition hud.qh:205
vector hud_shift
Definition hud.qh:223
#define HUD_Panel_GetColorTeam()
Definition hud.qh:348
#define HUD_ShiftX(f)
Definition hud.qh:17
bool autocvar_hud_cursormode
Definition hud.qh:191
#define Hud_Panel_GetPanelEnabled()
Definition hud.qh:424
float current_player
Definition hud.qh:185
vector hud_scale
Definition hud.qh:221
vector cl_followmodel_ofs
Definition hud.qh:218
vector OFFSET_CURSOR
Definition hud.qh:6
string hud_skin_path
Definition hud.qh:136
vector panel_pos
Definition hud.qh:162
const int PANEL_SHOW_WITH_SB
Definition hud.qh:233
#define HUD_Panel_GetFgAlpha()
Definition hud.qh:374
float panel_bg_alpha
Definition hud.qh:170
vector panel_bg_color
Definition hud.qh:165
#define HUD_Panel_UpdatePosSize_ForMenu()
Definition hud.qh:400
#define HUD_Panel_ScalePosSize()
Definition hud.qh:414
string panel_bg_padding_str
Definition hud.qh:175
entity panel
Definition hud.qh:147
const int PANEL_CONFIG_MAIN
Definition hud.qh:237
vector myteamcolors
Definition hud.qh:139
float autocvar_hud_dynamic_follow_scale
Definition hud.qh:210
#define HUD_Panel_GetBorder()
Definition hud.qh:381
vector hud_shift_current
Definition hud.qh:224
#define HUD_Panel_GetBgAlpha()
Definition hud.qh:357
bool HUD_Radar_Clickable()
Definition radar.qc:26
vector SIZE_CURSOR
Definition hud.qh:7
void HUD_Configure_PostDraw()
void HUD_Configure_Frame()
float hud_configure_prev
Definition hud_config.qh:18
bool autocvar_hud_configure_teamcolorforced
Definition hud_config.qh:8
bool autocvar__hud_configure
Definition hud_config.qh:3
float hud_configure_menu_open
Definition hud_config.qh:22
#define stoi(s)
Definition int.qh:4
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define TC(T, sym)
Definition _all.inc:82
noref float vid_conwidth
Definition draw.qh:8
noref float vid_conheight
Definition draw.qh:9
#define STAT(...)
Definition stats.qh:82
#define LOG_TRACE(...)
Definition log.qh:76
#define M_PI
Definition mathlib.qh:108
void cvar_set(string name, string value)
string fgets(float fhandle)
float isdemo()
void fclose(float fhandle)
float ceil(float f)
float stof(string val,...)
float bound(float min, float value, float max)
string substring(string s, float start, float length)
float fopen(string filename, float mode)
vector stov(string s)
string precache_pic(string name,...)
const string cvar_string(string name)
float sqrt(float f)
float sin(float f)
float min(float f,...)
string ftos(float f)
float fabs(float f)
float floor(float f)
const string cvar_defstring(string name)
string strzone(string s)
string argv(float n)
float max(float f,...)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define REGISTRY_COUNT(id)
Definition registry.qh:18
#define REGISTRY_GET(id, i)
Definition registry.qh:43
float health
Legacy fields for the resources. To be removed.
Definition resources.qh:9
float scoreboard_fade_alpha
Definition scoreboard.qh:17
vector
Definition self.qh:92
#define strcpy(this, s)
Definition string.qh:52
int myteam
Definition teams.qh:60
const int NUM_SPECTATOR
Definition teams.qh:23
bool teamplay
Definition teams.qh:59
const vector eY
Definition vector.qh:45
const vector eX
Definition vector.qh:44
#define vec2(...)
Definition vector.qh:90
void calc_followmodel_ofs(entity view)
Definition view.qc:113
int cursor_active
Definition view.qh:112