ACE3/addons/arsenal/functions/fnc_addListBoxItem.sqf
jonpas 76e1aafb33
Use function documentation script (#6897)
Co-authored-by: Björn Dahlgren <bjorn@dahlgren.io>
2023-04-30 23:03:35 +02:00

63 lines
2.2 KiB
Plaintext

#include "script_component.hpp"
/*
* Author: Dedmen
* Add a listbox row.
*
* Arguments:
* 0: Config category, must be "CfgWeapons", "CfgVehicles", "CfgMagazines", "CfgVoice" <STRING>
* 1: Classname <STRING>
* 2: Panel control <CONTROL>
* 3: Name of the picture entry in that Cfg class <STRING>
*
* Return Value:
* None
*
* Example:
* ["CfgWeapons", "launch_NLAW_F", _ctrl, "icon"] call ace_arsenal_fnc_addListBoxItem
*
* Public: Yes
*/
params ["_configCategory", "_className", "_ctrlPanel", ["_pictureEntryName", "picture", [""]]];
private _cacheNamespace = _ctrlPanel; //For better readability.
private _cachedItemInfo = _cacheNamespace getVariable [_configCategory+_className, []];
//_cachedItemInfo == [_displayName, _itemPicture, _modPicture]
if (_cachedItemInfo isEqualTo []) then {//Not in cache. So get info and put into cache.
private _configPath = configFile >> _configCategory >> _className;
_cachedItemInfo set [0, getText (_configPath >> "displayName")];
//if _pictureEntryName is empty then this item has no Icons. (Faces)
_cachedItemInfo set [1, if (_pictureEntryName isEqualTo "") then {""} else {getText (_configPath >> _pictureEntryName)}];
//get name of DLC
private _dlcName = "";
private _addons = configsourceaddonlist _configPath;
if (_addons isNotEqualTo []) then {
private _mods = configsourcemodlist (configfile >> "CfgPatches" >> _addons select 0);
if (_mods isNotEqualTo []) then {
_dlcName = _mods select 0;
};
};
if (_dlcName != "") then {
_cachedItemInfo set [2, (modParams [_dlcName,["logo"]]) param [0,""]];//mod picture
} else {
_cachedItemInfo set [2, ""];//mod picture
_cachedItemInfo set [3, 0];//mod ID
};
_cacheNamespace setVariable [_configCategory+_className, _cachedItemInfo];
};
_cachedItemInfo params ["_displayName", "_itemPicture", "_modPicture"];
private _lbAdd = _ctrlPanel lbAdd _displayName;
_ctrlPanel lbSetData [_lbAdd, _className];
_ctrlPanel lbSetPicture [_lbAdd, _itemPicture];
_ctrlPanel lbSetPictureRight [_lbAdd,["",_modPicture] select (GVAR(enableModIcons))];
_ctrlPanel lbSetTooltip [_lbAdd, format ["%1\n%2", _displayName, _className]];