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