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