ACE3/addons/disarming/functions/fnc_showItemsInListbox.sqf

61 lines
2.2 KiB
Plaintext
Raw Normal View History

2015-02-27 21:23:46 +00:00
/*
* Author: PabstMirror
* Shows a list of inventory items in a listBox control.
2015-02-27 21:23:46 +00:00
*
* Arguments:
* 0: RscListBox <CONTROL>
2015-03-21 01:17:49 +00:00
* 1: ItemArray [["itemClassnames"],[counts]] <ARRAY>
2015-02-27 21:23:46 +00:00
*
* Return Value:
* Nothing
*
* Example:
* [theListBox, [["ace_bandage"],[2]]] call ace_disarming_fnc_showItemsInListbox
*
* Public: No
*/
#include "script_component.hpp"
disableSerialization;
PARAMS_2(_listBoxCtrl,_itemsCountArray);
2015-04-16 17:36:12 +00:00
private ["_classname", "_count", "_displayName", "_picture"];
2015-03-21 01:17:49 +00:00
2015-02-27 21:23:46 +00:00
{
_displayName = "";
_picture = "";
2015-03-21 01:17:49 +00:00
_classname = _x;
2015-02-27 21:23:46 +00:00
_count = (_itemsCountArray select 1) select _forEachIndex;
2015-03-21 01:17:49 +00:00
if (_classname != DUMMY_ITEM) then { //Don't show the dummy potato
2015-04-04 05:52:21 +00:00
2015-03-21 01:17:49 +00:00
switch (true) do {
case (isClass (configFile >> "CfgWeapons" >> _classname)): {
_displayName = getText (configFile >> "CfgWeapons" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgWeapons" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgMagazines" >> _classname)): {
_displayName = getText (configFile >> "CfgMagazines" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgMagazines" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgVehicles" >> _classname)): {
_displayName = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgVehicles" >> _classname >> "picture");
};
case (isClass (configFile >> "CfgGlasses" >> _classname)): {
_displayName = getText (configFile >> "CfgGlasses" >> _classname >> "displayName");
_picture = getText (configFile >> "CfgGlasses" >> _classname >> "picture");
};
2015-04-04 05:52:21 +00:00
default {
ERROR(format ["[%1] - bad classname", _classname]);
};
2015-02-27 21:23:46 +00:00
};
2015-03-21 01:17:49 +00:00
_listBoxCtrl lbAdd format ["%1", _displayName];
_listBoxCtrl lbSetData [_forEachIndex, _classname];
_listBoxCtrl lbSetPicture [_forEachIndex, _picture];
_listBoxCtrl lbSetTextRight [_forEachIndex, str _count];
};
2015-02-27 21:23:46 +00:00
} forEach (_itemsCountArray select 0);