Arsenal - Add ace_arsenal_loadoutVerified event (#9792)

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
This commit is contained in:
Grim 2024-02-11 20:25:12 -03:00 committed by GitHub
parent b2849aaa29
commit 1e1d1d63f2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 8 deletions

View File

@ -19,7 +19,7 @@ private _extendedInfo = createHashMap;
// Check if the provided loadout is a CBA extended loadout
if (count _loadout == 2) then {
_extendedInfo = _loadout select 1;
_extendedInfo = +(_loadout select 1); // Copy the hashmap to prevent events from modifiyng the profileNamespace extendedInfo
_loadout = _loadout select 0;
};
@ -70,4 +70,7 @@ private _fnc_filterLoadout = {
// Loadout might come from a different modpack, which might have different config naming
_loadout = _loadout call _fnc_filterLoadout;
// Raise event for 3rd party: mostly for handling extended info
[QGVAR(loadoutVerified), [_loadout, _extendedInfo]] call CBA_fnc_localEvent;
[[_loadout, _extendedInfo], _nullItemsList arrayIntersect _nullItemsList, _unavailableItemsList arrayIntersect _unavailableItemsList]

View File

@ -26,17 +26,30 @@ PREP_RECOMPILE_END;
}, _this] call CBA_fnc_execNextFrame;
}] call CBA_fnc_addClassEventHandler;
[QEGVAR(arsenal,loadoutVerified), {
params ["_loadout", "_extendedInfo"];
private _gunbagInfo = _extendedInfo getOrDefault [QGVAR(gunbagWeapon), []];
if (_gunbagInfo isEqualTo []) exitWith {};
private _weapon = (_gunbagInfo select 0) call EFUNC(arsenal,baseWeapon);
if !(_weapon in EGVAR(arsenal,virtualItemsFlat)) exitWith {
INFO_1("removing [%1] from loadout",_gunbagInfo);
_extendedInfo deleteAt QGVAR(gunbagWeapon);
};
{
private _class = _x param [0, ""];
private _defaultValue = ["", []] select {_x isEqualType []};
if (_class != "" && {!(_class in EGVAR(arsenal,virtualItemsFlat))}) then {
INFO_1("removing [%1] from loadout",_x);
_gunbagInfo set [_forEachIndex + 1, _defaultValue];
};
} forEach (_gunbagInfo select [1]); // weapon was verified above
}] call CBA_fnc_addEventHandler;
["CBA_loadoutSet", {
params ["_unit", "_loadout", "_extendedInfo"];
private _gunbagWeapon = _extendedInfo getOrDefault [QGVAR(gunbagWeapon), []];
if (_gunbagWeapon isNotEqualTo []) then {
if (!isNil QEGVAR(arsenal,virtualItemsFlatAll)) then {
private _weapon = (_gunbagWeapon select 0) call EFUNC(arsenal,baseWeapon);
if !(_weapon in EGVAR(arsenal,virtualItemsFlatAll)) then {
INFO_1("removing [%1] from loadout",_gunbagWeapon);
_gunbagWeapon = [];
};
};
(backpackContainer _unit) setVariable [QGVAR(gunbagWeapon), _gunbagWeapon, true];
};
}] call CBA_fnc_addEventHandler;

View File

@ -511,6 +511,7 @@ All are local.
| ace_arsenal_loadoutsDisplayClosed | None | 3.12.3 |
| ace_arsenal_loadoutsTabChanged | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 |
| ace_arsenal_loadoutsListFilled | loadouts screen display (DISPLAY), tab control (CONTROL) | 3.12.3 |
| ace_arsenal_loadoutVerified | loadout data (ARRAY), loadout CBA extended data (HASHMAP) | 3.17.0 |
| ace_arsenal_weaponItemChanged | weapon classname (STRING), item classname (STRING), item index (NUMBER, 0-5: muzzle, side, optic, bipod, magazine, underbarrel) | 3.16.0 |
## 9. Custom sub item categories