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