Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arsenal - Add ace_arsenal_loadoutVerified event #9792

Merged
merged 5 commits into from
Feb 11, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion addons/arsenal/functions/fnc_verifyLoadout.sqf
Original file line number Diff line number Diff line change
@@ -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
johnb432 marked this conversation as resolved.
Show resolved Hide resolved
_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]
27 changes: 20 additions & 7 deletions addons/gunbag/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -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, _defaultValue];
LinkIsGrim marked this conversation as resolved.
Show resolved Hide resolved
};
} 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;
1 change: 1 addition & 0 deletions docs/wiki/framework/arsenal-framework.md
Original file line number Diff line number Diff line change
@@ -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
Loading