Xonotic
hud.qc
Go to the documentation of this file.
1 #include "hud.qh"
2 
3 #include <client/draw.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>
18 #include <common/stats.qh>
19 #include <common/vehicles/all.qh>
23 
24 
25 /*
26 ==================
27 Misc HUD functions
28 ==================
29 */
30 
31 void 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 
37 void 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/default";
59  fh = fopen(strcat(draw_currentSkin, "/skinvalues.txt"), FILE_READ);
60  }
61 
63 
64  if(fh >= 0)
65  {
66  string s;
67  while((s = fgets(fh)))
68  {
69  int n = tokenize_console(s);
70  if (n < 2)
71  continue;
72  if(substring(argv(0), 0, 2) == "//")
73  continue;
74  if(argv(0) == "SIZE_CURSOR")
76  else if(argv(0) == "OFFSET_CURSOR")
78  }
79  fclose(fh);
80  }
81 }
82 
84 {
85  hud_scale = '1 1 0';
86  hud_shift = '0 0 0';
88 }
89 
91 {
95 }
96 
98 {
99  v.x = HUD_ScaleX(v.x);
100  v.y = HUD_ScaleY(v.y);
101  return v;
102 }
103 
105 {
106  v.x = HUD_ShiftX(v.x);
107  v.y = HUD_ShiftY(v.y);
108  return v;
109 }
110 
111 vector HUD_GetFontsize(string cvarname)
112 {
113  vector v;
114  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 
123 vector 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
130  vector color;
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 -= color * f;
159  }
160  }
161 
162  return color;
163 }
164 
165 float 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) / 2), item_count);
170 }
171 
172 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
173 {
174  TC(int, item_count);
175  float columns, rows;
176  float ratio, best_ratio = 0;
177  float best_columns = 1, best_rows = 1;
178  bool vertical = (psize.x / psize.y >= item_aspect);
179  if(vertical)
180  {
181  psize = eX * psize.y + eY * psize.x;
182  item_aspect = 1 / item_aspect;
183  }
184 
185  rows = ceil(sqrt(item_count));
186  columns = ceil(item_count/rows);
187  while(columns >= 1)
188  {
189  ratio = (psize.x/columns) / (psize.y/rows);
190  if(ratio > item_aspect)
191  ratio = item_aspect * item_aspect / ratio;
192 
193  if(ratio <= best_ratio)
194  break; // ratio starts decreasing by now, skip next configurations
195 
196  best_columns = columns;
197  best_rows = rows;
198  best_ratio = ratio;
199 
200  if(columns == 1)
201  break;
202 
203  --columns;
204  rows = ceil(item_count/columns);
205  }
206 
207  return (vertical) ? vec2(best_rows, best_columns) : vec2(best_columns, best_rows);
208 }
209 
210 /*
211 ==================
212 HUD panels
213 ==================
214 */
215 
217 {
218  // NOTE: in hud_configure mode cvars must be reloaded every frame
219  if (panel.update_time <= time)
220  {
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")));
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"));
230  HUD_Panel_GetBg();
231  if (panel.current_panel_bg != "0")
232  {
235  }
240  panel.current_panel_bg_alpha = panel_bg_alpha;
241  panel.current_panel_fg_alpha = panel_fg_alpha;
244  else
245  {
248  }
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;
256  return;
257  }
258 
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;
267 }
268 
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)
271 {
272  TC(bool, vertical); TC(int, drawflag);
273  if(!length_ratio || !theAlpha)
274  return;
275  if(length_ratio > 1)
276  length_ratio = 1;
277  if (baralign == 3)
278  {
279  if(length_ratio < -1)
280  length_ratio = -1;
281  }
282  else if(length_ratio < 0)
283  return;
284 
285  theOrigin = HUD_Shift(theOrigin);
286  theSize = HUD_Scale(theSize);
287 
288  vector square;
289  vector width, height;
290  if(vertical) {
291  pic = strcat(hud_skin_path, "/", pic, "_vertical");
292  if(precache_pic(pic) == "") {
293  pic = "gfx/hud/default/progressbar_vertical";
294  }
295 
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
301  {
302  theSize.y *= 0.5;
303  if (length_ratio > 0)
304  theOrigin.y += theSize.y;
305  else
306  {
307  theOrigin.y += (1 + length_ratio) * theSize.y;
308  length_ratio = -length_ratio;
309  }
310  }
311  theSize.y *= length_ratio;
312 
313  vector bH;
314  width = eX * theSize.x;
315  height = eY * theSize.y;
316  if(theSize.y <= theSize.x * 2)
317  {
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);
324  }
325  else
326  {
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);
331  }
332  } else {
333  pic = strcat(hud_skin_path, "/", pic);
334  if(precache_pic(pic) == "") {
335  pic = "gfx/hud/default/progressbar";
336  }
337 
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
343  {
344  theSize.x *= 0.5;
345  if (length_ratio > 0)
346  theOrigin.x += theSize.x;
347  else
348  {
349  theOrigin.x += (1 + length_ratio) * theSize.x;
350  length_ratio = -length_ratio;
351  }
352  }
353  theSize.x *= length_ratio;
354 
355  vector bW;
356  width = eX * theSize.x;
357  height = eY * theSize.y;
358  if(theSize.x <= theSize.y * 2)
359  {
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);
366  }
367  else
368  {
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);
373  }
374  }
375 }
376 
377 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
378 {
379  TC(int, drawflag);
380  if(!theAlpha)
381  return;
382 
383  pos = HUD_Shift(pos);
384  mySize = HUD_Scale(mySize);
385 
386  string pic;
387  pic = strcat(hud_skin_path, "/num_leading");
388  if(precache_pic(pic) == "") {
389  pic = "gfx/hud/default/num_leading";
390  }
391 
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);
396 }
397 
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)
399 {
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)
404 
405  if (vertical)
406  {
407  if(mySize.y/mySize.x > 2)
408  {
409  newSize.y = 2 * mySize.x;
410  newSize.x = mySize.x;
411 
412  newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
413  newPos.x = myPos.x;
414  }
415  else
416  {
417  newSize.x = 1/2 * mySize.y;
418  newSize.y = mySize.y;
419 
420  newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
421  newPos.y = myPos.y;
422  }
423 
424  if(icon_right_align)
425  {
426  numpos = newPos;
427  picpos = newPos + eY * newSize.x;
428  }
429  else
430  {
431  picpos = newPos;
432  numpos = newPos + eY * newSize.x;
433  }
434 
435  newSize.y /= 2;
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);
440  newSize.y *= 0.7;
441  drawstring_aspect(numpos, text, newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
442  return;
443  }
444 
445  if(mySize.x/mySize.y > 3)
446  {
447  newSize.x = 3 * mySize.y;
448  newSize.y = mySize.y;
449 
450  newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
451  newPos.y = myPos.y;
452  }
453  else
454  {
455  newSize.y = 1/3 * mySize.x;
456  newSize.x = mySize.x;
457 
458  newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
459  newPos.x = myPos.x;
460  }
461 
462  if(icon_right_align) // right align
463  {
464  numpos = newPos;
465  picpos = newPos + eX * 2 * newSize.y;
466  }
467  else // left align
468  {
469  numpos = newPos + eX * newSize.y;
470  picpos = newPos;
471  }
472 
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);
477 }
478 
479 void DrawNumIcon(vector myPos, vector mySize, float theTime, string icon, bool vertical, bool isInfinite, int icon_right_align, vector color, float theAlpha)
480 {
481  TC(bool, vertical); TC(int, icon_right_align);
482  DrawNumIcon_expanding(myPos, mySize, theTime, icon, vertical, isInfinite, icon_right_align, color, theAlpha, 0);
483 }
484 
485 /*
486 ==================
487 Main HUD system
488 ==================
489 */
490 
491 float lasthud;
494 {
495  if(autocvar__hud_configure) return;
496  if(intermission == 2) return;
497 
498  if(hud == HUD_BUMBLEBEE_GUN)
499  CSQC_BUMBLE_GUN_HUD();
500  else {
501  Vehicle info = REGISTRY_GET(Vehicles, hud);
502  info.vr_hud(info);
503  }
504 
505  if(hud != HUD_NORMAL && lasthud == HUD_NORMAL)
507 
508  lasthud = hud;
509 }
510 
511 void HUD_Panel_Draw(entity panent)
512 {
513  panel = panent;
515  {
516  if (!(panel.panel_configflags & PANEL_CONFIG_MAIN))
517  return;
518  panel_fade_alpha = 1;
520  panel.panel_draw();
521  return;
522  }
523 
524  bool draw_allowed = false;
525  if (scoreboard_fade_alpha && panel.panel_showflags & PANEL_SHOW_WITH_SB)
526  {
527  draw_allowed = true;
528  }
530  {
531  if (panel.panel_showflags & PANEL_SHOW_MINIGAME)
532  draw_allowed = true;
533  }
534  else if(intermission == 2)
535  {
536  if(panel.panel_showflags & PANEL_SHOW_MAPVOTE)
537  draw_allowed = true;
538  }
539  else if (panel.panel_showflags & PANEL_SHOW_MAINGAME)
540  draw_allowed = true;
541 
542  if (draw_allowed)
543  {
544  if (panel.panel_showflags & PANEL_SHOW_WITH_SB)
545  {
546  if (scoreboard_fade_alpha && intermission == 2 && !(panel.panel_showflags & PANEL_SHOW_MAPVOTE))
548  else
549  panel_fade_alpha = 1;
550  }
551  else
552  {
554  if(!panel_fade_alpha)
555  return;
556  }
557  panel.panel_draw();
558  }
559 }
560 
561 void HUD_Reset()
562 {
563  // reset gametype specific icons
564  if(gametype.m_modicons_reset)
565  gametype.m_modicons_reset();
566 }
567 
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};
575 {
576  if(time - hud_dynamic_shake_time < 0)
577  return false;
578 
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);
582  if(i >= 9)
583  return false;
584 
585  float f = elapsed_time - i;
592  return true;
593 }
594 
596 {
597  vector ofs = '0 0 0';
598  hud_scale_current = '1 1 0';
599  hud_shift_current = '0 0 0';
600 
602  {
604  calc_followmodel_ofs(view);
609 
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);
616 
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;
620 
623  }
624 
626  {
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
630  {
632  old_health = health;
633  }
634  else
635  {
636  float new_hud_dynamic_shake_factor = 0;
637  if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
639  && old_health > 0 && !intermission)
640  {
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)
646  {
647  hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
649  }
650  }
651  old_health = health;
653  if(!Hud_Shake_Update())
655  }
656 
658  {
661  }
662  }
663 
664  hud_scale_center.x = 0.5 * vid_conwidth;
666 
668 }
669 
671 {
673  return true;
674  if(mv_active)
675  return true;
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))
678  //return true;
679  if(HUD_Radar_Clickable())
680  return true;
682  return true;
683  if(QuickMenu_IsOpened())
684  return true;
685  return false;
686 }
687 
689 void HUD_Main()
690 {
691  int i;
692  if(hud_configure_menu_open == 1)
693  hud_fade_alpha = 1;
694  else
696 
697  if(myteam != prev_myteam)
698  {
699  myteamcolors = colormapPaletteColor(myteam, 1);
700  FOREACH(hud_panels, true, it.update_time = time);
701  prev_myteam = myteam;
702  }
703 
705 
706  if(scoreboard_fade_alpha == 1)
707  if(autocvar__menu_alpha == 1)
708  return;
709 
710  // Drawing stuff
712  {
715  }
716 
717  // draw the dock
718  if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
719  {
720  int f;
721  vector color;
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;
726  else
727  color = myteamcolors * hud_dock_color_team;
728  }
729  else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
730  color = '1 0 0' * hud_dock_color_team;
731  }
732  else
733  {
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);
738  }
739  else if(hud_dock_color == "pants") {
740  f = entcs_GetClientColors(current_player);
741  color = colormapPaletteColor(f % 16, 1);
742  }
743  else
744  color = stov(hud_dock_color);
745  }
746 
747  string pic;
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";
753  }
754  }
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...
756  }
757 
758  // cache the panel order into the panel_order array
760  for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i)
761  panel_order[i] = -1;
762  string s = "";
763  int p_num;
764  bool warning = false;
766  if (argc > REGISTRY_COUNT(hud_panels))
767  warning = true;
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
775  }
776  else
777  warning = true;
778  }
779  for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
780  if (panel_order[i] == -1) {
781  warning = true;
782  s = strcat(s, ftos(i), " "); //add missing panel number
783  }
784  }
785  if (warning)
786  LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder");
787 
788  cvar_set("_hud_panelorder", s);
790 
791  //now properly set panel_order
792  tokenize_console(s);
793  for(i = 0; i < REGISTRY_COUNT(hud_panels); ++i) {
794  panel_order[i] = stof(argv(i));
795  }
796  }
797 
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]));
802 
803  HUD_Vehicle();
804 
805  hud_draw_maximized = 1; // panels that may be maximized must check this var
806  // draw maximized panels on top
808  HUD_Panel_Draw(HUD_PANEL(RADAR));
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));
814 
815  int cursor_active_prev = cursor_active;
817  if (cursor_active_prev != cursor_active && autocvar_hud_cursormode)
818  {
819  setcursormode(cursor_active);
820  // cursor inactive this frame, will be set to 1 the next frame
821  if (cursor_active)
822  cursor_active = -1;
823  }
824 
825  if (intermission == 2)
826  HUD_Reset();
827 
829 
831 }
vector color
float vh_notice_time
Definition: hud.qc:492
float vid_conheight
void HUD_Configure_Frame()
Definition: hud_config.qc:1063
float autocvar_hud_dynamic_follow_scale
Definition: hud.qh:205
float panel_bg_border
Definition: hud.qh:169
string panel_bg_alpha_str
Definition: hud.qh:168
bool hud_panel_radar_maximized
Definition: hud.qh:69
float panel_fg_alpha
Definition: hud.qh:166
string panel_bg_color_team_str
Definition: hud.qh:165
void HUD_Panel_Draw(entity panent)
Definition: hud.qc:511
float current_player
Definition: hud.qh:182
const int NUM_SPECTATOR
Definition: teams.qh:23
float panel_bg_color_team
Definition: hud.qh:164
void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
Definition: hud.qc:377
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:270
void drawstring_aspect(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag)
Definition: draw.qc:102
vector hud_scale
Definition: hud.qh:216
entity highlightedPanel
Definition: hud.qh:106
const int PANEL_SHOW_WITH_SB
Definition: hud.qh:228
const vector eY
Definition: vector.qh:45
ERASEABLE float blink(float base, float range, float freq)
Definition: util.qc:2044
#define HUD_Panel_GetBg()
Definition: hud.qh:286
entity CSQCModel_server2csqc(int i)
Definition: cl_model.qc:314
float HUD_GetRowCount(int item_count, vector size, float item_aspect)
Definition: hud.qc:165
vector autocvar_hud_dynamic_follow_scale_xyz
Definition: hud.qh:206
vector SIZE_CURSOR
Definition: hud.qh:7
float autocvar_hud_dynamic_shake_damage_min
Definition: hud.qc:570
void HUD_Vehicle()
Definition: hud.qc:493
bool HUD_MinigameMenu_IsOpened()
bool autocvar__hud_configure
Definition: hud_config.qh:3
string panel_bg_border_str
Definition: hud.qh:170
vector hud_dynamic_shake_realofs
Definition: hud.qh:208
float panel_fade_alpha
Definition: hud.qh:410
vector hud_scale_current
Definition: hud.qh:217
string draw_currentSkin
Definition: util.qh:45
bool autocvar_hud_dock_color_team
Definition: hud.qh:192
vector panel_size
Definition: hud.qh:160
void HUD_Reset()
Definition: hud.qc:561
entity() spawn
#define REGISTRY_GET(id, i)
Definition: registry.qh:43
bool hud_draw_maximized
Definition: hud.qh:68
int panel_order[REGISTRY_MAX(hud_panels)]
Definition: hud.qh:65
float intermission
Definition: csprogsdefs.qc:148
float hud_dynamic_shake_factor
Definition: hud.qh:209
float autocvar_hud_dock_alpha
Definition: hud.qh:190
void draw_cursor_normal(vector pos, vector col, float a)
Definition: hud.qc:37
#define HUD_ShiftX(f)
Definition: hud.qh:17
const float FILE_READ
Definition: csprogsdefs.qc:231
vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
Definition: hud.qc:172
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:479
void HUD_Scale_Disable()
Definition: hud.qc:83
const int PANEL_CONFIG_MAIN
Definition: hud.qh:232
vector drawfontscale
Definition: draw.qh:3
float hud_dynamic_shake_x[10]
Definition: hud.qc:572
#define HUD_Panel_GetPadding()
Definition: hud.qh:380
vector size
Definition: csprogsdefs.qc:114
#define HUD_Panel_GetColorTeam()
Definition: hud.qh:336
float vid_conwidth
const int PANEL_SHOW_MINIGAME
Definition: hud.qh:226
float mv_active
Definition: mapvoting.qh:19
#define HUD_ScaleX(f)
Definition: hud.qh:15
#define HUD_Panel_GetFgAlpha()
Definition: hud.qh:363
float autocvar_hud_dynamic_shake_scale
Definition: hud.qc:571
bool HUD_WouldShowCursor()
Definition: hud.qc:670
float autocvar_hud_dynamic_follow
Definition: hud.qh:204
#define strcpy(this, s)
Definition: string.qh:49
#define stoi(s)
Definition: int.qh:4
#define REGISTRY_COUNT(id)
Definition: registry.qh:18
string hud_skin_prev
Definition: hud.qh:134
vector hud_scale_center
Definition: hud.qh:220
string panel_bg_str
Definition: hud.qh:161
bool HUD_Radar_Clickable()
Definition: radar.qc:25
#define argv_end_index
Definition: dpextensions.qh:30
string hud_skin_path
Definition: hud.qh:133
void LoadMenuSkinValues()
Definition: hud.qc:42
float autocvar__menu_alpha
Definition: hud.qh:184
void calc_followmodel_ofs(entity view)
Definition: view.qc:112
#define HUD_Panel_GetBgAlpha()
Definition: hud.qh:346
void HUD_Scale_Enable()
Definition: hud.qc:90
entity active_minigame
Definition: cl_minigames.qh:85
#define drawpic_aspect_skin(pos, pic, sz, color, theAlpha, drawflag)
Definition: draw.qh:78
vector HUD_Shift(vector v)
Definition: hud.qc:104
void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float theAlpha, float drawflag, float fadelerp)
Definition: draw.qc:131
void drawpic_aspect_skin_expanding(vector position, string pic, vector theScale, vector rgb, float theAlpha, float flag, float fadelerp)
Definition: draw.qc:61
int cursor_active
Definition: view.qh:108
#define argv_start_index
Definition: dpextensions.qh:27
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
vector HUD_GetFontsize(string cvarname)
Definition: hud.qc:111
float lasthud
Definition: hud.qc:491
float height
Definition: jumppads.qh:12
vector myteamcolors
Definition: hud.qh:136
string panel_bg_color_str
Definition: hud.qh:163
string panel_bg_padding_str
Definition: hud.qh:172
void Hud_Dynamic_Frame()
Definition: hud.qc:595
vector HUD_Scale(vector v)
Definition: hud.qc:97
float prev_myteam
Definition: hud.qc:688
float hud_dynamic_shake_y[10]
Definition: hud.qc:573
float panel_bg_alpha
Definition: hud.qh:167
const int PANEL_SHOW_MAINGAME
Definition: hud.qh:225
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
entity gametype
Definition: main.qh:30
entity panel
Definition: hud.qh:144
#define TC(T, sym)
Definition: _all.inc:82
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:398
vector panel_pos
Definition: hud.qh:159
float teamplay
Definition: progsdefs.qc:31
#define Hud_Panel_GetPanelEnabled()
Definition: hud.qh:413
float player_localentnum
Definition: csprogsdefs.qc:19
string autocvar_hud_dock
Definition: hud.qh:189
#define CASE_COLOR_BETWEEN(min, max)
void HUD_Configure_PostDraw()
Definition: hud_config.qc:1113
#define HUD_Panel_UpdatePosSize_ForMenu()
Definition: hud.qh:391
float autocvar_hud_dynamic_shake_damage_max
Definition: hud.qc:569
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define tokenize_console
Definition: dpextensions.qh:24
const float M_PI
Definition: csprogsdefs.qc:269
const int PANEL_SHOW_MAPVOTE
Definition: hud.qh:227
vector v
Definition: ent_cs.qc:116
bool autocvar__con_chat_maximized
Definition: chat.qh:6
vector cl_followmodel_ofs
Definition: hud.qh:213
bool QuickMenu_IsOpened()
Definition: quickmenu.qc:244
#define HUD_Panel_GetColor()
Definition: hud.qh:312
const vector eX
Definition: vector.qh:44
#define LOG_TRACE(...)
Definition: log.qh:81
vector hud_shift
Definition: hud.qh:218
float health
Definition: progsdefs.qc:137
#define HUD_ScaleY(f)
Definition: hud.qh:16
float hud_dynamic_shake_time
Definition: hud.qh:210
float autocvar_cl_vehicles_notify_time
Definition: cl_vehicles.qh:6
string hud_panelorder_prev
Definition: hud.qh:66
#define HUD_ShiftY(f)
Definition: hud.qh:18
vector HUD_Get_Num_Color(float hp, float maxvalue, bool blink)
Definition: hud.qc:123
#define vec2(...)
Definition: vector.qh:90
float drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag)
float hud_configure_prev
Definition: hud_config.qh:17
bool autocvar_hud_configure_teamcolorforced
Definition: hud_config.qh:7
float hud_configure_menu_open
Definition: hud_config.qh:21
float hud_fade_alpha
Definition: hud.qh:131
#define HUD_Panel_ScalePosSize()
Definition: hud.qh:405
bool Hud_Shake_Update()
Definition: hud.qc:574
string autocvar_hud_skin
Definition: hud.qh:200
#define HUD_Panel_GetBorder()
Definition: hud.qh:370
vector hud_shift_current
Definition: hud.qh:219
if(IS_DEAD(this))
Definition: impulse.qc:92
string autocvar_hud_dock_color
Definition: hud.qh:191
void draw_cursor(vector pos, vector ofs, string img, vector col, float a)
Definition: hud.qc:31
float time
Definition: csprogsdefs.qc:16
string autocvar__hud_panelorder
Definition: hud.qh:186
float autocvar_hud_panel_update_interval
Definition: hud.qh:202
#define FOREACH(list, cond, body)
Definition: iter.qh:19
#define HUD_PANEL(NAME)
Definition: hud.qh:51
void HUD_Main()
Definition: hud.qc:689
vector OFFSET_CURSOR
Definition: hud.qh:6
bool autocvar_hud_cursormode
Definition: hud.qh:188
#define colormapPaletteColor(c, isPants)
Definition: color.qh:5
float scoreboard_fade_alpha
Definition: scoreboard.qh:10
void HUD_Panel_LoadCvars()
Definition: hud.qc:216
float panel_bg_padding
Definition: hud.qh:171
int hud
Definition: main.qh:142
float autocvar_hud_dynamic_shake
Definition: hud.qc:568
vector panel_bg_color
Definition: hud.qh:162