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