adds scroll wheel spawning and setting, adds utils for getting cfg

This commit is contained in:
2024-02-03 22:37:44 -08:00
parent 7ef48ecaa2
commit 94ccf0d80d
9 changed files with 225 additions and 2 deletions

View File

@@ -88,6 +88,8 @@ class milsim_resupply {
class createMortarBox {};
class createWeaponsBox {};
class getSupplyCratesCfg {};
class addArsenalObjectSpawnBoxActions {};
class addCBASettings {postInit=1;};
};
};

View File

@@ -9,6 +9,17 @@ if (!isServer) then {
}] call CBA_fnc_addEventHandler;
};
// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes
[
{time > 5},
{
if (missionNamespace getVariable [
"milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning",
false
]) then {call milsim_resupply_fnc_addSpawnBoxActions}
}
] call CBA_fnc_waitUntilAndExecute;
["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups;
nil;

View File

@@ -0,0 +1,31 @@
// adds a scroll wheel action to all arsenal boxes to spawn different supply crate types
private _arsenalBoxClassName = "Land_PaperBox_open_full_F";
// get all instances of the arsenal item
private _arsenalBoxes = (allMissionObjects _arsenalBoxClassName) select {
// only select the ones that already have user actions attached
count (actionIDs _x) > 0;
};
private _supplyCratesCfg = call milsim_resupply_fnc_getSupplyCratesCfg;
private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren;
{
// add scroll wheel action to spawn different supply box types
private _arsenalBox = _x;
{
private _cfg = _x;
private _supplyCrateDisplayName = (_cfg >> "displayName") call BIS_fnc_getCfgData;
_arsenalBox addAction [format ["<t color='#ffffff'>Spawn %1</t>", _supplyCrateDisplayName], {
params ["_target", "_caller", "_actionId", "_arguments"];
_arguments params ["_supplyCrateCfg"];
[
objNull,
configName _supplyCrateCfg,
getPos _target
] call milsim_resupply_fnc_createBox;
}, [_cfg], 0, false, true, "", ""];
} forEach _supplyCrateTypesCfgs;
} forEach _arsenalBoxes;

View File

@@ -0,0 +1,22 @@
[
"milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning", // variable
"CHECKBOX", // type
["Enabled", "If true, adds scroll wheel options to arsenal boxes to spawn supply boxes"], // title
["17th Battalion", "Resupply"], // category
false, // default value
true, // global setting
{
params ["_value"];
[
"resupply",
"SETTING CHANGED",
[
[
"setting",
"milsim_resupply_setting_allowSupplyBoxScrollWheelSpawning"
],
["newValue", _value]
]
] call milsim_fnc_log;
}
] call CBA_fnc_addSetting;