From 5d3c28b807a20c7f8ee6e032d718a912bc924b6a Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Wed, 7 Feb 2024 13:11:58 -0800 Subject: [PATCH] ready for dedi --- framework/CfgFunctions.hpp | 10 +- .../client/functions/fn_addZenModules.sqf | 55 ---- framework/init/functions/fn_initClient.sqf | 3 + framework/zeus/functions/fn_addZenModules.sqf | 294 ++++++++++++++++++ framework/zeus/functions/fn_initClient.sqf | 14 + framework/zeus/script_component.hpp | 3 + 6 files changed, 323 insertions(+), 56 deletions(-) create mode 100644 framework/zeus/functions/fn_addZenModules.sqf create mode 100644 framework/zeus/functions/fn_initClient.sqf create mode 100644 framework/zeus/script_component.hpp diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index d9e5f96..5f23081 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -35,10 +35,10 @@ class CfgFunctions { class DOUBLES(PREFIX,client) { class functions { file = "framework\client\functions"; - class addZenModules { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; }; class bindEventHandlers { postInit = 1; }; class bindVehicleActions { postInit = 1; }; + class addZenModules {postInit = 1;}; }; }; @@ -169,4 +169,12 @@ class CfgFunctions { class isClassExcluded {}; }; }; + + class DOUBLES(PREFIX,zeus) { + class functions { + file = "framework\zeus\functions"; + class initClient {}; + class addZenModules {}; + }; + }; }; \ No newline at end of file diff --git a/framework/client/functions/fn_addZenModules.sqf b/framework/client/functions/fn_addZenModules.sqf index 0aeb533..d59ff07 100644 --- a/framework/client/functions/fn_addZenModules.sqf +++ b/framework/client/functions/fn_addZenModules.sqf @@ -2,61 +2,6 @@ if ( !hasInterface ) exitWith {}; -[ - QUOTE(MODULE_CATEGORY_NAME), - "Create Resupply Box", - { - params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; - // get parent definition - private _supplyCratesCfg = call EFUNC(resupply,getSupplyCratesCfg); - // get the subclass names - private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; - - _boxTypesAvailable sort true; - _comboOptions = _boxTypesAvailable apply { - [ - // display name - [_supplyCratesCfg >> _x >> "displayName", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, - // tooltip - [_supplyCratesCfg >> _x >> "tooltip", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, - // icon - [_supplyCratesCfg >> _x >> "icon", "STRING", "ERROR"] call CBA_fnc_getConfigEntry - ] - }; - - [ - "Resupply Box Options", - [ - // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] - ["COMBO", "Box Type", [_boxTypesAvailable, _comboOptions, 0]] - ], - { - - params ["_dialog", "_args"]; - - _dialog params ["_typeOptionSelected"]; - _args params ["_pos", "_target", "_keysSorted"]; - - - private _box = [_target, _typeOptionSelected, _pos] call EFUNC(resupply,createBox); - if (isNull _box) exitWith { - ["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint; - }; - [ - "Resupply Box", - format[ - "Created %1", - getText((call EFUNC(resupply,getSupplyCratesCfg)) >> _typeOptionSelected >> "displayName") - ] - ] call BIS_fnc_curatorHint; - }, - {}, - [_pos, _target] - ] call zen_dialog_fnc_create; - } -] call zen_custom_modules_fnc_register; - - [ QUOTE(MODULE_CATEGORY_NAME), "Grounds Cleanup", diff --git a/framework/init/functions/fn_initClient.sqf b/framework/init/functions/fn_initClient.sqf index a7d106a..3f2edc7 100644 --- a/framework/init/functions/fn_initClient.sqf +++ b/framework/init/functions/fn_initClient.sqf @@ -20,6 +20,7 @@ call EFUNC(reinsert,initClient); call EFUNC(resupply,initClient); call EFUNC(triageIcons,initClient); call EFUNC(vehicleFlags,initClient); +call EFUNC(zeus,initClient); call EFUNC(fbcb2_main,initClient); call EFUNC(fbcb2_assets,initClient); @@ -31,4 +32,6 @@ call EFUNC(fbcb2_assets,initClient); [] ] call EFUNC(common,log); +localNamespace setVariable [QGVAR(complete), true]; + nil; \ No newline at end of file diff --git a/framework/zeus/functions/fn_addZenModules.sqf b/framework/zeus/functions/fn_addZenModules.sqf new file mode 100644 index 0000000..41f29e0 --- /dev/null +++ b/framework/zeus/functions/fn_addZenModules.sqf @@ -0,0 +1,294 @@ +#include "..\script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +// Create Resupply Box +[ + QUOTE(MODULE_CATEGORY_NAME), + "Create Resupply Box", + { + // module placement + params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; + // get parent definition + private _supplyCratesCfg = call EFUNC(resupply,getSupplyCratesCfg); + // get the subclass names + private _boxTypesAvailable = _supplyCratesCfg call BIS_fnc_getCfgSubClasses; + + _boxTypesAvailable sort true; + _comboOptions = _boxTypesAvailable apply { + [ + // display name + [_supplyCratesCfg >> _x >> "displayName", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // tooltip + [_supplyCratesCfg >> _x >> "tooltip", "STRING", "ERROR"] call CBA_fnc_getConfigEntry, + // icon + [_supplyCratesCfg >> _x >> "icon", "STRING", "ERROR"] call CBA_fnc_getConfigEntry + ] + }; + + [ // create the dialog + "Resupply Box Options", + [ + // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] + ["COMBO", "Box Type", [_boxTypesAvailable, _comboOptions, 0]] + ], + { + + params ["_dialog", "_args"]; + + _dialog params ["_typeOptionSelected"]; + _args params ["_pos", "_target", "_keysSorted"]; + + + private _box = [_target, _typeOptionSelected, _pos] call EFUNC(resupply,createBox); + if (isNull _box) exitWith { + ["Resupply Box", "WARNING: Failed to locate or create box!"] call BIS_fnc_curatorHint; + }; + [ + "Resupply Box", + format[ + "Created %1", + getText((call EFUNC(resupply,getSupplyCratesCfg)) >> _typeOptionSelected >> "displayName") + ] + ] call BIS_fnc_curatorHint; + }, + {}, + [_pos, _target] + ] call zen_dialog_fnc_create; + } +] call zen_custom_modules_fnc_register; + +// Manage wheels in a vehicle's ACE cargo +[ + QUOTE(MODULE_CATEGORY_NAME), + "Manage Wheels in Vehicle", + { + // module placement + params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; + + if (isNull _target) exitWith { + ["Manage Wheels in Vehicle", "WARNING: No vehicle selected!"] call BIS_fnc_curatorHint; + }; + + if (_target isKindOf "CAManBase") exitWith { + ["Manage Wheels in Vehicle", "WARNING: Cannot add wheels/tracks to a person!"] call BIS_fnc_curatorHint; + }; + + if (_target isKindOf "Static") exitWith { + ["Manage Wheels in Vehicle", "WARNING: Cannot add wheels/tracks to a static object!"] call BIS_fnc_curatorHint; + }; + + // get loaded details + private _loadedItems = _target getVariable ["ace_cargo_loaded", []]; + private _loadedItemsObjects = _loadedItems select { _x isEqualType objNull }; + private _loadedItemsVirtual = _loadedItems select { _x isEqualType "" }; + private _spaceLeft = _target getVariable ["ace_cargo_space", 0]; + + private _wheels = _loadedItemsVirtual select { _x isEqualTo "ACE_Wheel" }; + _wheels append (_loadedItemsObjects select { typeOf _x isEqualTo "ACE_Wheel" }); + + + private _maxWheels = floor ((_spaceLeft + count _loadedItems) / ("ACE_Wheel" call ace_cargo_fnc_getSizeItem)); + private _currentWheels = count _wheels; + + private _comboOptions = [[], [], _currentWheels]; + for "_i" from 0 to _maxWheels do { + _comboOptions#0 pushBack _i; + _comboOptions#1 pushBack format["%1", _i]; + }; + + + [ // create the dialog + "Manage Wheels in Vehicle", + [ + // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] + ["TOOLBOX", "Existing Data", [ + 0, // default value + 2, // num rows + 2, // num columns + [ + format["Loaded Items: %1", count _loadedItems], + format["Space Left: %1", _spaceLeft], + format["Loaded Wheels: %1", count _wheels] + ] + ]], + ["COMBO", "Desired ACE Wheels Count", _comboOptions, true] + ], + { + + params ["_dialogValues", "_args"]; + + _dialogValues params ["_listItem", "_desiredWheelsCount"]; + _args params ["_pos", "_target", "_currentWheelsCount"]; + + // MANAGE WHEELS + if (_desiredWheelsCount > _currentWheelsCount) then { + // add wheels + private _wheelsToAdd = _desiredWheelsCount - _currentWheelsCount; + systemChat format["Adding %1 wheels...", _wheelsToAdd]; + for "_i" from 1 to _wheelsToAdd do { + if ( + ["ACE_Wheel", _target] call ace_cargo_fnc_canLoadItemIn + ) then { + ["ACE_Wheel", _target] call ace_cargo_fnc_addCargoItem; + }; + }; + }; + if (_desiredWheelsCount < _currentWheelsCount) then { + // remove wheels + private _wheelsToRemove = _currentWheelsCount - _desiredWheelsCount; + systemChat format["Removing %1 wheels...", _wheelsToRemove]; + ["ACE_Wheel", _target, _wheelsToRemove] call ace_cargo_fnc_removeCargoItem; + }; + + + // get loaded details + private _loadedItems = _target getVariable ["ace_cargo_loaded", []]; + private _loadedItemsObjects = _loadedItems select { _x isEqualType objNull }; + private _loadedItemsVirtual = _loadedItems select { _x isEqualType "" }; + private _spaceLeft = _target getVariable ["ace_cargo_space", 0]; + + private _wheels = _loadedItemsVirtual select { _x isEqualTo "ACE_Wheel" }; + _wheels append (_loadedItemsObjects select { typeOf _x isEqualTo "ACE_Wheel" }); + + + private _maxWheels = floor ((_spaceLeft + count _loadedItems) / ("ACE_Wheel" call ace_cargo_fnc_getSizeItem)); + private _currentWheels = count _wheels; + + [ + "Manage Wheels in Vehicle", + format[ + "Updated count of wheels in vehicle: %1", + _currentWheels + ] + ] call BIS_fnc_curatorHint; + true; + }, + {}, + [_pos, _target, count _wheels, count _tracks] + ] call zen_dialog_fnc_create; + } +] call zen_custom_modules_fnc_register; + + +// Manage tracks in a vehicle's ACE cargo +[ + QUOTE(MODULE_CATEGORY_NAME), + "Manage Tracks in Vehicle", + { + // module placement + params [["_pos", [0,0,0], [[]], 3], ["_target", objNull, [objNull]]]; + + if (isNull _target) exitWith { + ["Manage Tracks in Vehicle", "WARNING: No vehicle selected!"] call BIS_fnc_curatorHint; + }; + + if (_target isKindOf "CAManBase") exitWith { + ["Manage Tracks in Vehicle", "WARNING: Cannot add wheels/tracks to a person!"] call BIS_fnc_curatorHint; + }; + + if (_target isKindOf "Static") exitWith { + ["Manage Tracks in Vehicle", "WARNING: Cannot add wheels/tracks to a static object!"] call BIS_fnc_curatorHint; + }; + + // get loaded details + private _loadedItems = _target getVariable ["ace_cargo_loaded", []]; + private _loadedItemsObjects = _loadedItems select { _x isEqualType objNull }; + private _loadedItemsVirtual = _loadedItems select { _x isEqualType "" }; + private _spaceLeft = _target getVariable ["ace_cargo_space", 0]; + + private _tracks = _loadedItemsVirtual select { _x isEqualTo "ACE_Track" }; + _tracks append (_loadedItemsObjects select { typeOf _x isEqualTo "ACE_Track" }); + + private _maxTracks = floor ((_spaceLeft + count _loadedItems) / ("ACE_Track" call ace_cargo_fnc_getSizeItem)); + private _currentTracks = count _tracks; + + private _comboOptions = [[], [], _currentTracks]; + for "_i" from 0 to _maxTracks do { + _comboOptions#0 pushBack _i; + _comboOptions#1 pushBack format["%1", _i]; + }; + + [ // create the dialog + "Manage Tracks in Vehicle", + [ + // [ "COMBO", "Box Type", [[1,2,3], [["Ammo"],["Weapons"],["Medical"]],0] ] + ["TOOLBOX", "Existing Data", [ + 0, // default value + 2, // num rows + 2, // num columns + [ + format["Loaded Items: %1", count _loadedItems], + format["Space Left: %1", _spaceLeft], + format["Loaded Tracks: %1", count _tracks] + ] + ]], + ["COMBO", "Desired ACE Tracks Count", _comboOptions, true] + ], + { + + params ["_dialogValues", "_args"]; + + _dialogValues params ["_listItem", "_desiredTracksCount"]; + _args params ["_pos", "_target", "_currentTracksCount"]; + + // MANAGE TRACKS + if (_desiredTracksCount > _currentTracksCount) then { + // add tracks + private _tracksToAdd = _desiredTracksCount - _currentTracksCount; + systemChat format["Adding %1 tracks...", _tracksToAdd]; + for "_i" from 1 to _tracksToAdd do { + if ( + ["ACE_Track", _target] call ace_cargo_fnc_canLoadItemIn + ) then { + ["ACE_Track", _target] call ace_cargo_fnc_addCargoItem; + }; + }; + }; + if (_desiredTracksCount < _currentTracksCount) then { + // remove tracks + private _tracksToRemove = _currentTracksCount - _desiredTracksCount; + systemChat format["Removing %1 tracks...", _tracksToRemove]; + ["ACE_Track", _target, _tracksToRemove] call ace_cargo_fnc_removeCargoItem; + }; + + + // get loaded details + private _loadedItems = _target getVariable ["ace_cargo_loaded", []]; + private _loadedItemsObjects = _loadedItems select { _x isEqualType objNull }; + private _loadedItemsVirtual = _loadedItems select { _x isEqualType "" }; + private _spaceLeft = _target getVariable ["ace_cargo_space", 0]; + + private _tracks = _loadedItemsVirtual select { _x isEqualTo "ACE_Track" }; + _tracks append (_loadedItemsObjects select { typeOf _x isEqualTo "ACE_Track" }); + + private _maxTracks = floor ((_spaceLeft + count _loadedItems) / ("ACE_Track" call ace_cargo_fnc_getSizeItem)); + private _currentTracks = count _tracks; + + [ + "Manage Tracks in Vehicle", + format[ + "Updated count of tracks in vehicle: %1", + _currentTracks + ] + ] call BIS_fnc_curatorHint; + true; + }, + {}, + [_pos, _target, _currentTracks] + ] call zen_dialog_fnc_create; + } +] call zen_custom_modules_fnc_register; + + + + + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "ZEUS ENHANCED MODULES ADDED", + [] +] call EFUNC(common,log); + +nil; \ No newline at end of file diff --git a/framework/zeus/functions/fn_initClient.sqf b/framework/zeus/functions/fn_initClient.sqf new file mode 100644 index 0000000..28a5108 --- /dev/null +++ b/framework/zeus/functions/fn_initClient.sqf @@ -0,0 +1,14 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +call FUNC(addZenModules); + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/zeus/script_component.hpp b/framework/zeus/script_component.hpp new file mode 100644 index 0000000..85c6e66 --- /dev/null +++ b/framework/zeus/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT zeus +#define COMPONENT_BEAUTIFIED Zeus Utilities +#include "../script_mod.hpp" \ No newline at end of file