From 51b5cfe8563dded26ec3df381a84f09aa86c7274 Mon Sep 17 00:00:00 2001 From: PhILoXs Date: Sat, 23 Sep 2023 14:18:53 +0200 Subject: [PATCH 1/3] Armory - Minor fixes and some little features (#101) * propagate deletion of equipment/backpack to all players * propagate deletion of equipment and set default vaule Default value is needed, because nil is a reserved variable. * check for available equipment if equipment is not found, a warning log message will be thrown * equipment initialization will be logged * add cba setting and change code to allow player based db connections * remove multiline code in config * add interaction menu setting and overhaul createEquipment * disable debug mode * remove old initialisation var in example * Update addons/armory/functions/fnc_equipLoadout.sqf Co-authored-by: Timi007 * Update addons/armory/functions/fnc_equipBackpack.sqf Co-authored-by: Timi007 * Update addons/armory/functions/fnc_createEquipment.sqf Co-authored-by: Timi007 * use already existing disaplayName and remove subCategory * rename cba action setting cba_settings_action to openUIActionMenu * renameSetting cba_settings_playerDBConnection to allowPlayerDBConnection * correct spelling * move UI Code to seperate functions * add more descriptive action * rename UI Call to correct funtion name * add isNull Check for ui controls and fix checkbox query * rename var _params to _argsSuccessfullyParsed * fix spelling --------- Co-authored-by: Timi007 --- addons/armory/CfgEventHandlers.hpp | 6 + addons/armory/XEH_PREP.hpp | 2 + addons/armory/XEH_postInit.sqf | 163 ++++++++++++++++++ addons/armory/XEH_preInit.sqf | 143 +-------------- addons/armory/defines.hpp | 5 - .../functions/fnc_buttonCreateEquipment.sqf | 32 ++++ .../armory/functions/fnc_createEquipment.sqf | 16 +- addons/armory/functions/fnc_equipBackpack.sqf | 13 +- addons/armory/functions/fnc_equipLoadout.sqf | 13 +- addons/armory/functions/fnc_initEquipment.sqf | 4 +- .../functions/fnc_openNewEquipmentDialog.sqf | 25 +++ addons/armory/functions/fnc_saveEquipment.sqf | 8 +- addons/armory/functions/fnc_setEditArea.sqf | 4 +- addons/armory/functions/fnc_updateArsenal.sqf | 6 +- .../armory/functions/fnc_updateBackpack.sqf | 3 +- addons/armory/functions/fnc_updateEditors.sqf | 3 +- addons/armory/functions/fnc_updateLoadout.sqf | 5 +- addons/armory/initSettings.hpp | 21 +++ addons/armory/script_component.hpp | 1 - addons/armory/stringtable.xml | 30 +++- addons/armory/ui/RscAttributes.hpp | 9 +- 21 files changed, 322 insertions(+), 190 deletions(-) create mode 100644 addons/armory/XEH_postInit.sqf create mode 100644 addons/armory/functions/fnc_buttonCreateEquipment.sqf create mode 100644 addons/armory/functions/fnc_openNewEquipmentDialog.sqf create mode 100644 addons/armory/initSettings.hpp diff --git a/addons/armory/CfgEventHandlers.hpp b/addons/armory/CfgEventHandlers.hpp index 865276c..f6503c2 100644 --- a/addons/armory/CfgEventHandlers.hpp +++ b/addons/armory/CfgEventHandlers.hpp @@ -9,3 +9,9 @@ class Extended_PreInit_EventHandlers { init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); }; }; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); + }; +}; diff --git a/addons/armory/XEH_PREP.hpp b/addons/armory/XEH_PREP.hpp index cfba90f..cd2458d 100644 --- a/addons/armory/XEH_PREP.hpp +++ b/addons/armory/XEH_PREP.hpp @@ -1,9 +1,11 @@ +PREP(buttonCreateEquipment); PREP(createEquipment); PREP(equipLoadout); PREP(equipBackpack); PREP(initEquipment); PREP(openArmory); PREP(openArsenal); +PREP(openNewEquipmentDialog); PREP(saveEquipment); PREP(setEditArea); PREP(toggleSettings); diff --git a/addons/armory/XEH_postInit.sqf b/addons/armory/XEH_postInit.sqf new file mode 100644 index 0000000..a377c1e --- /dev/null +++ b/addons/armory/XEH_postInit.sqf @@ -0,0 +1,163 @@ +#include "script_component.hpp" + +GVAR(initialized) = false; +[QGVAR(updateArsenal), FUNC(updateArsenal)] call CBA_fnc_addEventHandler; + +TRACE_2("", isDedicated, GVAR(allowPlayerDBConnection)); + +if (isDedicated || GVAR(allowPlayerDBConnection)) then { + + private _dbConnected = ["armory", "armory.ini"] call DB_CONNECT; + if (isNil "_dbConnected" || !(_dbConnected select 0)) exitWith { + WARNING("Can't connect to Database! Disabling module."); + }; + GVAR(sessionID) = _dbConnected select 1; + + GVAR(equipment) = [true] call CBA_fnc_createNamespace; + publicVariable QGVAR(equipment); + + GVAR(equipmentInitialized) = []; + [QGVAR(updateLoadout), FUNC(updateLoadout)] call CBA_fnc_addEventHandler; + [QGVAR(updateBackpack), FUNC(updateBackpack)] call CBA_fnc_addEventHandler; + [QGVAR(updateEditors), FUNC(updateEditors)] call CBA_fnc_addEventHandler; + [QGVAR(createEquipment), FUNC(createEquipment)] call CBA_fnc_addEventHandler; + + [QGVAR(initEquipment), { + params [["_unit", objNull, [objNull]], ["_callBackEvent", "", [""]], ["_args", [], [[]]]]; + CHECK(!GVAR(initialized) || isNull _unit || _callBackEvent isEqualTo "" || (_args param [ARR_2(0,"")]) isEqualTo ""); + _args params ["_equipmentName"]; + + if ([_equipmentName] call FUNC(initEquipment)) then { + [_callBackEvent, _args, _unit] call CBA_fnc_targetEvent; + } else { + [QGVAR(error), [_unit, _callBackEvent, _args], _unit] call CBA_fnc_targetEvent; + }; + }] call CBA_fnc_addEventhandler; + + GVAR(initialized) = true; + publicVariable QGVAR(initialized); +}; + +if (hasinterface) then { + [QGVAR(openArmory), FUNC(openArmory)] call CBA_fnc_addEventhandler; + [QGVAR(equipBackpack), FUNC(equipBackpack)] call CBA_fnc_addEventhandler; + [QGVAR(equipLoadout), FUNC(equipLoadout)] call CBA_fnc_addEventhandler; + + [QGVAR(error), { + params ["_unit", "_callBackEvent", "_args"]; + ERROR(format [ARR_4("Something went wrong: Unit: %1 | CallBackEvent: %2 | Args: %3", _unit, _callBackEvent, _args)]); + if (hasinterface) then { + hint "MTS Armory:\nSomething went wrong, please take a look into your logfiles."; + }; + }] call CBA_fnc_addEventhandler; + + [QGVAR(addAction), { + params [["_equipmentName", "", [""]], ["_object", objNull, [objNull]]]; + CHECK(isNull _object || _equipmentName isEqualTo ""); + + if (GVAR(openUIActionMenu) isEqualTo "ace_interaction" && isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) then { + private _actionOpenArmory = [ + QGVAR(ace_interact_openArmory), + format["%1: %2", LLSTRING(displayName), _equipmentName], + "", + { + params ["_object", "", "_params"]; + _params params ["_equipmentName"]; + + [_equipmentName, _object] call FUNC(openArmory); + }, + {true}, + {}, + [_equipmentName] + ] call ace_interact_menu_fnc_createAction; + [_object, 0, ["ACE_MainActions"], _actionOpenArmory] call ace_interact_menu_fnc_addActionToObject; + } else { + _object addAction [format["%1: %2", LLSTRING(displayName), _equipmentName], {[(_this select 3), (_this select 0)] call FUNC(openArmory)}, _equipmentName]; + }; + }] call CBA_fnc_addEventhandler; + + GVAR(IDCsToHide) = [ + IDC_CHECKBOX_ARSENAL, + IDC_EDITBOX_EQUIPMENT_NAME, + IDC_LISTBOX_MEDIC, + IDC_LISTBOX_ENGINEER, + IDC_BUTTON_SAVE_EQUIPMENT, + IDC_BUTTON_DELETE_EQUIPMENT, + IDC_BACKGROUND_DELETE_EQUIPMENT, + IDC_ICON_DELETE_EQUIPMENT, + IDC_EDITBOX_EDITORS, + IDC_BUTTON_SAVE_EDITORS, + IDC_BUTTON_EDIT_LOADOUT_1, + IDC_BUTTON_EDIT_LOADOUT_2, + IDC_BUTTON_EDIT_LOADOUT_3, + IDC_BUTTON_EDIT_LOADOUT_4, + IDC_BUTTON_EDIT_LOADOUT_5, + IDC_BUTTON_EDIT_LOADOUT_6, + IDC_BUTTON_EDIT_LOADOUT_7, + IDC_BUTTON_EDIT_LOADOUT_8, + IDC_BUTTON_EDIT_LOADOUT_9, + IDC_BUTTON_EDIT_LOADOUT_10, + IDC_BUTTON_EDIT_LOADOUT_11, + IDC_BUTTON_EDIT_LOADOUT_12, + IDC_BACKGROUND_EDIT_LOADOUT_1, + IDC_BACKGROUND_EDIT_LOADOUT_2, + IDC_BACKGROUND_EDIT_LOADOUT_3, + IDC_BACKGROUND_EDIT_LOADOUT_4, + IDC_BACKGROUND_EDIT_LOADOUT_5, + IDC_BACKGROUND_EDIT_LOADOUT_6, + IDC_BACKGROUND_EDIT_LOADOUT_7, + IDC_BACKGROUND_EDIT_LOADOUT_8, + IDC_BACKGROUND_EDIT_LOADOUT_9, + IDC_BACKGROUND_EDIT_LOADOUT_10, + IDC_BACKGROUND_EDIT_LOADOUT_11, + IDC_BACKGROUND_EDIT_LOADOUT_12, + IDC_ICON_EDIT_LOADOUT_1, + IDC_ICON_EDIT_LOADOUT_2, + IDC_ICON_EDIT_LOADOUT_3, + IDC_ICON_EDIT_LOADOUT_4, + IDC_ICON_EDIT_LOADOUT_5, + IDC_ICON_EDIT_LOADOUT_6, + IDC_ICON_EDIT_LOADOUT_7, + IDC_ICON_EDIT_LOADOUT_8, + IDC_ICON_EDIT_LOADOUT_9, + IDC_ICON_EDIT_LOADOUT_10, + IDC_ICON_EDIT_LOADOUT_11, + IDC_ICON_EDIT_LOADOUT_12, + IDC_BUTTON_EDIT_BACKPACK_1, + IDC_BUTTON_EDIT_BACKPACK_2, + IDC_BUTTON_EDIT_BACKPACK_3, + IDC_BUTTON_EDIT_BACKPACK_4, + IDC_BUTTON_EDIT_BACKPACK_5, + IDC_BUTTON_EDIT_BACKPACK_6, + IDC_BUTTON_EDIT_BACKPACK_7, + IDC_BUTTON_EDIT_BACKPACK_8, + IDC_BUTTON_EDIT_BACKPACK_9, + IDC_BUTTON_EDIT_BACKPACK_10, + IDC_BUTTON_EDIT_BACKPACK_11, + IDC_BUTTON_EDIT_BACKPACK_12, + IDC_BACKGROUND_EDIT_BACKPACK_1, + IDC_BACKGROUND_EDIT_BACKPACK_2, + IDC_BACKGROUND_EDIT_BACKPACK_3, + IDC_BACKGROUND_EDIT_BACKPACK_4, + IDC_BACKGROUND_EDIT_BACKPACK_5, + IDC_BACKGROUND_EDIT_BACKPACK_6, + IDC_BACKGROUND_EDIT_BACKPACK_7, + IDC_BACKGROUND_EDIT_BACKPACK_8, + IDC_BACKGROUND_EDIT_BACKPACK_9, + IDC_BACKGROUND_EDIT_BACKPACK_10, + IDC_BACKGROUND_EDIT_BACKPACK_11, + IDC_BACKGROUND_EDIT_BACKPACK_12, + IDC_ICON_EDIT_BACKPACK_1, + IDC_ICON_EDIT_BACKPACK_2, + IDC_ICON_EDIT_BACKPACK_3, + IDC_ICON_EDIT_BACKPACK_4, + IDC_ICON_EDIT_BACKPACK_5, + IDC_ICON_EDIT_BACKPACK_6, + IDC_ICON_EDIT_BACKPACK_7, + IDC_ICON_EDIT_BACKPACK_8, + IDC_ICON_EDIT_BACKPACK_9, + IDC_ICON_EDIT_BACKPACK_10, + IDC_ICON_EDIT_BACKPACK_11, + IDC_ICON_EDIT_BACKPACK_12 + ]; +}; diff --git a/addons/armory/XEH_preInit.sqf b/addons/armory/XEH_preInit.sqf index d2d848b..bf2ce23 100644 --- a/addons/armory/XEH_preInit.sqf +++ b/addons/armory/XEH_preInit.sqf @@ -6,147 +6,6 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -GVAR(initialized) = false; -[QGVAR(updateArsenal), FUNC(updateArsenal)] call CBA_fnc_addEventHandler; - -if (SERVER_CHECK) then { - - private _dbConnected = ["armory", "armory.ini"] call DB_CONNECT; - if (isNil "_dbConnected" || !(_dbConnected select 0)) exitWith { - WARNING("Can't connect to Database! Disabling module."); - }; - GVAR(sessionID) = _dbConnected select 1; - - GVAR(equipment) = [true] call CBA_fnc_createNamespace; - publicVariable QGVAR(equipment); - - GVAR(equipmentInitialized) = []; - [QGVAR(updateLoadout), FUNC(updateLoadout)] call CBA_fnc_addEventHandler; - [QGVAR(updateBackpack), FUNC(updateBackpack)] call CBA_fnc_addEventHandler; - [QGVAR(updateEditors), FUNC(updateEditors)] call CBA_fnc_addEventHandler; - [QGVAR(createEquipment), FUNC(createEquipment)] call CBA_fnc_addEventHandler; - - [QGVAR(initEquipment), { - params [["_unit", objNull, [objNull]], ["_callBackEvent", "", [""]], ["_args", [], [[]]]]; - CHECK(!GVAR(initialized) || isNull _unit || _callBackEvent isEqualTo "" || (_args param [ARR_2(0,"")]) isEqualTo ""); - _args params ["_equipmentName"]; - - if ([_equipmentName] call FUNC(initEquipment)) then { - [_callBackEvent, _args, _unit] call CBA_fnc_targetEvent; - } else { - [QGVAR(error), [_unit, _callBackEvent, _args], _unit] call CBA_fnc_targetEvent; - }; - }] call CBA_fnc_addEventhandler; - - GVAR(initialized) = true; - publicVariable QGVAR(initialized); -}; - -if (hasinterface) then { - [QGVAR(openArmory), FUNC(openArmory)] call CBA_fnc_addEventhandler; - [QGVAR(equipBackpack), FUNC(equipBackpack)] call CBA_fnc_addEventhandler; - [QGVAR(equipLoadout), FUNC(equipLoadout)] call CBA_fnc_addEventhandler; - - [QGVAR(error), { - params ["_unit", "_callBackEvent", "_args"]; - ERROR(format [ARR_4("Something went wrong: Unit: %1 | CallBackEvent: %2 | Args: %3", _unit, _callBackEvent, _args)]); - if (hasinterface) then { - hint "MTS Armory:\nSomething went wrong, please take a look into your logfiles."; - }; - }] call CBA_fnc_addEventhandler; - - [QGVAR(addAction), { - params [["_equipmentName", "", [""]], ["_object", objNull, [objNull]]]; - CHECK(isNull _object || _equipmentName isEqualTo ""); - - _object addAction [_equipmentName, {[(_this select 3), (_this select 0)] call FUNC(openArmory)}, _equipmentName]; - }] call CBA_fnc_addEventhandler; - - GVAR(IDCsToHide) = [ - IDC_CHECKBOX_ARSENAL, - IDC_EDITBOX_EQUIPMENT_NAME, - IDC_LISTBOX_MEDIC, - IDC_LISTBOX_ENGINEER, - IDC_BUTTON_SAVE_EQUIPMENT, - IDC_BUTTON_DELETE_EQUIPMENT, - IDC_BACKGROUND_DELETE_EQUIPMENT, - IDC_ICON_DELETE_EQUIPMENT, - IDC_EDITBOX_EDITORS, - IDC_BUTTON_SAVE_EDITORS, - IDC_BUTTON_EDIT_LOADOUT_1, - IDC_BUTTON_EDIT_LOADOUT_2, - IDC_BUTTON_EDIT_LOADOUT_3, - IDC_BUTTON_EDIT_LOADOUT_4, - IDC_BUTTON_EDIT_LOADOUT_5, - IDC_BUTTON_EDIT_LOADOUT_6, - IDC_BUTTON_EDIT_LOADOUT_7, - IDC_BUTTON_EDIT_LOADOUT_8, - IDC_BUTTON_EDIT_LOADOUT_9, - IDC_BUTTON_EDIT_LOADOUT_10, - IDC_BUTTON_EDIT_LOADOUT_11, - IDC_BUTTON_EDIT_LOADOUT_12, - IDC_BACKGROUND_EDIT_LOADOUT_1, - IDC_BACKGROUND_EDIT_LOADOUT_2, - IDC_BACKGROUND_EDIT_LOADOUT_3, - IDC_BACKGROUND_EDIT_LOADOUT_4, - IDC_BACKGROUND_EDIT_LOADOUT_5, - IDC_BACKGROUND_EDIT_LOADOUT_6, - IDC_BACKGROUND_EDIT_LOADOUT_7, - IDC_BACKGROUND_EDIT_LOADOUT_8, - IDC_BACKGROUND_EDIT_LOADOUT_9, - IDC_BACKGROUND_EDIT_LOADOUT_10, - IDC_BACKGROUND_EDIT_LOADOUT_11, - IDC_BACKGROUND_EDIT_LOADOUT_12, - IDC_ICON_EDIT_LOADOUT_1, - IDC_ICON_EDIT_LOADOUT_2, - IDC_ICON_EDIT_LOADOUT_3, - IDC_ICON_EDIT_LOADOUT_4, - IDC_ICON_EDIT_LOADOUT_5, - IDC_ICON_EDIT_LOADOUT_6, - IDC_ICON_EDIT_LOADOUT_7, - IDC_ICON_EDIT_LOADOUT_8, - IDC_ICON_EDIT_LOADOUT_9, - IDC_ICON_EDIT_LOADOUT_10, - IDC_ICON_EDIT_LOADOUT_11, - IDC_ICON_EDIT_LOADOUT_12, - IDC_BUTTON_EDIT_BACKPACK_1, - IDC_BUTTON_EDIT_BACKPACK_2, - IDC_BUTTON_EDIT_BACKPACK_3, - IDC_BUTTON_EDIT_BACKPACK_4, - IDC_BUTTON_EDIT_BACKPACK_5, - IDC_BUTTON_EDIT_BACKPACK_6, - IDC_BUTTON_EDIT_BACKPACK_7, - IDC_BUTTON_EDIT_BACKPACK_8, - IDC_BUTTON_EDIT_BACKPACK_9, - IDC_BUTTON_EDIT_BACKPACK_10, - IDC_BUTTON_EDIT_BACKPACK_11, - IDC_BUTTON_EDIT_BACKPACK_12, - IDC_BACKGROUND_EDIT_BACKPACK_1, - IDC_BACKGROUND_EDIT_BACKPACK_2, - IDC_BACKGROUND_EDIT_BACKPACK_3, - IDC_BACKGROUND_EDIT_BACKPACK_4, - IDC_BACKGROUND_EDIT_BACKPACK_5, - IDC_BACKGROUND_EDIT_BACKPACK_6, - IDC_BACKGROUND_EDIT_BACKPACK_7, - IDC_BACKGROUND_EDIT_BACKPACK_8, - IDC_BACKGROUND_EDIT_BACKPACK_9, - IDC_BACKGROUND_EDIT_BACKPACK_10, - IDC_BACKGROUND_EDIT_BACKPACK_11, - IDC_BACKGROUND_EDIT_BACKPACK_12, - IDC_ICON_EDIT_BACKPACK_1, - IDC_ICON_EDIT_BACKPACK_2, - IDC_ICON_EDIT_BACKPACK_3, - IDC_ICON_EDIT_BACKPACK_4, - IDC_ICON_EDIT_BACKPACK_5, - IDC_ICON_EDIT_BACKPACK_6, - IDC_ICON_EDIT_BACKPACK_7, - IDC_ICON_EDIT_BACKPACK_8, - IDC_ICON_EDIT_BACKPACK_9, - IDC_ICON_EDIT_BACKPACK_10, - IDC_ICON_EDIT_BACKPACK_11, - IDC_ICON_EDIT_BACKPACK_12 - ]; -}; - +#include "initSettings.hpp" ADDON = true; diff --git a/addons/armory/defines.hpp b/addons/armory/defines.hpp index 85baef8..c202c66 100644 --- a/addons/armory/defines.hpp +++ b/addons/armory/defines.hpp @@ -1,11 +1,6 @@ #define LOADOUT 1 #define BACKPACK 2 #define IDD_ACE_ARSENAL 1127001 -#ifdef DEBUG_CLIENT_SERVER - #define SERVER_CHECK isServer -#else - #define SERVER_CHECK isDedicated -#endif // Equipment dialog #define IDD_EQUIPMENT 520600 diff --git a/addons/armory/functions/fnc_buttonCreateEquipment.sqf b/addons/armory/functions/fnc_buttonCreateEquipment.sqf new file mode 100644 index 0000000..44231cb --- /dev/null +++ b/addons/armory/functions/fnc_buttonCreateEquipment.sqf @@ -0,0 +1,32 @@ +#include "script_component.hpp" +/** + * Author: PhILoX + * + * Description: + * Gets all information and create new equipment from "newEquipment" dialog + * + * Parameter(s): + * 0: CONTROL - Button control of "Button_Create_Equipment" from "newEquipment" dialog + * + * Returns: + * Nothing + * + * Example: + * [_buttonCtrl] call mts_armory_fnc_buttonCreateEquipment + * + */ + +params [["_buttonCtrl", controlNull, [controlNull]]]; +CHECK(isNull _buttonCtrl); + +private _attachToObject = _buttonCtrl getVariable [QGVAR(attachedObject), objNull]; +private _addActionChecked = cbChecked ((ctrlParent _buttonCtrl) displayCtrl IDC_CHECKBOX_EQUIPMENT); +private _equipmentName = ctrlText IDC_EDITBOX_EQUIPMENT; +private _playerUID = getPlayerUID player; + +if (_addActionChecked && !isNull _attachToObject) then { + [QGVAR(createEquipment), [_equipmentName, [_playerUID], _attachToObject]] call CBA_fnc_serverEvent; +} else { + [QGVAR(createEquipment), [_equipmentName, [_playerUID]]] call CBA_fnc_serverEvent; +}; +closeDialog 0; diff --git a/addons/armory/functions/fnc_createEquipment.sqf b/addons/armory/functions/fnc_createEquipment.sqf index 4dc2371..7cd349d 100644 --- a/addons/armory/functions/fnc_createEquipment.sqf +++ b/addons/armory/functions/fnc_createEquipment.sqf @@ -8,33 +8,31 @@ * Parameter(s): * 0: STRING - Equipment name * 1: ARRAY - Editor UIDs. Format: ["00000000000000000",...] - * 2: BOOLEAN - if the equipment should be initialized after creation (optional) - * 3: OBJECT - Object to add action (optional) + * 3: OBJECT - Object to add action for new equipment (optional) * * Returns: * Nothing * * Example: - * ["enhanced", ["00000000000000000"], true] call mts_armory_fnc_newEquipment + * ["enhanced", ["00000000000000000"]] call mts_armory_fnc_createEquipment * */ -private _params = params [["_equipmentName", "", [""]], ["_editors", [], [[],""]], ["_initialize", false, [false]], ["_object", objNull, [objNull]]]; -TRACE_4("",_equipmentName,_editors,_initialize,_object); +private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_editors", [], [[],""]], ["_object", objNull, [objNull]]]; +TRACE_4("",_equipmentName,_editors,_object, _argsSuccessfullyParsed); if (_editors isEqualType "") then { _editors = parseSimpleArray _editors; }; -CHECK(!GVAR(initialized) || !_params || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo "") || !SERVER_CHECK); +CHECK(!GVAR(initialized) || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo "")); +CHECK(!isDedicated && !GVAR(allowPlayerDBConnection)); [GVAR(sessionID), "insertEquipment", _equipmentName, _editors] call DB_SET; -if (_initialize) then { +if (!isNull _object) then { [{ params ["_equipmentName", "_object"]; - if ([_equipmentName] call FUNC(initEquipment)) then { [QGVAR(addAction), [_equipmentName, _object]] call CBA_fnc_globalEventJIP; - }; }, [_equipmentName, _object]] call CBA_fnc_execNextFrame; }; diff --git a/addons/armory/functions/fnc_equipBackpack.sqf b/addons/armory/functions/fnc_equipBackpack.sqf index cab5197..23a60eb 100644 --- a/addons/armory/functions/fnc_equipBackpack.sqf +++ b/addons/armory/functions/fnc_equipBackpack.sqf @@ -17,21 +17,24 @@ * */ -private _params = params [["_equipmentName", "", [""]], ["_backpackName", "", [""]]]; -TRACE_3("",_equipmentName,_backpackName,_params); +private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_backpackName", "", [""]]]; +TRACE_3("",_equipmentName,_backpackName,_argsSuccessfullyParsed); -CHECK(!GVAR(initialized) || !_params); +CHECK(!GVAR(initialized) || !_argsSuccessfullyParsed); private _equipmentNamespaces = GVAR(equipment) getVariable [_equipmentName, []]; if (_equipmentNamespaces isEqualTo []) exitWith { - LOG("Equipment not in Namespace"); + LOG_1("Equipment '%1' not in namespace. Will be initialized.",_equipmentName); [QGVAR(initEquipment), [player, QGVAR(equipBackpack), [_equipmentName, _backpackName]]] call CBA_fnc_serverEvent; }; _equipmentNamespaces params ["", "_backpackNamespace"]; -(_backpackNamespace getVariable [_backpackName, []]) params ["", "", "_class", "_items"]; +private _backpack = _backpackNamespace getVariable [_backpackName, []]; +CHECKRET(_backpack isEqualTo [], WARNING_1("Backpack '%1' not available!", _backpackName)); + +_backpack params ["", "", "_class", "_items"]; removeBackpack player; player addBackpack _class; diff --git a/addons/armory/functions/fnc_equipLoadout.sqf b/addons/armory/functions/fnc_equipLoadout.sqf index b277e7b..0b2c6ea 100644 --- a/addons/armory/functions/fnc_equipLoadout.sqf +++ b/addons/armory/functions/fnc_equipLoadout.sqf @@ -17,21 +17,24 @@ * */ -private _params = params [["_equipmentName", "", [""]], ["_loadoutName", "", [""]]]; -TRACE_3("",_equipmentName,_loadoutName,_params); +private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_loadoutName", "", [""]]]; +TRACE_3("",_equipmentName,_loadoutName,_argsSuccessfullyParsed); -CHECK(!GVAR(initialized) || !_params); +CHECK(!GVAR(initialized) || !_argsSuccessfullyParsed); private _equipmentNamespaces = GVAR(equipment) getVariable [_equipmentName, []]; if (_equipmentNamespaces isEqualTo []) exitWith { - LOG("Equipment not in Namespace"); + LOG_1("Equipment '%1' not in namespace. Will be initialized.",_equipmentName); [QGVAR(initEquipment), [player, QGVAR(equipLoadout), [_equipmentName, _loadoutName]]] call CBA_fnc_serverEvent; }; _equipmentNamespaces params ["_loadoutNamespace"]; -(_loadoutNamespace getVariable [_loadoutName, []]) params ["", "", "_loadout", "_ace_medic", "_ace_engineer"]; +private _loadout = _loadoutNamespace getVariable [_loadoutName, []]; +CHECKRET(_loadout isEqualTo [], WARNING_1("Loadout '%1' not available!", _loadoutName)); + +_loadout params ["", "", "_loadout", "_ace_medic", "_ace_engineer"]; player setUnitLoadout [_loadout, true]; player setVariable ["ace_medical_medicclass", _ace_medic, true]; diff --git a/addons/armory/functions/fnc_initEquipment.sqf b/addons/armory/functions/fnc_initEquipment.sqf index 0ce35dd..c8b1ab7 100644 --- a/addons/armory/functions/fnc_initEquipment.sqf +++ b/addons/armory/functions/fnc_initEquipment.sqf @@ -19,7 +19,8 @@ params [["_equipmentName", "", [""]]]; TRACE_1("", _equipmentName); -CHECKRET(!GVAR(initialized) || _equipmentName isEqualTo "" || !SERVER_CHECK,false); +CHECKRET(!GVAR(initialized) || _equipmentName isEqualTo "",false); +CHECKRET(!isDedicated && !GVAR(allowPlayerDBConnection),false); CHECKRET(_equipmentName in GVAR(equipmentInitialized),true); private _equipmentInfo = [GVAR(sessionID), "getEquipmentInfo", _equipmentName] call DB_GET; @@ -54,4 +55,5 @@ GVAR(equipment) setVariable [_equipmentName, [_loadoutNamespace, _backpackNamesp GVAR(equipmentInitialized) pushBackUnique _equipmentName; TRACE_1("",GVAR(equipmentInitialized)); +LOG_1("Equipment '%1' initialized",_equipmentName); true diff --git a/addons/armory/functions/fnc_openNewEquipmentDialog.sqf b/addons/armory/functions/fnc_openNewEquipmentDialog.sqf new file mode 100644 index 0000000..7ec6a76 --- /dev/null +++ b/addons/armory/functions/fnc_openNewEquipmentDialog.sqf @@ -0,0 +1,25 @@ +#include "script_component.hpp" +/** + * Author: PhILoX + * + * Description: + * Gets attached object and opens "newEquipment" dialog + * + * Parameter(s): + * 0: CONTROL - Button control of "Button_New_Equipment" from main dialog + * + * Returns: + * Nothing + * + * Example: + * [_buttonCtrl] call mts_armory_fnc_openNewEquipmentDialog + * + */ + +params [["_buttonCtrl", controlNull, [controlNull]]]; +CHECK(isNull _buttonCtrl); + +private _attachToObject = _buttonCtrl getVariable [QGVAR(attachedObject), objNull]; +closeDialog 0; +createDialog QGVAR(newEquipment); +((findDisplay IDD_NEW_EQUIPMENT) displayCtrl IDC_BUTTON_CREATE) setVariable [QGVAR(attachedObject), _attachToObject]; diff --git a/addons/armory/functions/fnc_saveEquipment.sqf b/addons/armory/functions/fnc_saveEquipment.sqf index 3e52374..3ddc89d 100644 --- a/addons/armory/functions/fnc_saveEquipment.sqf +++ b/addons/armory/functions/fnc_saveEquipment.sqf @@ -47,7 +47,7 @@ _ctrlSave setVariable [QGVAR(oldName), _name]; switch (_category) do { case (LOADOUT): { if (_delete) then { - _loadoutNamespace setVariable [_oldName, nil]; + _loadoutNamespace setVariable [_oldName, [], true]; _name = ""; } else { private _ace_medic = lbCurSel IDC_LISTBOX_MEDIC; @@ -66,7 +66,7 @@ switch (_category) do { }; }; if !(_name isEqualTo _oldName) then { - _loadoutNamespace setVariable [_oldName, nil]; + _loadoutNamespace setVariable [_oldName, [], true]; }; _loadoutNamespace setVariable [_name, [_name, _idc, _loadout, _ace_medic, _ace_engineer], true]; @@ -75,7 +75,7 @@ switch (_category) do { }; case (BACKPACK): { if (_delete) then { - _backpackNamespace setVariable [_oldName, nil]; + _backpackNamespace setVariable [_oldName, [], true]; _name = ""; } else { private _class = backpack player; @@ -89,7 +89,7 @@ switch (_category) do { } forEach _items; }; if !(_name isEqualTo _oldName) then { - _backpackNamespace setVariable [_oldName, nil]; + _backpackNamespace setVariable [_oldName, [], true]; }; _backpackNamespace setVariable [_name, [_name, _idc, _class, _items], true]; diff --git a/addons/armory/functions/fnc_setEditArea.sqf b/addons/armory/functions/fnc_setEditArea.sqf index 22f740f..6a5c3d8 100644 --- a/addons/armory/functions/fnc_setEditArea.sqf +++ b/addons/armory/functions/fnc_setEditArea.sqf @@ -17,12 +17,12 @@ * */ -private _params = params [["_idc", -1, [0]], ["_category", -1, [0]]]; +private _argsSuccessfullyParsed = params [["_idc", -1, [0]], ["_category", -1, [0]]]; private _display = findDisplay IDD_EQUIPMENT; private _ctrlSave = _display displayCtrl IDC_BUTTON_SAVE_EQUIPMENT; TRACE_4("",_idc,_category,_display,_ctrlSave); -CHECK(!GVAR(initialized) || isNull _display || !_params || !(_idc > 0) || !(_category > 0)); +CHECK(!GVAR(initialized) || isNull _display || !_argsSuccessfullyParsed || !(_idc > 0) || !(_category > 0)); private _name = ctrlText _idc; diff --git a/addons/armory/functions/fnc_updateArsenal.sqf b/addons/armory/functions/fnc_updateArsenal.sqf index ab7ea82..d59f7e0 100644 --- a/addons/armory/functions/fnc_updateArsenal.sqf +++ b/addons/armory/functions/fnc_updateArsenal.sqf @@ -17,12 +17,12 @@ * */ -private _params = params [["_equipmentName", "", [""]], ["_status", false, [false]]]; -TRACE_3("", _equipmentName, _status, _params); +private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_status", false, [false]]]; +TRACE_3("", _equipmentName, _status, _argsSuccessfullyParsed); CHECK(!GVAR(initialized) || !_params); -if (SERVER_CHECK) then { +if (isDedicated || GVAR(allowPlayerDBConnection)) then { private _equipmentArray = GVAR(equipment) getVariable [_equipmentName, []]; private _equipmentID = _equipmentArray param [2, 0]; diff --git a/addons/armory/functions/fnc_updateBackpack.sqf b/addons/armory/functions/fnc_updateBackpack.sqf index 8804063..a565fd7 100644 --- a/addons/armory/functions/fnc_updateBackpack.sqf +++ b/addons/armory/functions/fnc_updateBackpack.sqf @@ -29,7 +29,8 @@ private _params = params [["_equipmentName", "", [""]], ["_name", "", [""]], ["_oldName", "", [""]]]; -CHECK(!GVAR(initialized) || !_params || !SERVER_CHECK); +CHECK(!GVAR(initialized) || !_params); +CHECK(!isDedicated && !GVAR(allowPlayerDBConnection)); (GVAR(equipment) getVariable [_equipmentName, []]) params ["", "_backpackNamespace", "", "_equipmentID"]; _backpackNamespace getVariable [_name, []] params ["", "_idc", "_class", "_items"]; diff --git a/addons/armory/functions/fnc_updateEditors.sqf b/addons/armory/functions/fnc_updateEditors.sqf index 9dd039f..8ea0853 100644 --- a/addons/armory/functions/fnc_updateEditors.sqf +++ b/addons/armory/functions/fnc_updateEditors.sqf @@ -34,7 +34,8 @@ private _checkEditors = false; }; } count _editors; -CHECK(!GVAR(initialized) || !_params || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo "") || !SERVER_CHECK || _checkEditors); +CHECK(!GVAR(initialized) || !_params || _equipmentName isEqualTo "" || ((_editors param [ARR_2(0,"")]) isEqualTo "") || _checkEditors); +CHECK(!isDedicated && !GVAR(allowPlayerDBConnection)); private _equipmentArray = GVAR(equipment) getVariable [_equipmentName, []]; private _equipmentID = _equipmentArray param [3, 0]; diff --git a/addons/armory/functions/fnc_updateLoadout.sqf b/addons/armory/functions/fnc_updateLoadout.sqf index 0ddd75f..e2e452f 100644 --- a/addons/armory/functions/fnc_updateLoadout.sqf +++ b/addons/armory/functions/fnc_updateLoadout.sqf @@ -27,9 +27,10 @@ * */ -private _params = params [["_equipmentName", "", [""]], ["_name", "", [""]], ["_oldName", "", [""]]]; +private _argsSuccessfullyParsed = params [["_equipmentName", "", [""]], ["_name", "", [""]], ["_oldName", "", [""]]]; -CHECK(!GVAR(initialized) || !_params || !SERVER_CHECK); +CHECK(!GVAR(initialized) || !_argsSuccessfullyParsed); +CHECK(!isDedicated && !GVAR(allowPlayerDBConnection)); (GVAR(equipment) getVariable [_equipmentName, []]) params ["_loadoutNamespace", "", "", "_equipmentID"]; _loadoutNamespace getVariable [_name, []] params ["", "_idc", "_loadout", "_ace_medic", "_ace_engineer"]; diff --git a/addons/armory/initSettings.hpp b/addons/armory/initSettings.hpp new file mode 100644 index 0000000..e689bbd --- /dev/null +++ b/addons/armory/initSettings.hpp @@ -0,0 +1,21 @@ +[ + QGVAR(openUIActionMenu), + "LIST", + [LLSTRING(openUIActionMenu), LLSTRING(openUIActionMenu_tooltip)], + [LELSTRING(main,category), LLSTRING(displayName)], + [["ace_interaction","scroll_menu"],[LLSTRING(openUIActionMenu_ace_interaction), LLSTRING(openUIActionMenu_scroll_menu)],0], + 1, + {} +] call CBA_settings_fnc_init; + +[ + QGVAR(allowPlayerDBConnection), + "CHECKBOX", + [LLSTRING(allowPlayerDBConnection), LLSTRING(allowPlayerDBConnection_tooltip)], + [LELSTRING(main,category), LLSTRING(displayName)], + false, + 0, + {}, + true +] call CBA_fnc_addSetting; + diff --git a/addons/armory/script_component.hpp b/addons/armory/script_component.hpp index 4aac8b5..3424a2f 100644 --- a/addons/armory/script_component.hpp +++ b/addons/armory/script_component.hpp @@ -2,7 +2,6 @@ #define COMPONENT_BEAUTIFIED Armory #include "\z\mts_enhanced\addons\main\script_mod.hpp" -// #define DEBUG_CLIENT_SERVER // #define DEBUG_MODE_FULL // #define DISABLE_COMPILE_CACHE // #define CBA_DEBUG_SYNCHRONOUS diff --git a/addons/armory/stringtable.xml b/addons/armory/stringtable.xml index 00c3140..b352da3 100644 --- a/addons/armory/stringtable.xml +++ b/addons/armory/stringtable.xml @@ -46,8 +46,8 @@ Erstellen - Initializes equipment category after creation and if possible adds action for everyone - Initialisiert die Ausrüstungskategorie und fügt, falls möglich, eine Aktion für jeden hinzu + If possible, adds interaction menu for the newly created equipment.\n(Depending on whether an object was passed to the openArmoy function) + Wenn möglich, fügt ein Interaktionsmenü für die neu erstellte Ausrüstungskategorie hinzu.\n(Abhängig davon, ob ein Objekt an die Funktion openArmoy übergeben wurde) Equipment category '%1' couldn't be created! @@ -85,5 +85,31 @@ Who is permitted to edit this equipment category? Format: ["PlayerUID", "PlayerUID", ...] Wer darf diese Ausrüstungskategorie bearbeiten? Format: ["PlayerUID", "PlayerUID", ...] + + + Interaction menu + Interaktionsmenü + + + Sets the interaction menu, for newly created equipment categories, which should be used. If ACE is not present, it will fall back to Vanilla system. + Setzt das Interaktionsmenü, bei neu erstellen Ausrüstungskategorien, welches benutzt werden soll. Wenn ACE nicht geladen ist, wird das Vanilla system verwendet. + + + ACE Interaction + ACE Interaktionsmenü + + + Scroll menu (Vanilla) + Scrollmenü (Vanilla) + + + DEBUG: Allow Player database connection + DEBUG: Erlaube Spieler Datenbankverbindung + + + DEBUG: Allow the player to connect to the armory database. The mod ExtDB3 and a proper configurationen is needed! + DEBUG: Erlaube dem Spieler, sich mit der Ausrüstungsdatenbank zu verbinden. Die Mod ExtDB3 und die entsprechende Konfigurationen wird benötigt! + + diff --git a/addons/armory/ui/RscAttributes.hpp b/addons/armory/ui/RscAttributes.hpp index e9737f5..6f9d1bc 100644 --- a/addons/armory/ui/RscAttributes.hpp +++ b/addons/armory/ui/RscAttributes.hpp @@ -62,12 +62,7 @@ class GVAR(dialog) { y = "SafeZoneY + (180 / 1080) * SafeZoneH"; w = "(30 / 1920) * SafeZoneW"; h = "(30 / 1080) * SafeZoneH"; - onButtonClick = QUOTE(\ - private _object = ((_this select 0) getVariable [ARR_2(QQGVAR(attachedObject),objNull)]);\ - closeDialog 0;\ - createDialog QQGVAR(newEquipment);\ - ((findDisplay IDD_NEW_EQUIPMENT) displayCtrl IDC_BUTTON_CREATE) setVariable [ARR_2(QQGVAR(attachedObject), _object)];\ - ); + onButtonClick = QUOTE([_this select 0] call LINKFUNC(openNewEquipmentDialog)); onMouseEnter = QUOTE(((ctrlParent (_this select 0)) displayCtrl IDC_BACKGROUND_NEW_EQUIPMENT) ctrlSetBackgroundColor [ARR_4(0,0,0,1)]); onMouseExit = QUOTE(((ctrlParent (_this select 0)) displayCtrl IDC_BACKGROUND_NEW_EQUIPMENT) ctrlSetBackgroundColor [ARR_4(0,0,0,0.5)]); }; @@ -1081,7 +1076,7 @@ class GVAR(newEquipment) { y = "SafeZoneY + (525 / 1080) * SafeZoneH"; w = "(150 / 1920) * SafeZoneW"; h = "(30 / 1080) * SafeZoneH"; - onButtonClick = QUOTE([ARR_2(QQGVAR(createEquipment), [ARR_4(ctrlText IDC_EDITBOX_EQUIPMENT, [(getPlayerUID player)], cbChecked ((ctrlParent (_this select 0)) displayCtrl IDC_CHECKBOX_EQUIPMENT), (_this select 0) getVariable [ARR_2(QQGVAR(attachedObject), objNull)])])] call CBA_fnc_serverEvent; closeDialog 0); + onButtonClick = QUOTE([_this select 0] call LINKFUNC(buttonCreateEquipment)); }; }; class controlsBackground { From d3f92a316e767b79fc4d417c8104ed406739fcaa Mon Sep 17 00:00:00 2001 From: Timi007 Date: Sat, 23 Sep 2023 14:21:05 +0200 Subject: [PATCH 2/3] Add VSCode workspace settings (#102) --- .gitignore | 2 -- .vscode/extensions.json | 7 +++++++ .vscode/settings.json | 24 ++++++++++++++++++++++++ .vscode/sqf.code-snippets | 27 +++++++++++++++++++++++++++ .vscode/tasks.json | 31 +++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/sqf.code-snippets create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index aefb6f4..64dca67 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,3 @@ releases/* keys/* .hemtt/local #### - -.vscode/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..127ac5e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "blackfisch.sqf-language", + "editorconfig.editorconfig", + "bux578.vscode-openlastrpt" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ce71ff4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,24 @@ +{ + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.hg": true, + "**/CVS": true, + "**/.DS_Store": true, + "**/Thumbs.db": true, + "**/*.pbo": true, + "**/*.exe": true, + "**/keys": true, + "**/release": true, + }, + "files.associations": { + "**/*.hpp": "ext", + // "**/*.hpp": "cpp", + "**/*.cpp": "ext", + "**/XEH_PREP.hpp": "sqf", + "*.rpt": "log", + "init*.hpp": "sqf", + }, + "sqf.enableACE3": true, + "sqf.enableCBA": true, +} diff --git a/.vscode/sqf.code-snippets b/.vscode/sqf.code-snippets new file mode 100644 index 0000000..0ac8810 --- /dev/null +++ b/.vscode/sqf.code-snippets @@ -0,0 +1,27 @@ +{ + "SQF Function header": { + "description": "SQF Function header", + "prefix": "header", + "body": [ + "#include \"script_component.hpp\"", + "/**", + " * Author: ${1:Author}", + " *", + " * Description:", + " * ${2:Description}", + " *", + " * Parameter(s):", + " * ${3:0: TYPE - Parameter description}", + " *", + " * Returns:", + " * ${4:TYPE - Description}", + " *", + " * Example:", + " * _this call mts_${TM_DIRECTORY/(.*)addons\\\\(.*)\\\\functions(.*)/$2/}_${TM_FILENAME_BASE}", + " *", + " */", + "", + "params [];" + ], + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..629df82 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,31 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build Debug", + "detail": "Build Arma addon with HEMTT in debug mode.", + "type": "process", + "command": "hemtt.exe", + "args": ["build"], + "group": "build", + "presentation": { + "close": true, + "reveal": "always", + "showReuseMessage": false + } + }, + { + "label": "Build Release", + "detail": "Build Arma addon with HEMTT for release.", + "type": "process", + "command": "hemtt.exe", + "args": [ + "build", + "--release", + "--time", + "-f" + ], + "group": "build" + } + ] +} From 02aacec135f8cf27ae4eb5b9173c72cc9e46d21e Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 23 Sep 2023 14:25:46 +0200 Subject: [PATCH 3/3] Bump to 1.6.1 --- README.md | 2 +- addons/main/script_version.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 02ef454..6b5d00e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

- Metis Enhanced Version + Metis Enhanced Version Metis Enhanced Downloads diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index ad833ec..bcb75d2 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 1 #define MINOR 6 -#define PATCHLVL 0 -#define BUILD 230325 +#define PATCHLVL 1 +#define BUILD 230923