ACE3/addons/inventory/XEH_postInit.sqf

81 lines
2.9 KiB
Plaintext
Raw Normal View History

2015-12-11 00:02:15 +00:00
#include "script_component.hpp"
if (!hasInterface) exitWith {};
// cache config
// items in the inventory display can only be distinguished by their lb names and pictures
// this can cause collisions (mainly weapons with attachments),
// but if the item has the same name and picture it at least shouldn't change the filter anyway
// luckily we don't need private items, so dummy and parent classes are out of the picture
GVAR(ItemKeyNamespace) = [] call CBA_fnc_createNamespace;
private _fnc_addToCache = {
private _displayName = getText (_this >> "displayName");
private _picture = getText (_this >> "picture");
// list box seems to delete the leading backslash
if (_picture select [0,1] == "\") then {
_picture = _picture select [1];
};
GVAR(ItemKeyNamespace) setVariable [format ["%1:%2", _displayName, _picture], _this];
};
2016-03-06 06:14:43 +00:00
private _allItems = [];
2016-03-06 06:14:43 +00:00
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgWeapons"));
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses"));
_allItems append ("getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgMagazines"));
_allItems append ("getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles"));
2016-03-06 06:14:43 +00:00
{_x call _fnc_addToCache; false} count _allItems;
2015-12-11 00:02:15 +00:00
GVAR(customFilters) = [];
GVAR(selectedFilterIndex) = -1;
// add custom filters
2015-12-11 12:14:58 +00:00
// generate list of grenades
GVAR(Grenades_ItemList) = [];
2015-12-11 00:02:15 +00:00
2015-12-11 12:14:58 +00:00
{
GVAR(Grenades_ItemList) append getArray (configFile >> "CfgWeapons" >> "Throw" >> _x >> "magazines");
false
} count getArray (configFile >> "CfgWeapons" >> "Throw" >> "muzzles");
2015-12-11 00:02:15 +00:00
2015-12-11 12:14:58 +00:00
// make list case insensitive
2016-02-06 11:08:04 +00:00
GVAR(Grenades_ItemList) = GVAR(Grenades_ItemList) apply {toLower _x};
2015-12-11 00:02:15 +00:00
2015-12-11 12:14:58 +00:00
// filter duplicates
GVAR(Grenades_ItemList) = GVAR(Grenades_ItemList) arrayIntersect GVAR(Grenades_ItemList);
2015-12-11 00:02:15 +00:00
2015-12-11 12:14:58 +00:00
[localize LSTRING(Grenades), QFUNC(filterGrenades)] call FUNC(addCustomFilter);
[localize LSTRING(Backpacks), QFUNC(filterBackpacks)] call FUNC(addCustomFilter);
[localize LSTRING(Uniforms), QFUNC(filterUniforms)] call FUNC(addCustomFilter);
2015-12-11 00:02:15 +00:00
[localize LSTRING(Vests), QFUNC(filterVests)] call FUNC(addCustomFilter);
2015-12-11 12:14:58 +00:00
[localize LSTRING(Headgear), QFUNC(filterHeadgear)] call FUNC(addCustomFilter);
// generate list of medical items
GVAR(Medical_ItemList) = [];
{
GVAR(Medical_ItemList) append getArray (_x >> "items");
false
} count (
("true" configClasses (configFile >> QEGVAR(Medical,Actions) >> "Basic")) +
("true" configClasses (configFile >> QEGVAR(Medical,Actions) >> "Advanced"))
);
2016-02-06 13:59:31 +00:00
// remove all numbers from list
GVAR(Medical_ItemList) = GVAR(Medical_ItemList) select {_x isEqualType ""};
2015-12-11 12:14:58 +00:00
// make list case insensitive
2016-02-06 13:59:31 +00:00
GVAR(Medical_ItemList) = GVAR(Medical_ItemList) apply {toLower _x};
2015-12-11 12:14:58 +00:00
// filter duplicates
GVAR(Medical_ItemList) = GVAR(Medical_ItemList) arrayIntersect GVAR(Medical_ItemList);
[localize LSTRING(Medical), QFUNC(filterMedical)] call FUNC(addCustomFilter);