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