]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/hud.qc
Make the scoreboard a panel
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / hud.qc
1 #include "hud.qh"
2
3 #include "hud_config.qh"
4 #include "../mapvoting.qh"
5 #include "../scoreboard.qh"
6 #include "../teamradar.qh"
7 #include <common/t_items.qh>
8 #include <common/deathtypes/all.qh>
9 #include <common/items/all.qc>
10 #include <common/mapinfo.qh>
11 #include <common/vehicles/all.qh>
12 #include <common/mutators/mutator/waypoints/all.qh>
13 #include <common/stats.qh>
14 #include <lib/csqcmodel/cl_player.qh>
15 #include <server/mutators/mutator/gamemode_ctf.qh> // TODO: remove
16
17
18 /*
19 ==================
20 Misc HUD functions
21 ==================
22 */
23
24 vector HUD_Get_Num_Color (float x, float maxvalue)
25 {
26         float blinkingamt;
27         vector color;
28         if(x >= maxvalue) {
29                 color.x = sin(2*M_PI*time);
30                 color.y = 1;
31                 color.z = sin(2*M_PI*time);
32         }
33         else if(x > maxvalue * 0.75) {
34                 color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
35                 color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
36                 color.z = 0;
37         }
38         else if(x > maxvalue * 0.5) {
39                 color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
40                 color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
41                 color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
42         }
43         else if(x > maxvalue * 0.25) {
44                 color.x = 1;
45                 color.y = 1;
46                 color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
47         }
48         else if(x > maxvalue * 0.1) {
49                 color.x = 1;
50                 color.y = (x-20)*90/27/100; // green value between 0 -> 1
51                 color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
52         }
53         else {
54                 color.x = 1;
55                 color.y = 0;
56                 color.z = 0;
57         }
58
59         blinkingamt = (1 - x/maxvalue/0.25);
60         if(blinkingamt > 0)
61         {
62                 color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
63                 color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
64                 color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
65         }
66         return color;
67 }
68
69 float HUD_GetRowCount(int item_count, vector size, float item_aspect)
70 {
71     TC(int, item_count);
72         float aspect = size_y / size_x;
73         return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
74 }
75
76 vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect)
77 {
78     TC(int, item_count);
79         float columns, rows;
80         float ratio, best_ratio = 0;
81         float best_columns = 1, best_rows = 1;
82         bool vertical = (psize.x / psize.y >= item_aspect);
83         if(vertical)
84         {
85                 psize = eX * psize.y + eY * psize.x;
86                 item_aspect = 1 / item_aspect;
87         }
88
89         rows = ceil(sqrt(item_count));
90         columns = ceil(item_count/rows);
91         while(columns >= 1)
92         {
93                 ratio = (psize.x/columns) / (psize.y/rows);
94                 if(ratio > item_aspect)
95                         ratio = item_aspect * item_aspect / ratio;
96
97                 if(ratio <= best_ratio)
98                         break; // ratio starts decreasing by now, skip next configurations
99
100                 best_columns = columns;
101                 best_rows = rows;
102                 best_ratio = ratio;
103
104                 if(columns == 1)
105                         break;
106
107                 --columns;
108                 rows = ceil(item_count/columns);
109         }
110
111         if(vertical)
112                 return eX * best_rows + eY * best_columns;
113         else
114                 return eX * best_columns + eY * best_rows;
115 }
116
117 /*
118 ==================
119 HUD panels
120 ==================
121 */
122
123 //basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
124 void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
125 {
126     TC(bool, vertical); TC(int, drawflag);
127         if(!length_ratio || !theAlpha)
128                 return;
129         if(length_ratio > 1)
130                 length_ratio = 1;
131         if (baralign == 3)
132         {
133                 if(length_ratio < -1)
134                         length_ratio = -1;
135         }
136         else if(length_ratio < 0)
137                 return;
138
139         theOrigin = HUD_Shift(theOrigin);
140         theSize = HUD_Scale(theSize);
141
142         vector square;
143         vector width, height;
144         if(vertical) {
145                 pic = strcat(hud_skin_path, "/", pic, "_vertical");
146                 if(precache_pic(pic) == "") {
147                         pic = "gfx/hud/default/progressbar_vertical";
148                 }
149
150         if (baralign == 1) // bottom align
151                         theOrigin.y += (1 - length_ratio) * theSize.y;
152         else if (baralign == 2) // center align
153             theOrigin.y += 0.5 * (1 - length_ratio) * theSize.y;
154         else if (baralign == 3) // center align, positive values down, negative up
155                 {
156                         theSize.y *= 0.5;
157                         if (length_ratio > 0)
158                                 theOrigin.y += theSize.y;
159                         else
160                         {
161                                 theOrigin.y += (1 + length_ratio) * theSize.y;
162                                 length_ratio = -length_ratio;
163                         }
164                 }
165                 theSize.y *= length_ratio;
166
167                 vector bH;
168                 width = eX * theSize.x;
169                 height = eY * theSize.y;
170                 if(theSize.y <= theSize.x * 2)
171                 {
172                         // button not high enough
173                         // draw just upper and lower part then
174                         square = eY * theSize.y * 0.5;
175                         bH = eY * (0.25 * theSize.y / (theSize.x * 2));
176                         drawsubpic(theOrigin,          square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag);
177                         drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag);
178                 }
179                 else
180                 {
181                         square = eY * theSize.x;
182                         drawsubpic(theOrigin,                   width   +     square, pic, '0 0    0', '1 0.25 0', theColor, theAlpha, drawflag);
183                         drawsubpic(theOrigin +          square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5  0', theColor, theAlpha, drawflag);
184                         drawsubpic(theOrigin + height - square, width   +     square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag);
185                 }
186         } else {
187                 pic = strcat(hud_skin_path, "/", pic);
188                 if(precache_pic(pic) == "") {
189                         pic = "gfx/hud/default/progressbar";
190                 }
191
192                 if (baralign == 1) // right align
193                         theOrigin.x += (1 - length_ratio) * theSize.x;
194         else if (baralign == 2) // center align
195             theOrigin.x += 0.5 * (1 - length_ratio) * theSize.x;
196         else if (baralign == 3) // center align, positive values on the right, negative on the left
197                 {
198                         theSize.x *= 0.5;
199                         if (length_ratio > 0)
200                                 theOrigin.x += theSize.x;
201                         else
202                         {
203                                 theOrigin.x += (1 + length_ratio) * theSize.x;
204                                 length_ratio = -length_ratio;
205                         }
206                 }
207                 theSize.x *= length_ratio;
208
209                 vector bW;
210                 width = eX * theSize.x;
211                 height = eY * theSize.y;
212                 if(theSize.x <= theSize.y * 2)
213                 {
214                         // button not wide enough
215                         // draw just left and right part then
216                         square = eX * theSize.x * 0.5;
217                         bW = eX * (0.25 * theSize.x / (theSize.y * 2));
218                         drawsubpic(theOrigin,          square + height, pic, '0 0 0', eY + bW, theColor, theAlpha, drawflag);
219                         drawsubpic(theOrigin + square, square + height, pic, eX - bW, eY + bW, theColor, theAlpha, drawflag);
220                 }
221                 else
222                 {
223                         square = eX * theSize.y;
224                         drawsubpic(theOrigin,                  height  +     square, pic, '0    0 0', '0.25 1 0', theColor, theAlpha, drawflag);
225                         drawsubpic(theOrigin +         square, theSize - 2 * square, pic, '0.25 0 0', '0.5  1 0', theColor, theAlpha, drawflag);
226                         drawsubpic(theOrigin + width - square, height  +     square, pic, '0.75 0 0', '0.25 1 0', theColor, theAlpha, drawflag);
227                 }
228         }
229 }
230
231 void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theAlpha, int drawflag)
232 {
233     TC(int, drawflag);
234         if(!theAlpha)
235                 return;
236
237         pos = HUD_Shift(pos);
238         mySize = HUD_Scale(mySize);
239
240         string pic;
241         pic = strcat(hud_skin_path, "/num_leading");
242         if(precache_pic(pic) == "") {
243                 pic = "gfx/hud/default/num_leading";
244         }
245
246         drawsubpic(pos, eX * min(mySize.x * 0.5, mySize.y) + eY * mySize.y, pic, '0 0 0', '0.25 1 0', color, theAlpha, drawflag);
247         if(mySize.x/mySize.y > 2)
248                 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);
249         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);
250 }
251
252 void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, bool vertical, int icon_right_align, vector color, float theAlpha, float fadelerp)
253 {
254     TC(bool, vertical); TC(int, icon_right_align);
255         vector newPos = '0 0 0', newSize = '0 0 0';
256         vector picpos, numpos;
257
258         if (vertical)
259         {
260                 if(mySize.y/mySize.x > 2)
261                 {
262                         newSize.y = 2 * mySize.x;
263                         newSize.x = mySize.x;
264
265                         newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
266                         newPos.x = myPos.x;
267                 }
268                 else
269                 {
270                         newSize.x = 1/2 * mySize.y;
271                         newSize.y = mySize.y;
272
273                         newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
274                         newPos.y = myPos.y;
275                 }
276
277                 if(icon_right_align)
278                 {
279                         numpos = newPos;
280                         picpos = newPos + eY * newSize.x;
281                 }
282                 else
283                 {
284                         picpos = newPos;
285                         numpos = newPos + eY * newSize.x;
286                 }
287
288                 newSize.y /= 2;
289                 drawpic_aspect_skin(picpos, icon, newSize, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
290                 // make number smaller than icon, it looks better
291                 // reduce only y to draw numbers with different number of digits with the same y size
292                 numpos.y += newSize.y * ((1 - 0.7) / 2);
293                 newSize.y *= 0.7;
294                 drawstring_aspect(numpos, ftos(x), newSize, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
295                 return;
296         }
297
298         if(mySize.x/mySize.y > 3)
299         {
300                 newSize.x = 3 * mySize.y;
301                 newSize.y = mySize.y;
302
303                 newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
304                 newPos.y = myPos.y;
305         }
306         else
307         {
308                 newSize.y = 1/3 * mySize.x;
309                 newSize.x = mySize.x;
310
311                 newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
312                 newPos.x = myPos.x;
313         }
314
315         if(icon_right_align) // right align
316         {
317                 numpos = newPos;
318                 picpos = newPos + eX * 2 * newSize.y;
319         }
320         else // left align
321         {
322                 numpos = newPos + eX * newSize.y;
323                 picpos = newPos;
324         }
325
326         // NOTE: newSize_x is always equal to 3 * mySize_y so we can use
327         // '2 1 0' * newSize_y instead of eX * (2/3) * newSize_x + eY * newSize_y
328         drawstring_aspect_expanding(numpos, ftos(x), '2 1 0' * newSize.y, color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
329         drawpic_aspect_skin_expanding(picpos, icon, '1 1 0' * newSize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, fadelerp);
330 }
331
332 void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertical, int icon_right_align, vector color, float theAlpha)
333 {
334     TC(bool, vertical); TC(int, icon_right_align);
335         DrawNumIcon_expanding(myPos, mySize, x, icon, vertical, icon_right_align, color, theAlpha, 0);
336 }
337
338 #include "all.inc"
339
340 /*
341 ==================
342 Main HUD system
343 ==================
344 */
345
346 void CSQC_BUMBLE_GUN_HUD();
347
348 void HUD_Vehicle()
349 {
350         if(autocvar__hud_configure) return;
351         if(intermission == 2) return;
352
353         if(hud == HUD_BUMBLEBEE_GUN)
354                 CSQC_BUMBLE_GUN_HUD();
355         else {
356                 Vehicle info = Vehicles_from(hud);
357                 info.vr_hud(info);
358         }
359 }
360
361 bool HUD_Panel_CheckFlags(int showflags)
362 {
363     TC(int, showflags);
364         if ( HUD_Minigame_Showpanels() )
365                 return showflags & PANEL_SHOW_MINIGAME;
366         if(intermission == 2)
367                 return showflags & PANEL_SHOW_MAPVOTE;
368         return showflags & PANEL_SHOW_MAINGAME;
369 }
370
371 void HUD_Panel_Draw(entity panent)
372 {
373         panel = panent;
374         if(autocvar__hud_configure)
375         {
376                 if(panel.panel_configflags & PANEL_CONFIG_MAIN)
377                         panel.panel_draw();
378         }
379         else if(HUD_Panel_CheckFlags(panel.panel_showflags))
380                 panel.panel_draw();
381 }
382
383 void HUD_Reset()
384 {
385         // reset gametype specific icons
386         if(gametype == MAPINFO_TYPE_CTF)
387                 HUD_Mod_CTF_Reset();
388 }
389
390 float autocvar_hud_dynamic_shake = 1;
391 float autocvar_hud_dynamic_shake_damage_max = 130;
392 float autocvar_hud_dynamic_shake_damage_min = 10;
393 float autocvar_hud_dynamic_shake_scale = 0.2;
394 float hud_dynamic_shake_x[10] = {0,    1, -0.7,  0.5, -0.3,  0.2, -0.1,  0.1,  0.0, 0};
395 float hud_dynamic_shake_y[10] = {0,  0.4,  0.8, -0.2, -0.6,  0.0,  0.3,  0.1, -0.1, 0};
396 bool Hud_Shake_Update()
397 {
398         if(time - hud_dynamic_shake_time < 0)
399                 return false;
400
401         float anim_speed = 17 + 9 * hud_dynamic_shake_factor;
402         float elapsed_time = (time - hud_dynamic_shake_time) * anim_speed;
403         int i = floor(elapsed_time);
404         if(i >= 9)
405                 return false;
406
407         float f = elapsed_time - i;
408         hud_dynamic_shake_realofs.x = (1 - f) * hud_dynamic_shake_x[i] + f * hud_dynamic_shake_x[i+1];
409         hud_dynamic_shake_realofs.y = (1 - f) * hud_dynamic_shake_y[i] + f * hud_dynamic_shake_y[i+1];
410         hud_dynamic_shake_realofs.z = 0;
411         hud_dynamic_shake_realofs *= hud_dynamic_shake_factor * autocvar_hud_dynamic_shake_scale;
412         hud_dynamic_shake_realofs.x = bound(-0.1, hud_dynamic_shake_realofs.x, 0.1) * vid_conwidth;
413         hud_dynamic_shake_realofs.y = bound(-0.1, hud_dynamic_shake_realofs.y, 0.1) * vid_conheight;
414         return true;
415 }
416
417 void calc_followmodel_ofs(entity view);
418 void Hud_Dynamic_Frame()
419 {
420         vector ofs = '0 0 0';
421         hud_scale = '1 1 0';
422         hud_shift = '0 0 0';
423         if (autocvar_hud_dynamic_follow)
424         {
425                 entity view = CSQCModel_server2csqc(player_localentnum - 1);
426                 calc_followmodel_ofs(view);
427                 ofs = -cl_followmodel_ofs * autocvar_hud_dynamic_follow_scale;
428                 ofs.x *= autocvar_hud_dynamic_follow_scale_xyz.z;
429                 ofs.y *= autocvar_hud_dynamic_follow_scale_xyz.x;
430                 ofs.z *= autocvar_hud_dynamic_follow_scale_xyz.y;
431
432                 if (fabs(ofs.x) < 0.001) ofs.x = 0;
433                 if (fabs(ofs.y) < 0.001) ofs.y = 0;
434                 if (fabs(ofs.z) < 0.001) ofs.z = 0;
435                 ofs.x = bound(-0.1, ofs.x, 0.1);
436                 ofs.y = bound(-0.1, ofs.y, 0.1);
437                 ofs.z = bound(-0.1, ofs.z, 0.1);
438
439                 hud_shift.x = ofs.y * vid_conwidth;
440                 hud_shift.y = ofs.z * vid_conheight;
441                 hud_shift.z = ofs.x;
442
443                 hud_scale.x = (1 + hud_shift.z);
444                 hud_scale.y = hud_scale.x;
445         }
446
447         if(autocvar_hud_dynamic_shake > 0)
448         {
449                 static float old_health = 0;
450                 float health = max(-1, STAT(HEALTH));
451                 if(hud_dynamic_shake_factor == -1) // don't allow the effect for this frame
452                 {
453                         hud_dynamic_shake_factor = 0;
454                         old_health = health;
455                 }
456                 else
457                 {
458                         float new_hud_dynamic_shake_factor = 0;
459                         if (old_health - health >= autocvar_hud_dynamic_shake_damage_min
460                                 && autocvar_hud_dynamic_shake_damage_max > autocvar_hud_dynamic_shake_damage_min
461                                 && old_health > 0 && !intermission)
462                         {
463                                 float m = max(autocvar_hud_dynamic_shake_damage_min, 1);
464                                 new_hud_dynamic_shake_factor = (old_health - health - m) / (autocvar_hud_dynamic_shake_damage_max - m);
465                                 if(new_hud_dynamic_shake_factor >= 1)
466                                         new_hud_dynamic_shake_factor = 1;
467                                 if(new_hud_dynamic_shake_factor >= hud_dynamic_shake_factor)
468                                 {
469                                         hud_dynamic_shake_factor = new_hud_dynamic_shake_factor;
470                                         hud_dynamic_shake_time = time;
471                                 }
472                         }
473                         old_health = health;
474                         if(hud_dynamic_shake_factor)
475                                 if(!Hud_Shake_Update())
476                                         hud_dynamic_shake_factor = 0;
477                 }
478
479                 if(hud_dynamic_shake_factor > 0)
480                 {
481                         hud_shift.x += hud_dynamic_shake_realofs.x;
482                         hud_shift.y += hud_dynamic_shake_realofs.y;
483                 }
484         }
485
486         hud_scale_center.x = 0.5 * vid_conwidth;
487         hud_scale_center.y = 0.5 * vid_conheight;
488
489         hud_scale_current = hud_scale;
490         hud_shift_current = hud_shift;
491 }
492
493 // Scoreboard panel
494 //
495 void HUD_DrawScoreboard();
496 void HUD_Scoreboard(void)
497 {
498         HUD_DrawScoreboard();
499 }
500
501 void HUD_Main()
502 {
503         int i;
504         // global hud alpha fade (scoreboard-related panels behave differently and override it temporarly)
505         if(menu_enabled == 1)
506                 hud_fade_alpha = 1;
507         else if(!autocvar__hud_configure)
508                 hud_fade_alpha = (1 - scoreboard_fade_alpha) * (1 - autocvar__menu_alpha);
509         else
510                 hud_fade_alpha = 1 - autocvar__menu_alpha;
511
512         HUD_Configure_Frame();
513
514         Hud_Dynamic_Frame();
515
516         // panels that we want to be active together with the scoreboard
517         // they must fade only when the menu does
518         if(scoreboard_fade_alpha == 1)
519         {
520                 if(autocvar__menu_alpha == 1)
521                         return;
522                 if(scoreboard_fade_alpha == 1)
523                 {
524                         HUD_Panel_Draw(HUD_PANEL(SCOREBOARD));
525                         HUD_Panel_Draw(HUD_PANEL(CENTERPRINT));
526                         return;
527                 }
528         }
529
530         if(!autocvar__hud_configure && !hud_fade_alpha)
531         {
532                 hud_fade_alpha = 1;
533                 HUD_Panel_Draw(HUD_PANEL(VOTE));
534                 hud_fade_alpha = 0;
535                 return;
536         }
537
538         // Drawing stuff
539         if (hud_skin_prev != autocvar_hud_skin)
540         {
541                 if (hud_skin_path)
542                         strunzone(hud_skin_path);
543                 hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
544                 if (hud_skin_prev)
545                         strunzone(hud_skin_prev);
546                 hud_skin_prev = strzone(autocvar_hud_skin);
547         }
548
549         // draw the dock
550         if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
551         {
552                 int f;
553                 vector color;
554                 float hud_dock_color_team = autocvar_hud_dock_color_team;
555                 if((teamplay) && hud_dock_color_team) {
556                         if(autocvar__hud_configure && myteam == NUM_SPECTATOR)
557                                 color = '1 0 0' * hud_dock_color_team;
558                         else
559                                 color = myteamcolors * hud_dock_color_team;
560                 }
561                 else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
562                         color = '1 0 0' * hud_dock_color_team;
563                 }
564                 else
565                 {
566                         string hud_dock_color = autocvar_hud_dock_color;
567                         if(hud_dock_color == "shirt") {
568                                 f = stof(getplayerkeyvalue(current_player, "colors"));
569                                 color = colormapPaletteColor(floor(f / 16), 0);
570                         }
571                         else if(hud_dock_color == "pants") {
572                                 f = stof(getplayerkeyvalue(current_player, "colors"));
573                                 color = colormapPaletteColor(f % 16, 1);
574                         }
575                         else
576                                 color = stov(hud_dock_color);
577                 }
578
579                 string pic;
580                 pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
581                 if(precache_pic(pic) == "") {
582                         pic = strcat(hud_skin_path, "/dock_medium");
583                         if(precache_pic(pic) == "") {
584                                 pic = "gfx/hud/default/dock_medium";
585                         }
586                 }
587                 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...
588         }
589
590         // cache the panel order into the panel_order array
591         if(autocvar__hud_panelorder != hud_panelorder_prev) {
592                 for(i = 0; i < hud_panels_COUNT; ++i)
593                         panel_order[i] = -1;
594                 string s = "";
595                 int p_num;
596                 bool warning = false;
597                 int argc = tokenize_console(autocvar__hud_panelorder);
598                 if (argc > hud_panels_COUNT)
599                         warning = true;
600                 //first detect wrong/missing panel numbers
601                 for(i = 0; i < hud_panels_COUNT; ++i) {
602                         p_num = stoi(argv(i));
603                         if (p_num >= 0 && p_num < hud_panels_COUNT) { //correct panel number?
604                                 if (panel_order[p_num] == -1) //found for the first time?
605                                         s = strcat(s, ftos(p_num), " ");
606                                 panel_order[p_num] = 1; //mark as found
607                         }
608                         else
609                                 warning = true;
610                 }
611                 for(i = 0; i < hud_panels_COUNT; ++i) {
612                         if (panel_order[i] == -1) {
613                                 warning = true;
614                                 s = strcat(s, ftos(i), " "); //add missing panel number
615                         }
616                 }
617                 if (warning)
618                         LOG_TRACE("Automatically fixed wrong/missing panel numbers in _hud_panelorder\n");
619
620                 cvar_set("_hud_panelorder", s);
621                 if(hud_panelorder_prev)
622                         strunzone(hud_panelorder_prev);
623                 hud_panelorder_prev = strzone(s);
624
625                 //now properly set panel_order
626                 tokenize_console(s);
627                 for(i = 0; i < hud_panels_COUNT; ++i) {
628                         panel_order[i] = stof(argv(i));
629                 }
630         }
631
632         hud_draw_maximized = 0;
633         // draw panels in the order specified by panel_order array
634         for(i = hud_panels_COUNT - 1; i >= 0; --i)
635                 HUD_Panel_Draw(hud_panels_from(panel_order[i]));
636
637         HUD_Vehicle();
638
639         hud_draw_maximized = 1; // panels that may be maximized must check this var
640         // draw maximized panels on top
641         if(hud_panel_radar_maximized)
642                 HUD_Panel_Draw(HUD_PANEL(RADAR));
643         if(autocvar__con_chat_maximized)
644                 HUD_Panel_Draw(HUD_PANEL(CHAT));
645         if(hud_panel_quickmenu)
646                 HUD_Panel_Draw(HUD_PANEL(QUICKMENU));
647
648         if (scoreboard_active || intermission == 2)
649                 HUD_Reset();
650
651         HUD_Configure_PostDraw();
652
653         hud_configure_prev = autocvar__hud_configure;
654 }