]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/hud/panel/weapons.qc
Merge branch 'Mario/crouch' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / weapons.qc
1 #include "weapons.qh"
2
3 #include <client/autocvars.qh>
4 #include <client/defs.qh>
5 #include <client/miscfunctions.qh>
6 #include <client/view.qh>
7 #include <common/wepent.qh>
8
9 // Weapons (#0)
10
11 entity weaponorder[Weapons_MAX];
12 void weaponorder_swap(int i, int j, entity pass)
13 {
14     TC(int, i); TC(int, j);
15         entity h = weaponorder[i];
16         weaponorder[i] = weaponorder[j];
17         weaponorder[j] = h;
18 }
19
20 string weaponorder_cmp_str;
21 int weaponorder_cmp(int i, int j, entity pass)
22 {
23     TC(int, i); TC(int, j);
24         int ai = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[i].m_id), 0);
25         int aj = strstrofs(weaponorder_cmp_str, sprintf(" %d ", weaponorder[j].m_id), 0);
26         return aj - ai; // the string is in REVERSE order (higher prio at the right is what we want, but higher prio first is the string)
27 }
28
29 #define HUD_WEAPONS_GET_FULL_LAYOUT() MACRO_BEGIN { \
30         int nHidden = 0; \
31         FOREACH(Weapons, it != WEP_Null, { \
32                 if (weapons_stat & WepSet_FromWeapon(it)) continue; \
33                 if ((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)) nHidden += 1; \
34         }); \
35         vector table_size = HUD_GetTableSize_BestItemAR((Weapons_COUNT - 1) - nHidden, panel_size, aspect); \
36         columns = table_size.x; \
37         rows = table_size.y; \
38         weapon_size.x = panel_size.x / columns; \
39         weapon_size.y = panel_size.y / rows; \
40 } MACRO_END
41
42 void HUD_Weapons()
43 {
44         // declarations
45         WepSet weapons_stat = WepSet_GetFromStat();
46         int i;
47         float f, a;
48         float screen_ar;
49         vector center = '0 0 0';
50         int weapon_count, weapon_id;
51         int row, column, rows = 0, columns = 0;
52         bool vertical_order = true;
53         float aspect = autocvar_hud_panel_weapons_aspect;
54
55         float timeout = autocvar_hud_panel_weapons_timeout;
56         float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
57         float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
58
59         vector barsize = '0 0 0', baroffset = '0 0 0';
60         vector ammo_color = '1 0 1';
61         float ammo_alpha = 1;
62
63         float when = max(1, autocvar_hud_panel_weapons_complainbubble_time);
64         float fadetime = max(0, autocvar_hud_panel_weapons_complainbubble_fadetime);
65
66         bool infinite_ammo = (STAT(ITEMS) & IT_UNLIMITED_WEAPON_AMMO);
67
68         vector weapon_pos, weapon_size = '0 0 0';
69         vector color;
70
71         entity panel_switchweapon = NULL;
72
73         // check to see if we want to continue
74         if(hud != HUD_NORMAL) return;
75
76         if(!autocvar__hud_configure)
77         {
78                 if((!autocvar_hud_panel_weapons) || (spectatee_status == -1))
79                         return;
80                 if(STAT(HEALTH) <= 0 && autocvar_hud_panel_weapons_hide_ondeath)
81                         return;
82                 if(timeout && time >= weapontime + timeout + timeout_effect_length)
83                 if(autocvar_hud_panel_weapons_timeout_effect == 3 || (autocvar_hud_panel_weapons_timeout_effect == 1 && !(autocvar_hud_panel_weapons_timeout_fadebgmin + autocvar_hud_panel_weapons_timeout_fadefgmin)))
84                 {
85                         weaponprevtime = time;
86                         return;
87                 }
88         }
89
90         // update generic hud functions
91         HUD_Panel_LoadCvars();
92
93         // figure out weapon order (how the weapons are sorted) // TODO make this configurable
94         if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
95         {
96                 int weapon_cnt;
97                 if(weaponorder_bypriority)
98                         strunzone(weaponorder_bypriority);
99                 if(weaponorder_byimpulse)
100                         strunzone(weaponorder_byimpulse);
101
102                 weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
103                 weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
104                 weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
105
106                 weapon_cnt = 0;
107                 FOREACH(Weapons, it != WEP_Null && it.impulse >= 0, weaponorder[weapon_cnt++] = it);
108                 for(i = weapon_cnt; i < Weapons_MAX; ++i)
109                         weaponorder[i] = NULL;
110                 heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, NULL);
111
112                 weaponorder_cmp_str = string_null;
113         }
114
115         if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
116                 complain_weapon = 0;
117
118         if(autocvar__hud_configure)
119         {
120                 if(!weapons_stat)
121                 {
122                         int j = 0;
123                         FOREACH(Weapons, it != WEP_Null && it.impulse >= 0 && (it.impulse % 3 != 0) && j < 6, {
124                                 if(!(it.spawnflags & WEP_FLAG_MUTATORBLOCKED))
125                                 {
126                                         if(!panel_switchweapon || j < 4)
127                                                 panel_switchweapon = it;
128                                         weapons_stat |= it.m_wepset;
129                                         ++j;
130                                 }
131                         });
132                 }
133
134                 #if 0
135                 /// debug code
136                 if(cvar("wep_add"))
137                 {
138                         int j;
139                         int nHidden = 0;
140                         FOREACH(Weapons, it != WEP_Null, {
141                                 if (it.spawnflags & WEP_FLAG_MUTATORBLOCKED) nHidden += 1;
142                         });
143                         weapons_stat = '0 0 0';
144                         float countw = 1 + floor((floor(time * cvar("wep_add"))) % ((Weapons_COUNT - 1) - nHidden));
145                         for(i = 0, j = 0; i <= (Weapons_COUNT - 1) && j < countw; ++i)
146                         {
147                                 if(weaponorder[i].spawnflags & WEP_FLAG_MUTATORBLOCKED)
148                                         continue;
149                                 weapons_stat |= weaponorder[i].m_wepset;
150                                 ++j;
151                         }
152                 }
153                 #endif
154         }
155
156         // determine which weapons are going to be shown
157         if (autocvar_hud_panel_weapons_onlyowned)
158         {
159                 if(autocvar__hud_configure)
160                 {
161                         if(hud_configure_menu_open != 2)
162                                 HUD_Panel_DrawBg(); // also draw the bg of the entire panel
163                 }
164
165                 // do we own this weapon?
166                 weapon_count = 0;
167                 for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
168                         if((weapons_stat & WepSet_FromWeapon(weaponorder[i])) || (weaponorder[i].m_id == complain_weapon))
169                                 ++weapon_count;
170
171
172                 // might as well commit suicide now, no reason to live ;)
173                 if (weapon_count == 0)
174                         return;
175
176                 vector old_panel_size = panel_size;
177                 panel_size -= '2 2 0' * panel_bg_padding;
178
179                 HUD_WEAPONS_GET_FULL_LAYOUT();
180
181                 // NOTE: although weapons should aways look the same even if onlyowned is enabled,
182                 // we enlarge them a bit when possible to better match the desired aspect ratio
183                 if(panel_size.x / panel_size.y < aspect)
184                 {
185                         // maximum number of rows that allows to display items with the desired aspect ratio
186                         int max_rows = floor(panel_size.y / (weapon_size.x / aspect));
187                         columns = min(columns, ceil(weapon_count / max_rows));
188                         rows = ceil(weapon_count / columns);
189                         weapon_size.y = min(panel_size.y / rows, weapon_size.x / aspect);
190                         weapon_size.x = min(panel_size.x / columns, aspect * weapon_size.y);
191                         vertical_order = false;
192                 }
193                 else
194                 {
195                         int max_columns = floor(panel_size.x / (weapon_size.y * aspect));
196                         rows = min(rows, ceil(weapon_count / max_columns));
197                         columns = ceil(weapon_count / rows);
198                         weapon_size.x = min(panel_size.x / columns, aspect * weapon_size.y);
199                         weapon_size.y = min(panel_size.y / rows, weapon_size.x / aspect);
200                         vertical_order = true;
201                 }
202
203                 // reduce size of the panel
204                 panel_size.x = columns * weapon_size.x;
205                 panel_size.y = rows * weapon_size.y;
206                 panel_size += '2 2 0' * panel_bg_padding;
207
208                 // center the resized panel, or snap it to the screen edge when close enough
209                 if(panel_pos.x > vid_conwidth * 0.001)
210                 {
211                         if(panel_pos.x + old_panel_size.x > vid_conwidth * 0.999)
212                                 panel_pos.x += old_panel_size.x - panel_size.x;
213                         else
214                                 panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
215                 }
216                 else if(old_panel_size.x > vid_conwidth * 0.999)
217                         panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
218
219                 if(panel_pos.y > vid_conheight * 0.001)
220                 {
221                         if(panel_pos.y + old_panel_size.y > vid_conheight * 0.999)
222                                 panel_pos.y += old_panel_size.y - panel_size.y;
223                         else
224                                 panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
225                 }
226                 else if(old_panel_size.y > vid_conheight * 0.999)
227                         panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
228         }
229         else
230                 weapon_count = (Weapons_COUNT - 1);
231
232         // animation for fading in/out the panel respectively when not in use
233         if(!autocvar__hud_configure)
234         {
235                 if (timeout && time >= weapontime + timeout) // apply timeout effect if needed
236                 {
237                         f = bound(0, (time - (weapontime + timeout)) / timeout_effect_length, 1);
238
239                         // fade the panel alpha
240                         if(autocvar_hud_panel_weapons_timeout_effect == 1)
241                         {
242                                 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * f + (1 - f));
243                                 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * f + (1 - f));
244                         }
245                         else if(autocvar_hud_panel_weapons_timeout_effect == 3)
246                         {
247                                 panel_bg_alpha *= (1 - f);
248                                 panel_fg_alpha *= (1 - f);
249                         }
250
251                         // move the panel off the screen
252                         if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
253                         {
254                                 f *= f; // for a cooler movement
255                                 center.x = panel_pos.x + panel_size.x/2;
256                                 center.y = panel_pos.y + panel_size.y/2;
257                                 screen_ar = vid_conwidth/vid_conheight;
258                                 if (center.x/center.y < screen_ar) //bottom left
259                                 {
260                                         if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
261                                                 panel_pos.y += f * (vid_conheight - panel_pos.y);
262                                         else //left
263                                                 panel_pos.x -= f * (panel_pos.x + panel_size.x);
264                                 }
265                                 else //top right
266                                 {
267                                         if ((vid_conwidth - center.x)/center.y < screen_ar) //right
268                                                 panel_pos.x += f * (vid_conwidth - panel_pos.x);
269                                         else //top
270                                                 panel_pos.y -= f * (panel_pos.y + panel_size.y);
271                                 }
272                                 if(f == 1)
273                                         center.x = -1; // mark the panel as off screen
274                         }
275                         weaponprevtime = time - (1 - f) * timein_effect_length;
276                 }
277                 else if (timeout && time < weaponprevtime + timein_effect_length) // apply timein effect if needed
278                 {
279                         f = bound(0, (time - weaponprevtime) / timein_effect_length, 1);
280
281                         // fade the panel alpha
282                         if(autocvar_hud_panel_weapons_timeout_effect == 1)
283                         {
284                                 panel_bg_alpha *= (autocvar_hud_panel_weapons_timeout_fadebgmin * (1 - f) + f);
285                                 panel_fg_alpha *= (autocvar_hud_panel_weapons_timeout_fadefgmin * (1 - f) + f);
286                         }
287                         else if(autocvar_hud_panel_weapons_timeout_effect == 3)
288                         {
289                                 panel_bg_alpha *= (f);
290                                 panel_fg_alpha *= (f);
291                         }
292
293                         // move the panel back on screen
294                         if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
295                         {
296                                 f *= f; // for a cooler movement
297                                 f = 1 - f;
298                                 center.x = panel_pos.x + panel_size.x/2;
299                                 center.y = panel_pos.y + panel_size.y/2;
300                                 screen_ar = vid_conwidth/vid_conheight;
301                                 if (center.x/center.y < screen_ar) //bottom left
302                                 {
303                                         if ((vid_conwidth - center.x)/center.y < screen_ar) //bottom
304                                                 panel_pos.y += f * (vid_conheight - panel_pos.y);
305                                         else //left
306                                                 panel_pos.x -= f * (panel_pos.x + panel_size.x);
307                                 }
308                                 else //top right
309                                 {
310                                         if ((vid_conwidth - center.x)/center.y < screen_ar) //right
311                                                 panel_pos.x += f * (vid_conwidth - panel_pos.x);
312                                         else //top
313                                                 panel_pos.y -= f * (panel_pos.y + panel_size.y);
314                                 }
315                         }
316                 }
317         }
318
319         // draw the background, then change the virtual size of it to better fit other items inside
320         if (autocvar_hud_panel_weapons_dynamichud)
321                 HUD_Scale_Enable();
322         else
323                 HUD_Scale_Disable();
324         HUD_Panel_DrawBg();
325
326         if(center.x == -1)
327                 return; // panel has gone off screen
328
329         if(panel_bg_padding)
330         {
331                 panel_pos += '1 1 0' * panel_bg_padding;
332                 panel_size -= '2 2 0' * panel_bg_padding;
333         }
334
335         // after the sizing and animations are done, update the other values
336
337         if(!rows) // if rows is > 0 onlyowned code has already updated these vars
338         {
339                 HUD_WEAPONS_GET_FULL_LAYOUT();
340                 vertical_order = (panel_size.x / panel_size.y >= aspect);
341         }
342
343         // calculate position/size for visual bar displaying ammount of ammo status
344         if (!infinite_ammo && autocvar_hud_panel_weapons_ammo)
345         {
346                 ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
347                 ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
348
349                 if(weapon_size.x/weapon_size.y > aspect)
350                 {
351                         barsize.x = aspect * weapon_size.y;
352                         barsize.y = weapon_size.y;
353                         baroffset.x = (weapon_size.x - barsize.x) / 2;
354                 }
355                 else
356                 {
357                         barsize.y = 1/aspect * weapon_size.x;
358                         barsize.x = weapon_size.x;
359                         baroffset.y = (weapon_size.y - barsize.y) / 2;
360                 }
361         }
362         if(autocvar_hud_panel_weapons_accuracy)
363                 Accuracy_LoadColors();
364
365         // draw items
366         row = column = 0;
367         vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1);
368         vector noncurrent_size = weapon_size * bound(0.01, autocvar_hud_panel_weapons_noncurrent_scale, 1);
369         float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1);
370         static vector weapon_pos_current = '-1 0 0';
371         if(weapon_pos_current.x == -1)
372                 weapon_pos_current = panel_pos;
373
374         float switch_speed;
375         if(autocvar_hud_panel_weapons_selection_speed <= 0 || autocvar__hud_configure)
376                 switch_speed = 999;
377         else
378                 switch_speed = frametime * autocvar_hud_panel_weapons_selection_speed;
379         vector radius_size = weapon_size * (autocvar_hud_panel_weapons_selection_radius + 1);
380
381         entity wepent = viewmodels[0]; // TODO: unhardcode
382
383         if(wepent.switchweapon == WEP_Null)
384                 panel_switchweapon = NULL;
385         else if(!panel_switchweapon)
386                 panel_switchweapon = wepent.switchweapon;
387
388         // draw background behind currently selected weapon
389         // do it earlier to make sure bg is drawn behind every weapon icons while it's moving
390         if(panel_switchweapon)
391                 drawpic_aspect_skin(weapon_pos_current, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
392
393         for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
394         {
395                 // retrieve information about the current weapon to be drawn
396                 entity it = weaponorder[i];
397                 weapon_id = it.impulse;
398
399                 // skip if this weapon doesn't exist
400                 if(!it || weapon_id < 0) { continue; }
401
402                 // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon
403                 if(autocvar_hud_panel_weapons_onlyowned)
404                 {
405                         if (!((weapons_stat & WepSet_FromWeapon(it)) || (it.m_id == complain_weapon)))
406                                 continue;
407                 }
408                 else
409                 {
410                         if (((it.spawnflags & WEP_FLAG_HIDDEN) || (it.spawnflags & WEP_FLAG_MUTATORBLOCKED)) && !(weapons_stat & WepSet_FromWeapon(it)))
411                                 continue;
412                 }
413
414                 // figure out the drawing position of weapon
415                 weapon_pos = panel_pos + vec2(column * weapon_size.x, row * weapon_size.y);
416
417                 // update position of the currently selected weapon
418                 if(it == panel_switchweapon)
419                 {
420                         if(weapon_pos_current.y > weapon_pos.y)
421                                 weapon_pos_current.y = max(weapon_pos.y, weapon_pos_current.y - switch_speed * (weapon_pos_current.y - weapon_pos.y));
422                         else if(weapon_pos_current.y < weapon_pos.y)
423                                 weapon_pos_current.y = min(weapon_pos.y, weapon_pos_current.y + switch_speed * (weapon_pos.y - weapon_pos_current.y));
424                         if(weapon_pos_current.x > weapon_pos.x)
425                                 weapon_pos_current.x = max(weapon_pos.x, weapon_pos_current.x - switch_speed * (weapon_pos_current.x - weapon_pos.x));
426                         else if(weapon_pos_current.x < weapon_pos.x)
427                                 weapon_pos_current.x = min(weapon_pos.x, weapon_pos_current.x + switch_speed * (weapon_pos.x - weapon_pos_current.x));
428                 }
429
430                 // draw the weapon accuracy
431                 if(autocvar_hud_panel_weapons_accuracy)
432                 {
433                         float panel_weapon_accuracy = weapon_accuracy[it.m_id-WEP_FIRST];
434                         if(panel_weapon_accuracy >= 0)
435                         {
436                                 color = Accuracy_GetColor(panel_weapon_accuracy);
437                                 drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL);
438                         }
439                 }
440
441                 vector weapon_size_real = noncurrent_size;
442                 float weapon_alpha_real = noncurrent_alpha;
443                 float radius_factor_x = 1 - bound(0, fabs(weapon_pos.x - weapon_pos_current.x) / radius_size.x, 1);
444                 float radius_factor_y = 1 - bound(0, fabs(weapon_pos.y - weapon_pos_current.y) / radius_size.y, 1);
445                 if(radius_factor_x || radius_factor_y)
446                 {
447                         weapon_size_real.x += (weapon_size.x - noncurrent_size.x) * radius_factor_x;
448                         weapon_size_real.y += (weapon_size.y - noncurrent_size.y) * radius_factor_y;
449                         weapon_alpha_real += (panel_fg_alpha - noncurrent_alpha) * min(radius_factor_x, radius_factor_y);
450                 }
451
452                 vector weapon_pos_real = weapon_pos;
453                 weapon_pos_real.x = weapon_pos.x + (weapon_size.x - weapon_size_real.x) / 2;
454                 weapon_pos_real.y = weapon_pos.y + (weapon_size.y - weapon_size_real.y) / 2;
455
456                 // drawing all the weapon items
457                 if(weapons_stat & WepSet_FromWeapon(it))
458                 {
459                         // draw the weapon image
460                         drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '1 1 1', weapon_alpha_real, DRAWFLAG_NORMAL);
461
462                         // draw weapon label string
463                         switch(autocvar_hud_panel_weapons_label)
464                         {
465                                 case 1: // weapon number
466                                         drawstring(weapon_pos, ftos(weapon_id), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
467                                         break;
468
469                                 case 2: // bind
470                                         drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("weapon_group_", ftos(weapon_id))), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
471                                         break;
472
473                                 case 3: // weapon name
474                                         drawstring(weapon_pos, strtolower(it.m_name), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
475                                         break;
476
477                                 default: // nothing
478                                         break;
479                         }
480
481                         // draw ammo status bar
482                         if(!infinite_ammo && autocvar_hud_panel_weapons_ammo && (it.ammo_type != RESOURCE_NONE))
483                         {
484                                 float ammo_full;
485                                 a = getstati(GetAmmoStat(it.ammo_type)); // how much ammo do we have?
486
487                                 if(a > 0)
488                                 {
489                                         switch (it.ammo_type)
490                                         {
491                                                 case RESOURCE_SHELLS:  ammo_full = autocvar_hud_panel_weapons_ammo_full_shells;  break;
492                                                 case RESOURCE_BULLETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails;   break;
493                                                 case RESOURCE_ROCKETS: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break;
494                                                 case RESOURCE_CELLS:   ammo_full = autocvar_hud_panel_weapons_ammo_full_cells;   break;
495                                                 case RESOURCE_PLASMA:  ammo_full = autocvar_hud_panel_weapons_ammo_full_plasma;  break;
496                                                 case RESOURCE_FUEL:    ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel;    break;
497                                                 default: ammo_full = 60;
498                                         }
499
500                                         drawsetcliparea(
501                                                 weapon_pos.x + baroffset.x,
502                                                 weapon_pos.y + baroffset.y,
503                                                 barsize.x * bound(0, a/ammo_full, 1),
504                                                 barsize.y
505                                         );
506
507                                         drawpic_aspect_skin(
508                                                 weapon_pos,
509                                                 "weapon_ammo",
510                                                 weapon_size,
511                                                 ammo_color,
512                                                 ammo_alpha,
513                                                 DRAWFLAG_NORMAL
514                                         );
515
516                                         drawresetcliparea();
517                                 }
518                         }
519                 }
520                 else // draw a "ghost weapon icon" if you don't have the weapon
521                 {
522                         drawpic_aspect_skin(weapon_pos_real, it.model2, weapon_size_real, '0.2 0.2 0.2', weapon_alpha_real * 0.5, DRAWFLAG_NORMAL);
523                 }
524
525                 // draw the complain message
526                 if(it.m_id == complain_weapon)
527                 {
528                         if(fadetime)
529                                 a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1));
530                         else
531                                 a = ((complain_weapon_time + when > time) ? 1 : 0);
532
533                         string s;
534                         if(complain_weapon_type == 0) {
535                                 s = _("Out of ammo");
536                                 color = stov(autocvar_hud_panel_weapons_complainbubble_color_outofammo);
537                         }
538                         else if(complain_weapon_type == 1) {
539                                 s = _("Don't have");
540                                 color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
541                         }
542                         else {
543                                 s = _("Unavailable");
544                                 color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
545                         }
546                         float padding = autocvar_hud_panel_weapons_complainbubble_padding;
547                         drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
548                         drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
549                 }
550
551                 #if 0
552                 /// debug code
553                 if(!autocvar_hud_panel_weapons_onlyowned)
554                 {
555                         drawfill(weapon_pos + '1 1 0', weapon_size - '2 2 0', '1 1 1', panel_fg_alpha * 0.2, DRAWFLAG_NORMAL);
556                         drawstring(weapon_pos, ftos(i + 1), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
557                 }
558                 #endif
559
560                 // continue with new position for the next weapon
561                 if(vertical_order)
562                 {
563                         ++column;
564                         if(column >= columns)
565                         {
566                                 column = 0;
567                                 ++row;
568                         }
569                 }
570                 else
571                 {
572                         ++row;
573                         if(row >= rows)
574                         {
575                                 row = 0;
576                                 ++column;
577                         }
578                 }
579         }
580 }