2015-05-01 17:37:17 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2016-02-22 14:20:36 +00:00
|
|
|
#include "XEH_PREP.hpp"
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Cache config
|
|
|
|
// Items in the inventory display can all use lb data to get their classname (exception: backpacks, handled separately)
|
2019-02-17 17:41:48 +00:00
|
|
|
private _allItems = ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgWeapons"));
|
|
|
|
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgGlasses"));
|
2024-01-06 21:26:46 +00:00
|
|
|
_allItems append ("getNumber (_x >> 'scope') > 0" configClasses (configFile >> "CfgMagazines"));
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
uiNamespace setVariable [QGVAR(itemKeyCache), compileFinal ((_allItems apply {configName _x}) createHashMapFromArray _allItems)];
|
|
|
|
|
|
|
|
// Backpacks in the inventory display can only be distinguished by their lb names and pictures, lb data returns ""
|
|
|
|
_allItems = "getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'isBackpack') == 1}" configClasses (configFile >> "CfgVehicles");
|
|
|
|
|
|
|
|
uiNamespace setVariable [QGVAR(backpackKeyCache), compileFinal createHashMapFromArray (_allItems apply {
|
2019-02-17 17:41:48 +00:00
|
|
|
private _displayName = getText (_x >> "displayName");
|
|
|
|
private _picture = getText (_x >> "picture");
|
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// List box seems to delete the leading backslash
|
|
|
|
if (_picture select [0, 1] == "\") then {
|
2019-02-17 17:41:48 +00:00
|
|
|
_picture = _picture select [1];
|
|
|
|
};
|
2024-01-01 21:35:44 +00:00
|
|
|
if (count _picture > 0 && !(_picture regexMatch ".*?\.paa")) then { // handle missing file extension
|
|
|
|
if (!fileExists (_picture + ".paa")) exitWith {};
|
|
|
|
_picture = _picture + ".paa";
|
|
|
|
};
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Handle missing file extension, as inventory returns path with extension
|
|
|
|
if (count _picture > 0 && !(_picture regexMatch ".*?\.paa")) then {
|
|
|
|
if (!fileExists (_picture + ".paa")) exitWith {};
|
|
|
|
_picture = _picture + ".paa";
|
|
|
|
};
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Listboxes store pictures as lowercase
|
|
|
|
[format ["%1:%2", _displayName, toLower _picture], _x]
|
|
|
|
})];
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Generate list of grenades
|
|
|
|
private _cfgThrow = configFile >> "CfgWeapons" >> "Throw";
|
|
|
|
private _grenadeList = createHashMap;
|
2019-02-17 17:41:48 +00:00
|
|
|
|
|
|
|
{
|
2024-01-06 21:26:46 +00:00
|
|
|
_grenadeList insert [true, (getArray (_cfgThrow >> _x >> "magazines")) apply {_x call EFUNC(common,getConfigName)}, []];
|
|
|
|
} forEach getArray (_cfgThrow >> "muzzles");
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
uiNamespace setVariable [QGVAR(grenadesItemList), compileFinal _grenadeList];
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
// Generate list of medical items
|
|
|
|
private _medicalList = QUOTE(getNumber (_x >> 'scope') > 0 && {getNumber (_x >> 'ItemInfo' >> 'type') in [ARR_2(TYPE_FIRST_AID_KIT,TYPE_MEDIKIT)]}) configClasses (configFile >> "CfgWeapons");
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
_medicalList = _medicalList apply {configName _x};
|
2019-02-17 17:41:48 +00:00
|
|
|
|
2024-01-06 21:26:46 +00:00
|
|
|
uiNamespace setVariable [QGVAR(medicalItemList), compileFinal (_medicalList createHashMapFromArray [])];
|