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