//	@file Version: 1.0
//	@file Name: ADP_F_fillItems.sqf
//	@file Author: THumbert
//	@file Created: 12/14/2013
//	@file Description: Fills listbox with Vehicles

#define ARRAYCHECK(a,b) [##a,##b] call {_veh = _this select 0;_types = _this select 1;_res = false; {if (_veh isKindOf _x) exitwith { _res = true };} forEach _types;_res}
disableSerialization;
private ["_VehicleMake"];
_disp = _this select 0;
_control = _this select 1;
_type = _this select 2;
_display = findDisplay _disp;
_ctrl = _display displayctrl _control;

_Listbox = _control;

switch (_type) do
{
	case 0: {_VehicleMake = ["truck","truck_F","car","Motorcycle"];};
	case 1: {_VehicleMake = ["tank","Wheeled_APC","Wheeled_APC_F","Tracked_APC"];};
	case 2: {_VehicleMake = ["ship","Submarine"];};
	case 10:{_VehicleMake = ["tank","ship","Wheeled_APC","Wheeled_APC_F","Tracked_APC","truck","truck_F","car","Motorcycle","Submarine"];};
};	
_Value = 4; //Used for Spawn
_filter = [];
lbClear _Listbox;
ListContents = "Vehicles";
hint "Adding Vehicles";
_cfgvehicles = configFile >> "cfgVehicles";
for "_i" from 0 to (count _cfgvehicles)-1 do {
	_vehicle = _cfgvehicles select _i;
	if (isClass _vehicle) then {
		_vehicleType = configName(_vehicle);
		if ((getNumber(_vehicle >> "scope")==2)and(getText(_vehicle >> "picture")!="")and(ARRAYCHECK(_vehicleType,_VehicleMake))) then {
			_Text = (getText(_vehicle >> "displayName"));
			_index = lbAdd [_ListBox, _Text];
			lbSetData [_listbox,_index,_vehicletype];
			lbSetPicture [_listbox,_index,getText(_vehicle >> "picture")];
			lbSetValue [_listbox, _index,_Value];
		};
	};
};
lbsort _ctrl;