ACE3/addons/arsenal/XEH_postInit.sqf
BrettMayson 438a90b63d
Common - Add CBA extended loadout (#8923)
* extended loadouts - earplugs, gunbag, and arsenal identity

* arsenal - maintain default loadout size check

* restore comment

Co-authored-by: jonpas <jonpas33@gmail.com>

* fix forgotten example

Co-authored-by: jonpas <jonpas33@gmail.com>
2022-08-25 11:56:54 -05:00

106 lines
3.6 KiB
Plaintext

#include "script_component.hpp"
#include "defines.hpp"
GVAR(currentBox) = objNull;
GVAR(EH_ID) = 0;
GVAR(lastSearchTextLeft) = "";
GVAR(lastSearchTextRight) = "";
GVAR(lastSearchTextLoadouts) = "";
GVAR(lastSortLeft) = "";
GVAR(lastSortRight) = "";
[QGVAR(initBox), {_this call FUNC(initBox)}] call CBA_fnc_addEventHandler;
[QGVAR(removeBox), {_this call FUNC(removeBox)}] call CBA_fnc_addEventHandler;
[QGVAR(broadcastFace), {
params ["_unit", "_face"];
_unit setFace _face;
}] call CBA_fnc_addEventHandler;
[QGVAR(broadcastVoice), {
params ["_unit", "_voice"];
_unit setSpeaker _voice;
}] call CBA_fnc_addEventHandler;
[QGVAR(loadoutUnshared), {
params ["_contentPanelCtrl" , "_playerName", "_loadoutName"];
if (!isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then {
private _dataToCheck = _playerName + _loadoutName;
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbData [_i, 1]) == _dataToCheck) exitwith {_contentPanelCtrl lnbDeleteRow _i};
};
} else {
if (
profileName == _playerName &&
{!(isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonMyLoadouts})}
) then {
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _loadoutName) exitwith {
_contentPanelCtrl lnbSetPicture [[_i, 0], QPATHTOF(data\iconPublicBlank.paa)];
_contentPanelCtrl lnbSetValue [[_i, 0], 0];
};
};
};
};
}] call CBA_fnc_addEventHandler;
[QGVAR(loadoutShared), {
params ["_contentPanelCtrl" ,"_loadoutArgs"];
_loadoutArgs params ["_playerName", "_loadoutName", "_loadoutData"];
if (!isNil QGVAR(currentLoadoutsTab) && {GVAR(currentLoadoutsTab) == IDC_buttonSharedLoadouts}) then {
private _curSelData =_contentPanelCtrl lnbData [(lnbCurSelRow _contentPanelCtrl), 1];
([_loadoutData] call FUNC(verifyLoadout)) params ["_extendedLoadout", "_nullItemsAmount", "_unavailableItemsAmount"];
private _newRow = _contentPanelCtrl lnbAddRow [_playerName, _loadoutName];
_extendedLoadout params ["_loadout"];
ADD_LOADOUTS_LIST_PICTURES
_contentPanelCtrl lnbSetData [[_newRow, 1], _playerName + _loadoutName];
if (_nullItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 0, 0, 0.8]];
} else {
if (_unavailableItemsAmount > 0) then {
_contentPanelCtrl lnbSetColor [[_newRow, 1], [1, 1, 1, 0.25]];
};
};
_contentPanelCtrl lnbSort [1, false];
// Select previously selected loadout
for '_i' from 0 to (((lnbsize _contentPanelCtrl) select 0) - 1) do {
if ((_contentPanelCtrl lnbText [_i, 1]) == _curSelData) exitwith {_contentPanelCtrl lnbSetCurSelRow _i};
};
};
}] call CBA_fnc_addEventHandler;
["CBA_loadoutSet", {
params ["_unit", "_loadout", "_extendedInfo"];
private _face = _extendedInfo getOrDefault [QGVAR(face), ""];
if (_face != "") then {
_unit setFace _face;
};
private _voice = _extendedInfo getOrDefault [QGVAR(voice), ""];
if (_voice != "") then {
_unit setSpeaker _voice;
};
private _insignia = _extendedInfo getOrDefault [QGVAR(insignia), ""];
if (_insignia != "") then {
_unit setVariable ["BIS_fnc_setUnitInsignia_class", nil];
[_unit, _insignia] call bis_fnc_setUnitInsignia;
};
}] call CBA_fnc_addEventHandler;