From 4d6fd85b485f2ab7f786fd32d8cb9fe5fba0c60e Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 9 Jan 2021 02:08:03 -0500 Subject: [PATCH 01/31] Saved Selection and Transfer Ownership --- addons/common/XEH_postInit.sqf | 28 ++++++++ addons/editor/XEH_PREP.hpp | 2 + addons/editor/XEH_preInit.sqf | 7 ++ .../functions/fnc_drawSavedSelectionIcons.sqf | 33 +++++++++ .../functions/fnc_handleSelectionChanged.sqf | 23 ++++++ addons/modules/CfgVehicles.hpp | 8 +++ addons/modules/XEH_PREP.hpp | 1 + addons/modules/config.cpp | 1 + .../functions/fnc_moduleTransferOwnership.sqf | 72 +++++++++++++++++++ addons/modules/stringtable.xml | 12 ++++ 10 files changed, 187 insertions(+) create mode 100644 addons/editor/functions/fnc_drawSavedSelectionIcons.sqf create mode 100644 addons/editor/functions/fnc_handleSelectionChanged.sqf create mode 100644 addons/modules/functions/fnc_moduleTransferOwnership.sqf diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 99feea14b..c12c6cc41 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -314,10 +314,38 @@ if (isServer) then { }] call CBA_fnc_addEventHandler; [QGVAR(enableSimulationGlobal), { + diag_log _this; params ["_object", "_enable"]; _object enableSimulationGlobal _enable; }] call CBA_fnc_addEventHandler; + [QGVAR(transferOwnership), { + diag_log QGVAR(transferOwnership); + diag_log _this; + params ["_entities", "_target"]; + if (!(_entities isEqualType [])) then { + _entities = [_entities]; + }; + private _clientID = 0; + if (_target isEqualType 0) then { + _clientID = _target; + }; + if (_target isEqualType objNull) then { + _clientID = owner _target; + }; + { + if (_x isEqualType grpNull) then { + _x setGroupOwner _clientID; + } else { + if (group _x == grpNull) then { + group _x setGroupOwner _clientID; + } else { + _x setOwner _clientID; + }; + }; + } forEach _entities; + }] call CBA_fnc_addEventHandler; + [QGVAR(setFriend), { params ["_side1", "_side2", "_value"]; _side1 setFriend [_side2, _value]; diff --git a/addons/editor/XEH_PREP.hpp b/addons/editor/XEH_PREP.hpp index c35e8d435..d0ccc37c2 100644 --- a/addons/editor/XEH_PREP.hpp +++ b/addons/editor/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(addGroupIcons); PREP(declutterEmptyTree); +PREP(drawSavedSelectionIcons); PREP(fixSideButtons); PREP(handleKeyDown); PREP(handleLoad); @@ -9,6 +10,7 @@ PREP(handleSearchButton); PREP(handleSearchClick); PREP(handleSearchKeyDown); PREP(handleSearchKeyUp); +PREP(handleSelectionChanged); PREP(handleSideButtons); PREP(handleTreeButtons); PREP(handleUnload); diff --git a/addons/editor/XEH_preInit.sqf b/addons/editor/XEH_preInit.sqf index 3a9860073..43f6403d1 100644 --- a/addons/editor/XEH_preInit.sqf +++ b/addons/editor/XEH_preInit.sqf @@ -9,6 +9,9 @@ PREP_RECOMPILE_END; #include "initSettings.sqf" #include "initKeybinds.sqf" +GVAR(lastSelection) = []; +GVAR(savedSelection) = []; +GVAR(colour) = ["IGUI", "TEXT_RGB"] call BIS_fnc_displayColorGet; GVAR(clipboard) = []; GVAR(includeCrew) = true; @@ -16,6 +19,10 @@ GVAR(includeCrew) = true; params ["_logic"]; _logic addEventHandler ["CuratorObjectPlaced", {call FUNC(handleObjectPlaced)}]; + _logic addEventHandler ["CuratorGroupSelectionChanged", {call FUNC(handleSelectionChanged)}]; + _logic addEventHandler ["CuratorMarkerSelectionChanged", {call FUNC(handleSelectionChanged)}]; + _logic addEventHandler ["CuratorObjectSelectionChanged", {call FUNC(handleSelectionChanged)}]; + _logic addEventHandler ["CuratorWaypointSelectionChanged", {call FUNC(handleSelectionChanged)}]; }, true, [], true] call CBA_fnc_addClassEventHandler; ADDON = true; diff --git a/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf b/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf new file mode 100644 index 000000000..9962a7003 --- /dev/null +++ b/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf @@ -0,0 +1,33 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Draws icons over saved selection entities. + * + * Arguments: + * 0: Icon + * + * Return Value: + * 0: Draw3D mission EH handle + * + * Example: + * ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call zen_editor_fnc_drawSavedSelectionIcons + * + * Public: No + */ + +if (GVAR(savedSelection) select 0 isEqualTo []) exitWith { + -1 +}; + +params ["_icon"]; + +private _mehID = addMissionEventHandler ["Draw3D", { + { + drawIcon3D [ + "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa", + GVAR(colour), getPos _x, 1, 1, 0 + ]; + } forEach (GVAR(savedSelection) select 0); +}]; + +_mehID diff --git a/addons/editor/functions/fnc_handleSelectionChanged.sqf b/addons/editor/functions/fnc_handleSelectionChanged.sqf new file mode 100644 index 000000000..50a1686b3 --- /dev/null +++ b/addons/editor/functions/fnc_handleSelectionChanged.sqf @@ -0,0 +1,23 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Saves curator selected entities for use by modules. + * + * Arguments: + * 0: Curator + * 0: Entity: group, marker, object, or waypoint + * + * Return Value: + * Handled + * + * Example: + * [CONTROL] call zen_editor_fnc_handleSelectionChanged + * + * Public: No + */ + +params ["_curator", "_entity"]; +GVAR(savedSelection) = GVAR(lastSelection); +GVAR(lastSelection) = curatorSelected; + +false diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index 7247d45cc..ec543cde3 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -422,6 +422,14 @@ class CfgVehicles { function = QFUNC(moduleToggleLamps); icon = QPATHTOF(ui\street_lamp_ca.paa); }; + class GVAR(moduleTransferOwnership): GVAR(moduleBase) { + curatorCanAttach = 1; + category = QGVAR(DevTools); + displayName = CSTRING(ModuleTransferOwnership); + function = QFUNC(moduleTransferOwnership); + icon = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"; + portrait = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"; + }; class GVAR(moduleTurretOptics): GVAR(moduleBase) { curatorCanAttach = 1; category = QGVAR(Equipment); diff --git a/addons/modules/XEH_PREP.hpp b/addons/modules/XEH_PREP.hpp index 6306638ed..461d7b2a3 100644 --- a/addons/modules/XEH_PREP.hpp +++ b/addons/modules/XEH_PREP.hpp @@ -80,6 +80,7 @@ PREP(moduleTeleportPlayers); PREP(moduleToggleFlashlights); PREP(moduleToggleIRLasers); PREP(moduleToggleLamps); +PREP(moduleTransferOwnership); PREP(moduleTurretOptics); PREP(moduleUnGarrison); PREP(moduleVisibility); diff --git a/addons/modules/config.cpp b/addons/modules/config.cpp index 7fb016182..e96fc792b 100644 --- a/addons/modules/config.cpp +++ b/addons/modules/config.cpp @@ -65,6 +65,7 @@ class CfgPatches { QGVAR(moduleToggleFlashlights), QGVAR(moduleToggleIRLasers), QGVAR(moduleToggleLamps), + QGVAR(ModuleTransferOwnership), QGVAR(moduleTurretOptics), QGVAR(moduleUnGarrison), QGVAR(moduleVisibility), diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf new file mode 100644 index 000000000..00ec353c6 --- /dev/null +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -0,0 +1,72 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Zeus module function to transfer ownership of objects. + * + * Arguments: + * 0: Logic + * + * Return Value: + * None + * + * Example: + * [LOGIC] call zen_modules_fnc_moduleTransferOwnership + * + * Public: No + */ + +if (!isMultiplayer) exitWith { + [LSTRING(OnlyMultiplayer)] call EFUNC(common,showMessage); +}; + +params ["_logic"]; + +private _unit = attachedTo _logic; +deleteVehicle _logic; + +private _clientTypes = allPlayers; +private _clientNames = allPlayers apply {name _x}; +if (!isServer) then { + _clientTypes = [2] + _clientTypes; + _clientNames = ["Server"] + _clientNames; +}; + +private _entities = []; +private _mehID = -1; +if (isNull _unit) then { + _mehID = ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call EFUNC(editor,drawSavedSelectionIcons); + EGVAR(editor,savedSelection) params ["_objects", "_groups"]; + { + if (isNull group _x) then { + _entities pushBack _x; + } else { + _groups pushBackUnique group _x; + }; + } forEach _objects; + _entities append _groups; +} else { + _entities = [[group _unit, _unit] select (isNull group _unit)]; +}; + +[LSTRING(ModuleTransferOwnership), [ + [ + "COMBO", + ELSTRING(common,Target), + [_clientTypes, _clientNames, 0] + ] +], { + params ["_values", "_args"]; + _args params ["_entities", "_mehID"]; + if (_mehID > 0) then { + removeMissionEventHandler ["Draw3D", _mehID]; + }; + + _values params ["_target"]; + [QEGVAR(common,transferOwnership), [_entities, _target]] call CBA_fnc_serverEvent; +}, { + params ["", "_args"]; + _args params ["", "_mehID"]; + if (_mehID > 0) then { + removeMissionEventHandler ["Draw3D", _mehID]; + }; +}, [_entities, _mehID]] call EFUNC(dialog,create); diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 30b802da8..f8988a5da 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -590,6 +590,15 @@ CAS - 爆撃 CAS - 폭탄 투하 + + Transfer Ownership + + + Client + + + Server + Bind Variable To Object Привязать переменную к объекту @@ -2207,6 +2216,9 @@ 소환 + + Module only available in multiplayer + Place on a unit Placez sur une unité From 92f5c614981b0d539edcdc93a893d7553eec21eb Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 9 Jan 2021 13:10:23 -0500 Subject: [PATCH 02/31] Toolbox for most Server and Curator targets --- .../functions/fnc_moduleTransferOwnership.sqf | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 00ec353c6..ffbcc29ba 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -27,8 +27,8 @@ deleteVehicle _logic; private _clientTypes = allPlayers; private _clientNames = allPlayers apply {name _x}; if (!isServer) then { - _clientTypes = [2] + _clientTypes; - _clientNames = ["Server"] + _clientNames; + _clientTypes = [0] + _clientTypes; + _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; }; private _entities = []; @@ -48,21 +48,41 @@ if (isNull _unit) then { _entities = [[group _unit, _unit] select (isNull group _unit)]; }; +private _defaultTarget = !local (_entities select 0); [LSTRING(ModuleTransferOwnership), [ [ - "COMBO", + "TOOLBOX", ELSTRING(common,Target), + [_defaultTarget, 1, 3, [ + LSTRING(ModuleTransferOwnership_Server), + "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1", + LSTRING(ModuleTransferOwnership_Client) + ]] + ], + [ + "COMBO", + LSTRING(ModuleTransferOwnership_Client), [_clientTypes, _clientNames, 0] ] ], { params ["_values", "_args"]; + _values params ["_target", "_player"]; _args params ["_entities", "_mehID"]; if (_mehID > 0) then { removeMissionEventHandler ["Draw3D", _mehID]; }; - - _values params ["_target"]; - [QEGVAR(common,transferOwnership), [_entities, _target]] call CBA_fnc_serverEvent; + private _targetID = switch (_target) do { + case (0): { + 2 + }; + case (1): { + clientOwner + }; + case (2): { + _player + }; + }; + [QEGVAR(common,transferOwnership), [_entities, _targetID]] call CBA_fnc_serverEvent; }, { params ["", "_args"]; _args params ["", "_mehID"]; From c85e34fd64a07f571834aeb50f0f8fbb6cf9cb23 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 9 Jan 2021 14:30:53 -0500 Subject: [PATCH 03/31] Check for players in selection --- .../functions/fnc_moduleTransferOwnership.sqf | 33 ++++++++++++------- addons/modules/stringtable.xml | 3 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index ffbcc29ba..aa440c6d4 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Ampersand - * Zeus module function to transfer ownership of objects. + * Zeus module function to transfer ownership of objects and groups. * * Arguments: * 0: Logic @@ -24,17 +24,9 @@ params ["_logic"]; private _unit = attachedTo _logic; deleteVehicle _logic; -private _clientTypes = allPlayers; -private _clientNames = allPlayers apply {name _x}; -if (!isServer) then { - _clientTypes = [0] + _clientTypes; - _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; -}; - private _entities = []; -private _mehID = -1; if (isNull _unit) then { - _mehID = ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call EFUNC(editor,drawSavedSelectionIcons); + // No attached unit, get saved selection EGVAR(editor,savedSelection) params ["_objects", "_groups"]; { if (isNull group _x) then { @@ -48,7 +40,22 @@ if (isNull _unit) then { _entities = [[group _unit, _unit] select (isNull group _unit)]; }; +if (_entities findIf {units _x findIf {isPlayer _x} > -1} > -1) exitWith { + [LSTRING(SelectionCannotIncludePlayers)] call EFUNC(common,showMessage); +}; + private _defaultTarget = !local (_entities select 0); +private _clientTypes = allPlayers; +private _clientNames = allPlayers apply {name _x}; +_clientTypes = [0] + _clientTypes; +_clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; + +// Draw icon over entities in saved selection +private _mehID = -1; +if (isNull _unit) then { + _mehID = ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call EFUNC(editor,drawSavedSelectionIcons); +}; + [LSTRING(ModuleTransferOwnership), [ [ "TOOLBOX", @@ -68,12 +75,14 @@ private _defaultTarget = !local (_entities select 0); params ["_values", "_args"]; _values params ["_target", "_player"]; _args params ["_entities", "_mehID"]; + + // Stop drawing icons if (_mehID > 0) then { removeMissionEventHandler ["Draw3D", _mehID]; }; private _targetID = switch (_target) do { case (0): { - 2 + 2 // Server }; case (1): { clientOwner @@ -86,6 +95,8 @@ private _defaultTarget = !local (_entities select 0); }, { params ["", "_args"]; _args params ["", "_mehID"]; + + // Stop drawing icons if (_mehID > 0) then { removeMissionEventHandler ["Draw3D", _mehID]; }; diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index f8988a5da..fed0127e2 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -2216,6 +2216,9 @@ 소환 + + Selection cannot include players + Module only available in multiplayer From 6b84b804cc73607ffb276a291d2c9b5d869f77ff Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 9 Jan 2021 14:32:46 -0500 Subject: [PATCH 04/31] Added module description --- docs/user_guide/modules_list.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/user_guide/modules_list.md b/docs/user_guide/modules_list.md index 7933b1c16..14098183e 100644 --- a/docs/user_guide/modules_list.md +++ b/docs/user_guide/modules_list.md @@ -267,6 +267,10 @@ Toggles the simulation of the attached object. Toggles the visibility of the attached object. +## Transfer Ownership + +Transfer locality of objects and groups between server and clients. + ## Un-Garrison Group Un-garrisons units from the attached group. From 40adda75b36725dd234d555311bce73ad7c86237 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sat, 9 Jan 2021 14:34:08 -0500 Subject: [PATCH 05/31] remove logging --- addons/common/XEH_postInit.sqf | 3 --- 1 file changed, 3 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index c12c6cc41..409e193a5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -314,14 +314,11 @@ if (isServer) then { }] call CBA_fnc_addEventHandler; [QGVAR(enableSimulationGlobal), { - diag_log _this; params ["_object", "_enable"]; _object enableSimulationGlobal _enable; }] call CBA_fnc_addEventHandler; [QGVAR(transferOwnership), { - diag_log QGVAR(transferOwnership); - diag_log _this; params ["_entities", "_target"]; if (!(_entities isEqualType [])) then { _entities = [_entities]; From 3f4bcc268b0ff4a7a7ca11e8c508fc4ba09a5657 Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 10 Jan 2021 20:07:09 +0100 Subject: [PATCH 06/31] Improved selection preview --- addons/dialog/functions/fnc_close.sqf | 2 + addons/editor/XEH_PREP.hpp | 3 +- addons/editor/XEH_preInit.sqf | 11 ++++ .../functions/fnc_drawSavedSelectionIcons.sqf | 33 ---------- addons/editor/functions/fnc_getSelection.sqf | 65 +++++++++++++++++++ addons/editor/functions/fnc_handleLoad.sqf | 21 +++++- .../functions/fnc_toggleSelectionPreview.sqf | 52 +++++++++++++++ addons/modules/CfgVehicles.hpp | 1 + .../functions/fnc_moduleTransferOwnership.sqf | 39 ++++------- 9 files changed, 165 insertions(+), 62 deletions(-) delete mode 100644 addons/editor/functions/fnc_drawSavedSelectionIcons.sqf create mode 100644 addons/editor/functions/fnc_getSelection.sqf create mode 100644 addons/editor/functions/fnc_toggleSelectionPreview.sqf diff --git a/addons/dialog/functions/fnc_close.sqf b/addons/dialog/functions/fnc_close.sqf index 159c4cdc1..3ead79713 100644 --- a/addons/dialog/functions/fnc_close.sqf +++ b/addons/dialog/functions/fnc_close.sqf @@ -38,5 +38,7 @@ if (_confirmed) then { [_values, _args] call _onCancel; }; +[QGVAR(close), [_display, _confirmed]] call CBA_fnc_localEvent; + // Close dialog, returning false to not override engine driven IDC_OK and IDC_CANCEL false diff --git a/addons/editor/XEH_PREP.hpp b/addons/editor/XEH_PREP.hpp index d0ccc37c2..2c2ca3335 100644 --- a/addons/editor/XEH_PREP.hpp +++ b/addons/editor/XEH_PREP.hpp @@ -1,7 +1,7 @@ PREP(addGroupIcons); PREP(declutterEmptyTree); -PREP(drawSavedSelectionIcons); PREP(fixSideButtons); +PREP(getSelection); PREP(handleKeyDown); PREP(handleLoad); PREP(handleModeButtons); @@ -14,3 +14,4 @@ PREP(handleSelectionChanged); PREP(handleSideButtons); PREP(handleTreeButtons); PREP(handleUnload); +PREP(toggleSelectionPreview); diff --git a/addons/editor/XEH_preInit.sqf b/addons/editor/XEH_preInit.sqf index 43f6403d1..b1c61fc21 100644 --- a/addons/editor/XEH_preInit.sqf +++ b/addons/editor/XEH_preInit.sqf @@ -25,4 +25,15 @@ GVAR(includeCrew) = true; _logic addEventHandler ["CuratorWaypointSelectionChanged", {call FUNC(handleSelectionChanged)}]; }, true, [], true] call CBA_fnc_addClassEventHandler; +[QGVAR(ModuleSelChanged), { + params ["_moduleName"]; + + GVAR(savedModuleIcon) = GVAR(lastModuleIcon); + GVAR(lastModuleIcon) = getText (configFile >> "CfgVehicles" >> _moduleName >> "icon"); + + // Toggle selection preview + private _hasSelectionPreview = (getNumber (configFile >> "CfgVehicles" >> _moduleName >> QGVAR(hasSelectionPreview)) isEqualTo 1); + [_hasSelectionPreview] call FUNC(toggleSelectionPreview); +}] call CBA_fnc_addEventHandler; + ADDON = true; diff --git a/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf b/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf deleted file mode 100644 index 9962a7003..000000000 --- a/addons/editor/functions/fnc_drawSavedSelectionIcons.sqf +++ /dev/null @@ -1,33 +0,0 @@ -#include "script_component.hpp" -/* - * Author: Ampersand - * Draws icons over saved selection entities. - * - * Arguments: - * 0: Icon - * - * Return Value: - * 0: Draw3D mission EH handle - * - * Example: - * ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call zen_editor_fnc_drawSavedSelectionIcons - * - * Public: No - */ - -if (GVAR(savedSelection) select 0 isEqualTo []) exitWith { - -1 -}; - -params ["_icon"]; - -private _mehID = addMissionEventHandler ["Draw3D", { - { - drawIcon3D [ - "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa", - GVAR(colour), getPos _x, 1, 1, 0 - ]; - } forEach (GVAR(savedSelection) select 0); -}]; - -_mehID diff --git a/addons/editor/functions/fnc_getSelection.sqf b/addons/editor/functions/fnc_getSelection.sqf new file mode 100644 index 000000000..b9888b751 --- /dev/null +++ b/addons/editor/functions/fnc_getSelection.sqf @@ -0,0 +1,65 @@ +#include "script_component.hpp" +/* + * Author: Ampersand, Kex + * Retrieves and marks the entities a module is applied to. + * This function is meant to be used inside module functions only. + * + * Arguments: + * None + * + * Return Value: + * 0: List of selected objects + * 1: List of selected groups + * 2: List of selected waypoints + * 3: List of selected markers + * + * Example: + * (call zen_editor_fnc_getSelection) params ["_objects", "_groups"]; + * + * Public: No + */ + +BIS_fnc_curatorObjectPlaced_mouseOver params [["_entityType", ""], ["_entity", nil]]; + +// Retrieve selection +GVAR(savedSelection) = switch (_entityType) do { + case "OBJECT": { + [[_entity], [], [], []]; + }; + case "GROUP": { + [[], [_entity], [], []]; + }; + case "ARRAY": { + [[], [], [_entity], []]; + }; + case "STRING": { + [[], [], [], [_entity]]; + }; + default { + GVAR(savedSelection); + }; +}; + +// Turn on selection preview +GVAR(drawSavedSelectionIcons) = addMissionEventHandler ["Draw3D", { + { + drawIcon3D [ + GVAR(savedModuleIcon), + GVAR(colour), getPos _x, 1, 1, 0 + ]; + } forEach (GVAR(savedSelection) select 0); +}]; + +// Turn off selection preview when dialog is colosed +GVAR(toggleSelectionIconEH) = [QEGVAR(dialog,close), { + if !(isNil QGVAR(drawSavedSelectionIcons)) then { + removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; + GVAR(drawSavedSelectionIcons) = nil; + }; + if !(isNil QGVAR(toggleSelectionIconEH)) then { + [QEGVAR(dialog,close), GVAR(toggleSelectionIconEH)] call CBA_fnc_removeEventHandler; + GVAR(toggleSelectionIconEH) = nil; + }; +}] call CBA_fnc_addEventHandler; + +GVAR(savedSelection) diff --git a/addons/editor/functions/fnc_handleLoad.sqf b/addons/editor/functions/fnc_handleLoad.sqf index 899f86a0e..2324f7f02 100644 --- a/addons/editor/functions/fnc_handleLoad.sqf +++ b/addons/editor/functions/fnc_handleLoad.sqf @@ -98,15 +98,30 @@ _display displayAddEventHandler ["KeyDown", {call FUNC(handleKeyDown)}]; IDC_RSCDISPLAYCURATOR_MAINMAP ]; +// Add tree selection changed events +private _ctrlTreeModule = _display displayCtrl IDC_RSCDISPLAYCURATOR_CREATE_MODULES; +_ctrlTreeModule ctrlAddEventHandler ["TreeSelChanged", { + params ["_ctrlTreeModule", "_selectedPath"]; + + [QGVAR(ModuleSelChanged), _ctrlTreeModule tvData _selectedPath] call CBA_fnc_localEvent; +}]; + private _ctrlTreeRecent = _display displayCtrl IDC_RSCDISPLAYCURATOR_CREATE_RECENT; _ctrlTreeRecent ctrlAddEventHandler ["TreeSelChanged", { params ["_ctrlTreeRecent", "_selectedPath"]; + private _recentTreeData = _ctrlTreeRecent tvData _selectedPath; // Store data of selected item to allow for deleting the of crew of objects placed through the recent tree - // tvCurSel is unavailable once the selected item has been placed, the empty path check ensures that the + // tvCurSel is unavailable once the selected item has been placed, the empty string check ensures that the // data is not cleared since this event occurs before the object placed event - if !(_selectedPath isEqualTo []) then { - GVAR(recentTreeData) = _ctrlTreeRecent tvData _selectedPath; + if !(_recentTreeData isEqualTo "") then { + GVAR(recentTreeData) = _recentTreeData; + }; + + if (_recentTreeData isKindOf "Module_F") then { + [QGVAR(ModuleSelChanged), _recentTreeData] call CBA_fnc_localEvent; + } else { + [QGVAR(ModuleSelChanged), ""] call CBA_fnc_localEvent; }; }]; diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf new file mode 100644 index 000000000..3b6a192f6 --- /dev/null +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -0,0 +1,52 @@ +#include "script_component.hpp" +/* + * Author: Ampersand, Kex + * Toggle preview of the current selection + * + * Arguments: + * 0: Turn on preview + * + * Return Value: + * None + * + * Example: + * [true] call zen_editor_fnc_toggleSelectionPreview; + * + * Public: No + */ + +params [["_turnOn", true, [true]]]; + +if (_turnOn) then { + if (isNil QGVAR(toggleSelectionIconEH)) then { + GVAR(toggleSelectionIconEH) = [{ + // Show preview if mouse is not over an entity + if (curatorMouseOver isEqualTo [""]) then { + if (isNil QGVAR(drawSavedSelectionIcons)) then { + GVAR(drawSavedSelectionIcons) = addMissionEventHandler ["Draw3D", { + { + drawIcon3D [ + GVAR(lastModuleIcon), + GVAR(colour), getPos _x, 1, 1, 0 + ]; + } forEach (GVAR(lastSelection) select 0); + }]; + }; + } else { + if !(isNil QGVAR(drawSavedSelectionIcons)) then { + removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; + GVAR(drawSavedSelectionIcons) = nil + }; + }; + }, 0] call CBA_fnc_addPerFrameHandler; + }; +} else { + if !(isNil QGVAR(toggleSelectionIconEH)) then { + [GVAR(toggleSelectionIconEH)] call CBA_fnc_removePerFrameHandler; + GVAR(toggleSelectionIconEH) = nil; + }; + if !(isNil QGVAR(drawSavedSelectionIcons)) then { + removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; + GVAR(drawSavedSelectionIcons) = nil; + }; +}; diff --git a/addons/modules/CfgVehicles.hpp b/addons/modules/CfgVehicles.hpp index ec543cde3..951e52114 100644 --- a/addons/modules/CfgVehicles.hpp +++ b/addons/modules/CfgVehicles.hpp @@ -429,6 +429,7 @@ class CfgVehicles { function = QFUNC(moduleTransferOwnership); icon = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"; portrait = "\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"; + EGVAR(editor,hasSelectionPreview) = 1; }; class GVAR(moduleTurretOptics): GVAR(moduleBase) { curatorCanAttach = 1; diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index aa440c6d4..4e2fef5c7 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -15,30 +15,25 @@ * Public: No */ +params ["_logic"]; + if (!isMultiplayer) exitWith { - [LSTRING(OnlyMultiplayer)] call EFUNC(common,showMessage); + [LSTRING(OnlyMultiplayer)] call EFUNC(common,showMessage); + deleteVehicle _logic; }; -params ["_logic"]; - -private _unit = attachedTo _logic; deleteVehicle _logic; private _entities = []; -if (isNull _unit) then { - // No attached unit, get saved selection - EGVAR(editor,savedSelection) params ["_objects", "_groups"]; - { - if (isNull group _x) then { - _entities pushBack _x; - } else { - _groups pushBackUnique group _x; - }; - } forEach _objects; - _entities append _groups; -} else { - _entities = [[group _unit, _unit] select (isNull group _unit)]; -}; +(call EFUNC(editor,getSelection)) params ["_objects", "_groups"]; +{ + if (isNull group _x) then { + _entities pushBack _x; + } else { + _groups pushBackUnique group _x; + }; +} forEach _objects; +_entities append _groups; if (_entities findIf {units _x findIf {isPlayer _x} > -1} > -1) exitWith { [LSTRING(SelectionCannotIncludePlayers)] call EFUNC(common,showMessage); @@ -49,13 +44,7 @@ private _clientTypes = allPlayers; private _clientNames = allPlayers apply {name _x}; _clientTypes = [0] + _clientTypes; _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; - -// Draw icon over entities in saved selection -private _mehID = -1; -if (isNull _unit) then { - _mehID = ["\a3\ui_f\data\Map\VehicleIcons\iconVirtual_ca.paa"] call EFUNC(editor,drawSavedSelectionIcons); -}; - +systemChat str _entities; [LSTRING(ModuleTransferOwnership), [ [ "TOOLBOX", From 344c9d3d3ca7fa7058730e7cd2c1cf1dfc1b36ba Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Sun, 10 Jan 2021 16:11:21 -0500 Subject: [PATCH 07/31] Force toolbox default value --- addons/modules/functions/fnc_moduleTransferOwnership.sqf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 4e2fef5c7..baec50875 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -53,7 +53,8 @@ systemChat str _entities; LSTRING(ModuleTransferOwnership_Server), "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1", LSTRING(ModuleTransferOwnership_Client) - ]] + ]], + true ], [ "COMBO", From ebffcfc3a947cb55765aaf0d945b148c9620fc50 Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 10 Jan 2021 22:14:23 +0100 Subject: [PATCH 08/31] Clean-up --- addons/editor/functions/fnc_getSelection.sqf | 27 ++++++------------- .../functions/fnc_toggleSelectionPreview.sqf | 26 +++++++++--------- .../functions/fnc_moduleTransferOwnership.sqf | 2 +- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/addons/editor/functions/fnc_getSelection.sqf b/addons/editor/functions/fnc_getSelection.sqf index b9888b751..462a05345 100644 --- a/addons/editor/functions/fnc_getSelection.sqf +++ b/addons/editor/functions/fnc_getSelection.sqf @@ -22,7 +22,7 @@ BIS_fnc_curatorObjectPlaced_mouseOver params [["_entityType", ""], ["_entity", nil]]; // Retrieve selection -GVAR(savedSelection) = switch (_entityType) do { +GVAR(lastSelection) = switch (_entityType) do { case "OBJECT": { [[_entity], [], [], []]; }; @@ -41,25 +41,14 @@ GVAR(savedSelection) = switch (_entityType) do { }; // Turn on selection preview -GVAR(drawSavedSelectionIcons) = addMissionEventHandler ["Draw3D", { - { - drawIcon3D [ - GVAR(savedModuleIcon), - GVAR(colour), getPos _x, 1, 1, 0 - ]; - } forEach (GVAR(savedSelection) select 0); -}]; +GVAR(lastModuleIcon) = GVAR(savedModuleIcon); +[true] call FUNC(toggleSelectionPreview); // Turn off selection preview when dialog is colosed -GVAR(toggleSelectionIconEH) = [QEGVAR(dialog,close), { - if !(isNil QGVAR(drawSavedSelectionIcons)) then { - removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; - GVAR(drawSavedSelectionIcons) = nil; - }; - if !(isNil QGVAR(toggleSelectionIconEH)) then { - [QEGVAR(dialog,close), GVAR(toggleSelectionIconEH)] call CBA_fnc_removeEventHandler; - GVAR(toggleSelectionIconEH) = nil; - }; +GVAR(endSelectionHandle) = [QEGVAR(dialog,close), { + [false] call FUNC(toggleSelectionPreview); + [QEGVAR(dialog,close), GVAR(endSelectionHandle)] call CBA_fnc_removeEventHandler; + GVAR(endSelectionHandle) = nil; }] call CBA_fnc_addEventHandler; -GVAR(savedSelection) +GVAR(lastSelection) diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf index 3b6a192f6..244d60a20 100644 --- a/addons/editor/functions/fnc_toggleSelectionPreview.sqf +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -18,12 +18,12 @@ params [["_turnOn", true, [true]]]; if (_turnOn) then { - if (isNil QGVAR(toggleSelectionIconEH)) then { - GVAR(toggleSelectionIconEH) = [{ + if (isNil QGVAR(selectionIconHandler)) then { + GVAR(selectionIconHandler) = [{ // Show preview if mouse is not over an entity if (curatorMouseOver isEqualTo [""]) then { - if (isNil QGVAR(drawSavedSelectionIcons)) then { - GVAR(drawSavedSelectionIcons) = addMissionEventHandler ["Draw3D", { + if (isNil QGVAR(drawSelectioIcons)) then { + GVAR(drawSelectioIcons) = addMissionEventHandler ["Draw3D", { { drawIcon3D [ GVAR(lastModuleIcon), @@ -33,20 +33,20 @@ if (_turnOn) then { }]; }; } else { - if !(isNil QGVAR(drawSavedSelectionIcons)) then { - removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; - GVAR(drawSavedSelectionIcons) = nil + if !(isNil QGVAR(drawSelectioIcons)) then { + removeMissionEventHandler ["Draw3D", GVAR(drawSelectioIcons)]; + GVAR(drawSelectioIcons) = nil }; }; }, 0] call CBA_fnc_addPerFrameHandler; }; } else { - if !(isNil QGVAR(toggleSelectionIconEH)) then { - [GVAR(toggleSelectionIconEH)] call CBA_fnc_removePerFrameHandler; - GVAR(toggleSelectionIconEH) = nil; + if !(isNil QGVAR(selectionIconHandler)) then { + [GVAR(selectionIconHandler)] call CBA_fnc_removePerFrameHandler; + GVAR(selectionIconHandler) = nil; }; - if !(isNil QGVAR(drawSavedSelectionIcons)) then { - removeMissionEventHandler ["Draw3D", GVAR(drawSavedSelectionIcons)]; - GVAR(drawSavedSelectionIcons) = nil; + if !(isNil QGVAR(drawSelectioIcons)) then { + removeMissionEventHandler ["Draw3D", GVAR(drawSelectioIcons)]; + GVAR(drawSelectioIcons) = nil; }; }; diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 4e2fef5c7..36a417ddb 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -44,7 +44,7 @@ private _clientTypes = allPlayers; private _clientNames = allPlayers apply {name _x}; _clientTypes = [0] + _clientTypes; _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; -systemChat str _entities; + [LSTRING(ModuleTransferOwnership), [ [ "TOOLBOX", From 46a32a3a00105d36d7f2ecd8bbe8790d723a87eb Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 10 Jan 2021 22:35:47 +0100 Subject: [PATCH 09/31] Add default value for icon cache --- addons/editor/XEH_preInit.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/editor/XEH_preInit.sqf b/addons/editor/XEH_preInit.sqf index b1c61fc21..59e6756e0 100644 --- a/addons/editor/XEH_preInit.sqf +++ b/addons/editor/XEH_preInit.sqf @@ -11,6 +11,8 @@ PREP_RECOMPILE_END; GVAR(lastSelection) = []; GVAR(savedSelection) = []; +GVAR(lastModuleIcon) = ""; +GVAR(savedModuleIcon) = ""; GVAR(colour) = ["IGUI", "TEXT_RGB"] call BIS_fnc_displayColorGet; GVAR(clipboard) = []; GVAR(includeCrew) = true; From bb413314c6c72ac1b3dd6651980c8aeec51e41a8 Mon Sep 17 00:00:00 2001 From: Kex Date: Mon, 11 Jan 2021 02:51:06 +0100 Subject: [PATCH 10/31] Naked unit bug fix --- addons/common/XEH_postInit.sqf | 70 +++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 409e193a5..eb59c5f88 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -307,6 +307,35 @@ [QGVAR(setTurretAmmo), LINKFUNC(setTurretAmmo)] call CBA_fnc_addEventHandler; [QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler; +// Subevent of zen_common_transferOwnership +// Back up loadouts +[QGVAR(transferOwnership_backupLoadout), { + params ["_units", "_groups", "_newOwner"]; + _loadouts = _units apply {getUnitLoadout _x}; + [QGVAR(transferOwnership_transfer), [_units, _loadouts, _groups, _newOwner]] call CBA_fnc_serverEvent; +}] call CBA_fnc_addEventHandler; + +// Subevent of zen_common_transferOwnership +// Restore loadouts lost by the naked unit bug +[QGVAR(transferOwnership_restoreLoadout), { + params ["_units", "_loadouts"]; + // Wait until units are transferred + [{ + params ["_units"]; + _units findIf {!local _x && alive _x} == -1 + }, { + params ["_units", "_loadouts"]; + { + if (uniform _x isEqualTo "") then { + private _loadout = _loadouts select _forEachIndex; + if !(_loadout isEqualTo []) then { + _x setUnitLoadout _loadout; + }; + }; + } forEach _units; + }, [_units, _loadouts]] call CBA_fnc_waitUntilAndExecute; +}] call CBA_fnc_addEventHandler; + if (isServer) then { [QGVAR(hideObjectGlobal), { params ["_object", "_hide"]; @@ -318,29 +347,52 @@ if (isServer) then { _object enableSimulationGlobal _enable; }] call CBA_fnc_addEventHandler; + // Subevent of zen_common_transferOwnership + [QGVAR(transferOwnership_transfer), { + params ["_units", "_loadouts", "_groups", "_newOwner"]; + {_x setGroupOwner _newOwner} forEach _groups; + [QGVAR(transferOwnership_restoreLoadout), [_units, _loadouts], _newOwner] call CBA_fnc_ownerEvent; + }] call CBA_fnc_addEventHandler; + [QGVAR(transferOwnership), { params ["_entities", "_target"]; + if (_entities isEqualTo []) exitWith {}; if (!(_entities isEqualType [])) then { _entities = [_entities]; }; - private _clientID = 0; - if (_target isEqualType 0) then { - _clientID = _target; + private _newOwner = switch (typeName _target) do { + case "SCALAR": {_target}; + case "GROUP": {groupOwner _target}; + case "OBJECT": {owner _target}; + default {0}; }; - if (_target isEqualType objNull) then { - _clientID = owner _target; + private _entity = _entities select 0; + private _oldOwner = switch (typeName _entity) do { + case "GROUP": {groupOwner _entity}; + case "OBJECT": {owner _entity}; + default {0}; }; + if (_newOwner isEqualTo _oldOwner) exitWith {}; + + // Categorize entities + private _units = []; + private _groups = []; { if (_x isEqualType grpNull) then { - _x setGroupOwner _clientID; + _groups pushBackUnique _x; + {_units pushBackUnique _x} forEach units _x; } else { - if (group _x == grpNull) then { - group _x setGroupOwner _clientID; + if !(isNull group _x) then { + _groups pushBackUnique group _x; + _units pushBackUnique _x; } else { - _x setOwner _clientID; + // Objects can already be transferred + _x setOwner _newOwner; }; }; } forEach _entities; + + [QGVAR(transferOwnership_backupLoadout), [_units, _groups, _newOwner], _oldOwner] call CBA_fnc_ownerEvent; }] call CBA_fnc_addEventHandler; [QGVAR(setFriend), { From c7d75d7ba40e908ed131733930015629080851eb Mon Sep 17 00:00:00 2001 From: Kex Date: Mon, 11 Jan 2021 18:46:11 +0100 Subject: [PATCH 11/31] Revert "Naked unit bug fix" This reverts commit bb413314c6c72ac1b3dd6651980c8aeec51e41a8. --- addons/common/XEH_postInit.sqf | 70 +++++----------------------------- 1 file changed, 9 insertions(+), 61 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index eb59c5f88..409e193a5 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -307,35 +307,6 @@ [QGVAR(setTurretAmmo), LINKFUNC(setTurretAmmo)] call CBA_fnc_addEventHandler; [QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler; -// Subevent of zen_common_transferOwnership -// Back up loadouts -[QGVAR(transferOwnership_backupLoadout), { - params ["_units", "_groups", "_newOwner"]; - _loadouts = _units apply {getUnitLoadout _x}; - [QGVAR(transferOwnership_transfer), [_units, _loadouts, _groups, _newOwner]] call CBA_fnc_serverEvent; -}] call CBA_fnc_addEventHandler; - -// Subevent of zen_common_transferOwnership -// Restore loadouts lost by the naked unit bug -[QGVAR(transferOwnership_restoreLoadout), { - params ["_units", "_loadouts"]; - // Wait until units are transferred - [{ - params ["_units"]; - _units findIf {!local _x && alive _x} == -1 - }, { - params ["_units", "_loadouts"]; - { - if (uniform _x isEqualTo "") then { - private _loadout = _loadouts select _forEachIndex; - if !(_loadout isEqualTo []) then { - _x setUnitLoadout _loadout; - }; - }; - } forEach _units; - }, [_units, _loadouts]] call CBA_fnc_waitUntilAndExecute; -}] call CBA_fnc_addEventHandler; - if (isServer) then { [QGVAR(hideObjectGlobal), { params ["_object", "_hide"]; @@ -347,52 +318,29 @@ if (isServer) then { _object enableSimulationGlobal _enable; }] call CBA_fnc_addEventHandler; - // Subevent of zen_common_transferOwnership - [QGVAR(transferOwnership_transfer), { - params ["_units", "_loadouts", "_groups", "_newOwner"]; - {_x setGroupOwner _newOwner} forEach _groups; - [QGVAR(transferOwnership_restoreLoadout), [_units, _loadouts], _newOwner] call CBA_fnc_ownerEvent; - }] call CBA_fnc_addEventHandler; - [QGVAR(transferOwnership), { params ["_entities", "_target"]; - if (_entities isEqualTo []) exitWith {}; if (!(_entities isEqualType [])) then { _entities = [_entities]; }; - private _newOwner = switch (typeName _target) do { - case "SCALAR": {_target}; - case "GROUP": {groupOwner _target}; - case "OBJECT": {owner _target}; - default {0}; + private _clientID = 0; + if (_target isEqualType 0) then { + _clientID = _target; }; - private _entity = _entities select 0; - private _oldOwner = switch (typeName _entity) do { - case "GROUP": {groupOwner _entity}; - case "OBJECT": {owner _entity}; - default {0}; + if (_target isEqualType objNull) then { + _clientID = owner _target; }; - if (_newOwner isEqualTo _oldOwner) exitWith {}; - - // Categorize entities - private _units = []; - private _groups = []; { if (_x isEqualType grpNull) then { - _groups pushBackUnique _x; - {_units pushBackUnique _x} forEach units _x; + _x setGroupOwner _clientID; } else { - if !(isNull group _x) then { - _groups pushBackUnique group _x; - _units pushBackUnique _x; + if (group _x == grpNull) then { + group _x setGroupOwner _clientID; } else { - // Objects can already be transferred - _x setOwner _newOwner; + _x setOwner _clientID; }; }; } forEach _entities; - - [QGVAR(transferOwnership_backupLoadout), [_units, _groups, _newOwner], _oldOwner] call CBA_fnc_ownerEvent; }] call CBA_fnc_addEventHandler; [QGVAR(setFriend), { From 2a0706556a937540e64b3885ccec8bbe49c1cab7 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Mon, 11 Jan 2021 19:51:16 -0500 Subject: [PATCH 12/31] add toolbox for hc scripts flags --- .../functions/fnc_moduleTransferOwnership.sqf | 22 ++++++++++++++++++- addons/modules/stringtable.xml | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 0ca8f39b6..6dfc82720 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -60,10 +60,20 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; "COMBO", LSTRING(ModuleTransferOwnership_Client), [_clientTypes, _clientNames, 0] + ], + [ + "TOOLBOX", + LSTRING(ModuleTransferOwnership_HCScripts), + [_defaultTarget, 1, 3, [ + ELSTRING(common,Enabled), + ELSTRING(common,Disabled), + ELSTRING(common,Unchanged) + ]], + true ] ], { params ["_values", "_args"]; - _values params ["_target", "_player"]; + _values params ["_target", "_player", "_HCState"]; _args params ["_entities", "_mehID"]; // Stop drawing icons @@ -81,6 +91,16 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; _player }; }; + + // set headless client script flags + if (_HCState < 2) then { + if (acex_headless) then { + { + _x setVariable ["ace_headless_blacklist", [false, true] select _HCState, true]; + } forEach _entities; + }; + }; + [QEGVAR(common,transferOwnership), [_entities, _targetID]] call CBA_fnc_serverEvent; }, { params ["", "_args"]; diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index fed0127e2..2f24a018b 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -599,6 +599,9 @@ Server + + HC Scripts + Bind Variable To Object Привязать переменную к объекту From 84a88726471096375e4e73b93a6f90ebb8f7f838 Mon Sep 17 00:00:00 2001 From: Kex Date: Wed, 13 Jan 2021 02:06:58 +0100 Subject: [PATCH 13/31] Update stringtable.xml --- addons/modules/stringtable.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 2f24a018b..34a31541c 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -592,15 +592,28 @@ Transfer Ownership + Transférer la propriété + Transferir propiedad + Передать владение + Besitztum verschieben + 所有権を移行 + 转让所有权 + 轉讓所有權 Client + Client + Klient Server + Serveur + Server HC Scripts + Script pour HC + HC Skript Bind Variable To Object From 30ad1c6613423db6564ed9250cffd58bb5a19083 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Tue, 12 Jan 2021 22:58:07 -0500 Subject: [PATCH 14/31] check CfgPatches instead of `acex_headless` --- addons/modules/functions/fnc_moduleTransferOwnership.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 6dfc82720..7ab2c54e8 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -94,7 +94,7 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; // set headless client script flags if (_HCState < 2) then { - if (acex_headless) then { + if (isClass (configFile >> "CfgPatches" >> "acex_headless")) then { { _x setVariable ["ace_headless_blacklist", [false, true] select _HCState, true]; } forEach _entities; From 853b6967a1d65493c6ae095253069230a413e4dd Mon Sep 17 00:00:00 2001 From: Kex Date: Wed, 13 Jan 2021 17:32:00 +0100 Subject: [PATCH 15/31] Update stringtable.xml --- addons/modules/stringtable.xml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 34a31541c..b47817413 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -603,17 +603,17 @@ Client Client - Klient + Klient Server Serveur - Server + Server HC Scripts Script pour HC - HC Skript + HC Skript Bind Variable To Object @@ -2234,9 +2234,13 @@ Selection cannot include players + Auswahl kann keine Spieler beinhalten + La sélection ne permet pas de joueurs Module only available in multiplayer + Modul nur im Mehrspieler-Modus verfügbar + Module est seulement disponible dans la mode multijoueur Place on a unit From ccf1ff6e63af79c587b9dc727ed88a32e43ccc25 Mon Sep 17 00:00:00 2001 From: Kex Date: Wed, 13 Jan 2021 17:33:17 +0100 Subject: [PATCH 16/31] Update stringtable.xml --- addons/modules/stringtable.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index b47817413..7150d7779 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -2234,13 +2234,13 @@ Selection cannot include players - Auswahl kann keine Spieler beinhalten La sélection ne permet pas de joueurs + Auswahl kann keine Spieler beinhalten Module only available in multiplayer - Modul nur im Mehrspieler-Modus verfügbar Module est seulement disponible dans la mode multijoueur + Modul nur im Mehrspieler-Modus verfügbar Place on a unit From b535ee483d45284dd512f21fa58e690302ae7285 Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Wed, 13 Jan 2021 21:30:57 -0500 Subject: [PATCH 17/31] fix condition for objects --- addons/common/XEH_postInit.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 409e193a5..e39145c5f 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -335,9 +335,9 @@ if (isServer) then { _x setGroupOwner _clientID; } else { if (group _x == grpNull) then { - group _x setGroupOwner _clientID; - } else { _x setOwner _clientID; + } else { + group _x setGroupOwner _clientID; }; }; } forEach _entities; From 5c49b2992fd3f0b1595f4b7b45530cabb6d779cb Mon Sep 17 00:00:00 2001 From: Kex Date: Thu, 14 Jan 2021 19:17:37 +0100 Subject: [PATCH 18/31] Switch to rendering time scope --- addons/editor/functions/fnc_toggleSelectionPreview.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf index 244d60a20..0dee008b5 100644 --- a/addons/editor/functions/fnc_toggleSelectionPreview.sqf +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -27,7 +27,7 @@ if (_turnOn) then { { drawIcon3D [ GVAR(lastModuleIcon), - GVAR(colour), getPos _x, 1, 1, 0 + GVAR(colour), getPosVisual _x, 1, 1, 0 ]; } forEach (GVAR(lastSelection) select 0); }]; From 212472564baa5685781e08299e3b578723acdf97 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:14:42 +0100 Subject: [PATCH 19/31] Use a single handler for selection icons --- .../functions/fnc_toggleSelectionPreview.sqf | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf index 0dee008b5..a5dc9e45b 100644 --- a/addons/editor/functions/fnc_toggleSelectionPreview.sqf +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -19,34 +19,19 @@ params [["_turnOn", true, [true]]]; if (_turnOn) then { if (isNil QGVAR(selectionIconHandler)) then { - GVAR(selectionIconHandler) = [{ - // Show preview if mouse is not over an entity - if (curatorMouseOver isEqualTo [""]) then { - if (isNil QGVAR(drawSelectioIcons)) then { - GVAR(drawSelectioIcons) = addMissionEventHandler ["Draw3D", { - { - drawIcon3D [ - GVAR(lastModuleIcon), - GVAR(colour), getPosVisual _x, 1, 1, 0 - ]; - } forEach (GVAR(lastSelection) select 0); - }]; - }; - } else { - if !(isNil QGVAR(drawSelectioIcons)) then { - removeMissionEventHandler ["Draw3D", GVAR(drawSelectioIcons)]; - GVAR(drawSelectioIcons) = nil - }; - }; - }, 0] call CBA_fnc_addPerFrameHandler; - }; + GVAR(selectionIconHandler) = addMissionEventHandler ["Draw3D", { + if (curatorMouseOver isEqualTo [""]) then { + { + drawIcon3D [ + GVAR(lastModuleIcon), + GVAR(colour), getPosVisual _x, 1, 1, 0 + ]; + } forEach (GVAR(lastSelection) select 0); + }; + }]; } else { if !(isNil QGVAR(selectionIconHandler)) then { [GVAR(selectionIconHandler)] call CBA_fnc_removePerFrameHandler; GVAR(selectionIconHandler) = nil; }; - if !(isNil QGVAR(drawSelectioIcons)) then { - removeMissionEventHandler ["Draw3D", GVAR(drawSelectioIcons)]; - GVAR(drawSelectioIcons) = nil; - }; }; From 46b755e760a14864afcf4140226456deaa8cdb0b Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:17:49 +0100 Subject: [PATCH 20/31] Fix syntax --- .../functions/fnc_toggleSelectionPreview.sqf | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf index a5dc9e45b..4f6e9c466 100644 --- a/addons/editor/functions/fnc_toggleSelectionPreview.sqf +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -19,16 +19,17 @@ params [["_turnOn", true, [true]]]; if (_turnOn) then { if (isNil QGVAR(selectionIconHandler)) then { - GVAR(selectionIconHandler) = addMissionEventHandler ["Draw3D", { - if (curatorMouseOver isEqualTo [""]) then { - { - drawIcon3D [ - GVAR(lastModuleIcon), - GVAR(colour), getPosVisual _x, 1, 1, 0 - ]; - } forEach (GVAR(lastSelection) select 0); - }; - }]; + GVAR(selectionIconHandler) = addMissionEventHandler ["Draw3D", { + if (curatorMouseOver isEqualTo [""]) then { + { + drawIcon3D [ + GVAR(lastModuleIcon), + GVAR(colour), getPosVisual _x, 1, 1, 0 + ]; + } forEach (GVAR(lastSelection) select 0); + }; + }]; + }; } else { if !(isNil QGVAR(selectionIconHandler)) then { [GVAR(selectionIconHandler)] call CBA_fnc_removePerFrameHandler; From d9d83089802267ad8ede72c0f3117269cea9d138 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:20:48 +0100 Subject: [PATCH 21/31] Remove _mehID --- .../functions/fnc_moduleTransferOwnership.sqf | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 7ab2c54e8..9ba5e80b5 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -74,12 +74,8 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; ], { params ["_values", "_args"]; _values params ["_target", "_player", "_HCState"]; - _args params ["_entities", "_mehID"]; + _args params ["_entities"]; - // Stop drawing icons - if (_mehID > 0) then { - removeMissionEventHandler ["Draw3D", _mehID]; - }; private _targetID = switch (_target) do { case (0): { 2 // Server @@ -102,12 +98,4 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; }; [QEGVAR(common,transferOwnership), [_entities, _targetID]] call CBA_fnc_serverEvent; -}, { - params ["", "_args"]; - _args params ["", "_mehID"]; - - // Stop drawing icons - if (_mehID > 0) then { - removeMissionEventHandler ["Draw3D", _mehID]; - }; -}, [_entities, _mehID]] call EFUNC(dialog,create); +}, {}, [_entities]] call EFUNC(dialog,create); From e6a09c9d6ff6dfaf754df6db6675b7ec0c6d0a6f Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:22:36 +0100 Subject: [PATCH 22/31] Single delete logic --- addons/modules/functions/fnc_moduleTransferOwnership.sqf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 9ba5e80b5..558580ed8 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -16,14 +16,12 @@ */ params ["_logic"]; +deleteVehicle _logic; if (!isMultiplayer) exitWith { [LSTRING(OnlyMultiplayer)] call EFUNC(common,showMessage); - deleteVehicle _logic; }; -deleteVehicle _logic; - private _entities = []; (call EFUNC(editor,getSelection)) params ["_objects", "_groups"]; { From 8feb8a7bfbf58ad655b7d7e39630c19e4209c5ae Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:33:13 +0100 Subject: [PATCH 23/31] Doc comment --- addons/editor/functions/fnc_handleSelectionChanged.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/editor/functions/fnc_handleSelectionChanged.sqf b/addons/editor/functions/fnc_handleSelectionChanged.sqf index 50a1686b3..ddcb944d8 100644 --- a/addons/editor/functions/fnc_handleSelectionChanged.sqf +++ b/addons/editor/functions/fnc_handleSelectionChanged.sqf @@ -5,7 +5,7 @@ * * Arguments: * 0: Curator - * 0: Entity: group, marker, object, or waypoint + * 0: Entity: group, marker, object, or waypoint * * Return Value: * Handled From 6b5755d35f3e88e847826b2b623b22fb570a4894 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 18:41:36 +0100 Subject: [PATCH 24/31] Remove correct event handler --- addons/editor/functions/fnc_toggleSelectionPreview.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/editor/functions/fnc_toggleSelectionPreview.sqf b/addons/editor/functions/fnc_toggleSelectionPreview.sqf index 4f6e9c466..1deea4cc8 100644 --- a/addons/editor/functions/fnc_toggleSelectionPreview.sqf +++ b/addons/editor/functions/fnc_toggleSelectionPreview.sqf @@ -32,7 +32,7 @@ if (_turnOn) then { }; } else { if !(isNil QGVAR(selectionIconHandler)) then { - [GVAR(selectionIconHandler)] call CBA_fnc_removePerFrameHandler; + removeMissionEventHandler ["Draw3D", GVAR(selectionIconHandler)]; GVAR(selectionIconHandler) = nil; }; }; From 98916d6530fcfe6d506fd0f42ceb2870c50c1629 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 20:06:57 +0100 Subject: [PATCH 25/31] Merge options --- .../functions/fnc_moduleTransferOwnership.sqf | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 558580ed8..4a7dbd290 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -33,31 +33,27 @@ private _entities = []; } forEach _objects; _entities append _groups; -if (_entities findIf {units _x findIf {isPlayer _x} > -1} > -1) exitWith { +if (_entities findIf {units _x findIf {isPlayer _x} > -1} != -1) exitWith { [LSTRING(SelectionCannotIncludePlayers)] call EFUNC(common,showMessage); }; -private _defaultTarget = !local (_entities select 0); -private _clientTypes = allPlayers; -private _clientNames = allPlayers apply {name _x}; -_clientTypes = [0] + _clientTypes; -_clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; +private _targets = [2, clientOwner]; +_targets append allPlayers; + +private _targetNames = [ + LSTRING(ModuleTransferOwnership_Server), + "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1" +]; +_targetNames append (allPlayers apply {name _x}); + +// Set default target to curator or server depending on current locality +private _defaultTarget = parseNumber !(local (_entities select 0)); [LSTRING(ModuleTransferOwnership), [ - [ - "TOOLBOX", - ELSTRING(common,Target), - [_defaultTarget, 1, 3, [ - LSTRING(ModuleTransferOwnership_Server), - "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1", - LSTRING(ModuleTransferOwnership_Client) - ]], - true - ], [ "COMBO", - LSTRING(ModuleTransferOwnership_Client), - [_clientTypes, _clientNames, 0] + ELSTRING(common,Target), + [_targets, _targetNames, _defaultTarget] ], [ "TOOLBOX", @@ -71,21 +67,9 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; ] ], { params ["_values", "_args"]; - _values params ["_target", "_player", "_HCState"]; + _values params ["_target", "_HCState"]; _args params ["_entities"]; - private _targetID = switch (_target) do { - case (0): { - 2 // Server - }; - case (1): { - clientOwner - }; - case (2): { - _player - }; - }; - // set headless client script flags if (_HCState < 2) then { if (isClass (configFile >> "CfgPatches" >> "acex_headless")) then { @@ -95,5 +79,5 @@ _clientNames = ["str_a3_om_common_definitions.incphone_44"] + _clientNames; }; }; - [QEGVAR(common,transferOwnership), [_entities, _targetID]] call CBA_fnc_serverEvent; + [QEGVAR(common,transferOwnership), [_entities, _target]] call CBA_fnc_serverEvent; }, {}, [_entities]] call EFUNC(dialog,create); From e10c311f101571d981796eb4cc44d44452723fb1 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 20:19:58 +0100 Subject: [PATCH 26/31] Sort player targets by name --- .../modules/functions/fnc_moduleTransferOwnership.sqf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 4a7dbd290..8b0302478 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -38,13 +38,19 @@ if (_entities findIf {units _x findIf {isPlayer _x} > -1} != -1) exitWith { }; private _targets = [2, clientOwner]; -_targets append allPlayers; private _targetNames = [ LSTRING(ModuleTransferOwnership_Server), "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1" ]; -_targetNames append (allPlayers apply {name _x}); + +private _players = allPlayers apply {[name _x, _x]}; +_players sort true; +{ + _x params ["_name", "_entity"]; + _targetNames pushBack _name; + _targets pushBack _entity; +} forEach _players; // Set default target to curator or server depending on current locality private _defaultTarget = parseNumber !(local (_entities select 0)); From f6a50550d801480b99a88b29d8e584aa3dc664bf Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 24 Jan 2021 00:56:01 +0100 Subject: [PATCH 27/31] Prioritize HCs --- .../functions/fnc_moduleTransferOwnership.sqf | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 8b0302478..98e08e8b6 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -44,13 +44,22 @@ private _targetNames = [ "str_a3_cfgvehicles_module_f_moduledescription_curator_f_1" ]; -private _players = allPlayers apply {[name _x, _x]}; +private _HCs = []; +private _players = []; +{ + if (_x isKindOf "HeadlessClient_F") then { + _HCs pushBack [name _x, _x]; + } else { + _players pushBack [name _x, _x]; + }; +} forEach allPlayers; +_HCs sort true; _players sort true; { _x params ["_name", "_entity"]; _targetNames pushBack _name; _targets pushBack _entity; -} forEach _players; +} forEach (_HCs + _players); // Set default target to curator or server depending on current locality private _defaultTarget = parseNumber !(local (_entities select 0)); From e6fe9bbbb969a41b850fa9e67c3fcd58b50e1f3c Mon Sep 17 00:00:00 2001 From: ampersand38 Date: Mon, 25 Jan 2021 14:44:14 -0500 Subject: [PATCH 28/31] Change default values Target: if remote then curator else if HCs then HC else server HC scripts: if default going to HC then enabled, else disabled --- .../functions/fnc_moduleTransferOwnership.sqf | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 98e08e8b6..dc740d83c 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -61,22 +61,30 @@ _players sort true; _targets pushBack _entity; } forEach (_HCs + _players); -// Set default target to curator or server depending on current locality -private _defaultTarget = parseNumber !(local (_entities select 0)); +// Set default target to curator, server, or HC depending on current locality +private _defaultTarget = if (local (_entities select 0)) then { + if (_HCs isEqualTo []) then { + 0 + } else { + 2 + }; +} else { + 1 +}; [LSTRING(ModuleTransferOwnership), [ [ "COMBO", ELSTRING(common,Target), - [_targets, _targetNames, _defaultTarget] + [_targets, _targetNames, _defaultTarget], + true ], [ "TOOLBOX", LSTRING(ModuleTransferOwnership_HCScripts), - [_defaultTarget, 1, 3, [ - ELSTRING(common,Enabled), + [parseNumber (_defaultTarget == 2), 1, 2, [ ELSTRING(common,Disabled), - ELSTRING(common,Unchanged) + ELSTRING(common,Enabled) ]], true ] From 7d0f7553a2b301c45ab96be0e6d41da8f97a2f71 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 10:51:20 -0500 Subject: [PATCH 29/31] Update addons/modules/functions/fnc_moduleTransferOwnership.sqf Co-authored-by: Ralfs Garkaklis --- addons/modules/functions/fnc_moduleTransferOwnership.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index dc740d83c..204c507c1 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -23,7 +23,7 @@ if (!isMultiplayer) exitWith { }; private _entities = []; -(call EFUNC(editor,getSelection)) params ["_objects", "_groups"]; +call EFUNC(editor,getSelection) params ["_objects", "_groups"]; { if (isNull group _x) then { _entities pushBack _x; From 7e3f1d1f6d63339f847feb171df5c4fb89a86bd0 Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 11:54:15 -0500 Subject: [PATCH 30/31] use select --- .../functions/fnc_moduleTransferOwnership.sqf | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 204c507c1..33f85a278 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -62,15 +62,10 @@ _players sort true; } forEach (_HCs + _players); // Set default target to curator, server, or HC depending on current locality -private _defaultTarget = if (local (_entities select 0)) then { - if (_HCs isEqualTo []) then { - 0 - } else { - 2 - }; -} else { - 1 -}; +private _defaultTarget = [ + 1, + [2, 0] select (_HCs isEqualTo []) +] select (local (_entities select 0)); [LSTRING(ModuleTransferOwnership), [ [ From a1696ce76d27f4786eef90377b6335e092b3c49c Mon Sep 17 00:00:00 2001 From: Steve Zhao Date: Thu, 4 Mar 2021 11:54:28 -0500 Subject: [PATCH 31/31] Tooltip --- addons/modules/functions/fnc_moduleTransferOwnership.sqf | 2 +- addons/modules/stringtable.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/modules/functions/fnc_moduleTransferOwnership.sqf b/addons/modules/functions/fnc_moduleTransferOwnership.sqf index 33f85a278..f7a63ee11 100644 --- a/addons/modules/functions/fnc_moduleTransferOwnership.sqf +++ b/addons/modules/functions/fnc_moduleTransferOwnership.sqf @@ -76,7 +76,7 @@ private _defaultTarget = [ ], [ "TOOLBOX", - LSTRING(ModuleTransferOwnership_HCScripts), + [LSTRING(ModuleTransferOwnership_HCScripts), LSTRING(ModuleTransferOwnership_HCScripts_Description)], [parseNumber (_defaultTarget == 2), 1, 2, [ ELSTRING(common,Disabled), ELSTRING(common,Enabled) diff --git a/addons/modules/stringtable.xml b/addons/modules/stringtable.xml index 421454bbf..29a49da5a 100644 --- a/addons/modules/stringtable.xml +++ b/addons/modules/stringtable.xml @@ -615,6 +615,9 @@ Script pour HC HC Skript + + Flag the entity to for Headless Client transfer/balancing scripts such as ACEX + Bind Variable To Object Привязать переменную к объекту