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