ACE3/addons/disarming/functions/fnc_showItemsInListbox.sqf
2015-03-17 14:43:50 -05:00

51 lines
1.7 KiB
Plaintext

/*
* Author: PabstMirror
* Shows a list of inventory items in a listBox control.
*
* Arguments:
* 0: RscListBox <CONTROL>
* 1: ItemArray [["items"],[counts]] <ARRAY>
*
* Return Value:
* Nothing
*
* Example:
* [theListBox, [["ace_bandage"],[2]]] call ace_disarming_fnc_showItemsInListbox
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
PARAMS_2(_listBoxCtrl,_itemsCountArray);
{
_displayName = "";
_picture = "";
_count = (_itemsCountArray select 1) select _forEachIndex;
switch (true) do {
case (isClass (configFile >> "CfgWeapons" >> _x)): {
_displayName = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
_picture = getText (configFile >> "CfgWeapons" >> _x >> "picture");
};
case (isClass (configFile >> "CfgMagazines" >> _x)): {
_displayName = getText (configFile >> "CfgMagazines" >> _x >> "displayName");
_picture = getText (configFile >> "CfgMagazines" >> _x >> "picture");
};
case (isClass (configFile >> "CfgVehicles" >> _x)): {
_displayName = getText (configFile >> "CfgVehicles" >> _x >> "displayName");
_picture = getText (configFile >> "CfgVehicles" >> _x >> "picture");
};
case (isClass (configFile >> "CfgGlasses" >> _x)): {
_displayName = getText (configFile >> "CfgGlasses" >> _x >> "displayName");
_picture = getText (configFile >> "CfgGlasses" >> _x >> "picture");
};
};
_listBoxCtrl lbAdd format ["%1", _displayName];
_listBoxCtrl lbSetData [_forEachIndex, _x];
_listBoxCtrl lbSetPicture [_forEachIndex, _picture];
_listBoxCtrl lbSetTextRight [_forEachIndex, str _count];
} forEach (_itemsCountArray select 0);