diff --git a/TO_MERGE/agm/SafeMode/clientInit.sqf b/TO_MERGE/agm/SafeMode/clientInit.sqf
deleted file mode 100644
index 22440928b8..0000000000
--- a/TO_MERGE/agm/SafeMode/clientInit.sqf
+++ /dev/null
@@ -1,5 +0,0 @@
-
-// by commy2
-
-//["Soldier", {_player = AGM_player; if (currentWeapon _player in (_player getVariable ["AGM_SafeMode_safedWeapons", []])) then {[false] call AGM_SafeMode_setSafeModeVisual}] call AGM_Core_fnc_addInfoDisplayEventHandler;
- //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier"
\ No newline at end of file
diff --git a/TO_MERGE/agm/SafeMode/config.cpp b/TO_MERGE/agm/SafeMode/config.cpp
deleted file mode 100644
index c8360c341d..0000000000
--- a/TO_MERGE/agm/SafeMode/config.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// PATCH CONFIG
-class CfgPatches {
- class AGM_SafeMode {
- units[] = {};
- weapons[] = {};
- requiredVersion = 0.60;
- requiredAddons[] = {AGM_Core};
- version = "0.95";
- versionStr = "0.95";
- versionAr[] = {0,95,0};
- author[] = {"commy2"};
- authorUrl = "https://github.com/commy2/";
- };
-};
-
-class CfgFunctions {
- class AGM_SafeMode {
- class AGM_SafeMode {
- file = "AGM_SafeMode\functions";
- class firstMode;
- class lockSafety;
- class playChangeFiremodeSound;
- class setSafeModeVisual;
- class unlockSafety;
- };
- };
-};
-
-class Extended_PostInit_EventHandlers {
- class AGM_SafeMode {
- clientInit = "call compile preprocessFileLineNumbers '\AGM_SafeMode\clientInit.sqf';";
- };
-};
-
-class AGM_Core_Default_Keys {
- class safeWeapon {
- displayName = "$STR_AGM_SafeMode_SafeMode";
- condition = "[_player] call AGM_Core_fnc_canUseWeapon";
- statement = "[_player, currentWeapon _player, currentMuzzle _player] call AGM_SafeMode_fnc_lockSafety";
- exceptions[] = {"AGM_Interaction_isNotEscorting"};
- key = 41;
- shift = 0;
- control = 1;
- alt = 0;
- };
-};
diff --git a/TO_MERGE/agm/SafeMode/functions/fn_lockSafety.sqf b/TO_MERGE/agm/SafeMode/functions/fn_lockSafety.sqf
deleted file mode 100644
index cca54b51ab..0000000000
--- a/TO_MERGE/agm/SafeMode/functions/fn_lockSafety.sqf
+++ /dev/null
@@ -1,65 +0,0 @@
-// by commy2
-
-private ["_unit", "_weapon", "_muzzle", "_safedWeapons"];
-
-_unit = _this select 0;
-_weapon = _this select 1;
-_muzzle = _this select 2;
-
-// don't immediately switch back
-if (inputAction "nextWeapon" > 0) exitWith {};
-
-_safedWeapons = _unit getVariable ["AGM_SafeMode_safedWeapons", []];
-
-if (_weapon in _safedWeapons) exitWith {
- _this call AGM_SafeMode_fnc_unlockSafety;
-};
-
-_safedWeapons pushBack _weapon;
-
-_unit setVariable ["AGM_SafeMode_safedWeapons", _safedWeapons];
-
-if (_unit getVariable ["AGM_SafeWeapon_actionID", -1] == -1) then {
- private ["_condition", "_statement", "_id"];
-
- _condition = {
- if (
- [_this select 1] call AGM_Core_fnc_canUseWeapon
- && {
- if (currentMuzzle (_this select 1) in ((_this select 1) getVariable ["AGM_SafeMode_safedWeapons", []])) then {
- if (inputAction "nextWeapon" > 0) exitWith {
- [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call AGM_SafeMode_fnc_unlockSafety;
- false
- };
- true
- } else {false}
- }
- ) then {
- // player hud
- [false] call AGM_SafeMode_fnc_setSafeModeVisual;
- true
- } else {
- // player hud
- [true] call AGM_SafeMode_fnc_setSafeModeVisual;
- false
- }
- };
-
- _statement = {
- [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call AGM_SafeMode_fnc_unlockSafety;
- };
-
- //_id = [_unit, format ["%1", localize "STR_AGM_SafeMode_TakeOffSafety"], "DefaultAction", _condition, {}, {true}, _statement, 10] call AGM_Core_fnc_addActionMenuEventHandler;
- _id = [_unit, "DefaultAction", _condition, {}] call AGM_Core_fnc_addActionEventHandler;
-
- _unit setVariable ["AGM_SafeWeapon_actionID", _id];
-};
-
-_unit selectWeapon _muzzle;//_weapon
-
-// play fire mode selector sound
-[_unit, _weapon, _muzzle] call AGM_SafeMode_fnc_playChangeFiremodeSound;
-
-private "_picture";
-_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
-[localize "STR_AGM_SafeMode_PutOnSafety", _picture] call AGM_Core_fnc_displayTextPicture;
diff --git a/addons/safemode/$PBOPREFIX$ b/addons/safemode/$PBOPREFIX$
new file mode 100644
index 0000000000..361237305d
--- /dev/null
+++ b/addons/safemode/$PBOPREFIX$
@@ -0,0 +1 @@
+z\ace\addons\safemode
\ No newline at end of file
diff --git a/addons/safemode/CfgEventHandlers.hpp b/addons/safemode/CfgEventHandlers.hpp
new file mode 100644
index 0000000000..eefe61652b
--- /dev/null
+++ b/addons/safemode/CfgEventHandlers.hpp
@@ -0,0 +1,12 @@
+
+class Extended_PreInit_EventHandlers {
+ class ADDON {
+ init = QUOTE(call COMPILE_FILE(XEH_preInit) );
+ };
+};
+
+class Extended_PostInit_EventHandlers {
+ class ADDON {
+ clientInit = QUOTE( call COMPILE_FILE(XEH_postInit) );
+ };
+};
diff --git a/addons/safemode/XEH_postInit.sqf b/addons/safemode/XEH_postInit.sqf
new file mode 100644
index 0000000000..94e6b789bd
--- /dev/null
+++ b/addons/safemode/XEH_postInit.sqf
@@ -0,0 +1,5 @@
+
+// by commy2
+
+//["Soldier", {_player = ACE_player; if (currentWeapon _player in (_player getVariable [QGVAR(safedWeapons), []])) then {[false] call FUNC(setSafeModeVisual)}] call EFUNC(common,addInfoDisplayEventHandler);
+ //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier"
diff --git a/addons/safemode/XEH_preInit.sqf b/addons/safemode/XEH_preInit.sqf
new file mode 100644
index 0000000000..bc80c4269d
--- /dev/null
+++ b/addons/safemode/XEH_preInit.sqf
@@ -0,0 +1,7 @@
+#include "script_component.hpp"
+
+PREP(firstMode);
+PREP(lockSafety);
+PREP(playChangeFiremodeSound);
+PREP(setSafeModeVisual);
+PREP(unlockSafety);
diff --git a/addons/safemode/config.cpp b/addons/safemode/config.cpp
new file mode 100644
index 0000000000..d61a386e20
--- /dev/null
+++ b/addons/safemode/config.cpp
@@ -0,0 +1,28 @@
+#include "script_component.hpp"
+
+class CfgPatches {
+ class ADDON {
+ units[] = {};
+ weapons[] = {};
+ requiredVersion = REQUIRED_VERSION;
+ requiredAddons[] = {"ace_common"};
+ author[] = {"commy2"};
+ authorUrl = "https://github.com/commy2/";
+ VERSION_CONFIG;
+ };
+};
+
+#include "CfgEventHandlers.hpp"
+
+class ACE_Default_Keys {
+ class safeWeapon {
+ displayName = "$STR_ACE_SafeMode_SafeMode";
+ condition = QUOTE([_player] call EFUNC(common,canUseWeapon));
+ statement = QUOTE([ARR_3(_player, currentWeapon _player, currentMuzzle _player)] call FUNC(lockSafety));
+ exceptions[] = {"ACE_interaction_isNotEscorting"};
+ key = 41;
+ shift = 0;
+ control = 1;
+ alt = 0;
+ };
+};
diff --git a/TO_MERGE/agm/SafeMode/functions/fn_firstMode.sqf b/addons/safemode/functions/fnc_firstMode.sqf
similarity index 62%
rename from TO_MERGE/agm/SafeMode/functions/fn_firstMode.sqf
rename to addons/safemode/functions/fnc_firstMode.sqf
index 9e5644da15..821090dd32 100644
--- a/TO_MERGE/agm/SafeMode/functions/fn_firstMode.sqf
+++ b/addons/safemode/functions/fnc_firstMode.sqf
@@ -1,9 +1,9 @@
// by commy2
+#include "script_component.hpp"
-private ["_weapon", "_mode"];
-
-_weapon = _this select 0;
+EXPLODE_1_PVT(_this,_weapon);
+private ["_mode"];
_mode = getArray (configFile >> "CfgWeapons" >> _weapon >> "modes") select 0;
[_mode, _weapon] select (_mode == "this")
diff --git a/addons/safemode/functions/fnc_lockSafety.sqf b/addons/safemode/functions/fnc_lockSafety.sqf
new file mode 100644
index 0000000000..0e365fc221
--- /dev/null
+++ b/addons/safemode/functions/fnc_lockSafety.sqf
@@ -0,0 +1,63 @@
+// by commy2
+#include "script_component.hpp"
+
+EXPLODE_3_PVT(_this,_unit,_weapon,_muzzle);
+
+// don't immediately switch back
+if (inputAction "nextWeapon" > 0) exitWith {};
+
+private ["_safedWeapons"];
+_safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
+
+if (_weapon in _safedWeapons) exitWith {
+ _this call FUNC(unlockSafety);
+};
+
+_safedWeapons pushBack _weapon;
+
+_unit setVariable [QGVAR(safedWeapons), _safedWeapons];
+
+if (_unit getVariable [QGVAR(actionID), -1] == -1) then {
+ private ["_condition", "_statement", "_id"];
+
+ _condition = {
+ if (
+ [_this select 1] call EFUNC(common,canUseWeapon)
+ && {
+ if (currentMuzzle (_this select 1) in ((_this select 1) getVariable [QGVAR(safedWeapons), []])) then {
+ if (inputAction "nextWeapon" > 0) exitWith {
+ [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety);
+ false
+ };
+ true
+ } else {false}
+ }
+ ) then {
+ // player hud
+ [false] call FUNC(setSafeModeVisual);
+ true
+ } else {
+ // player hud
+ [true] call FUNC(setSafeModeVisual);
+ false
+ }
+ };
+
+ _statement = {
+ [_this select 1, currentWeapon (_this select 1), currentMuzzle (_this select 1)] call FUNC(unlockSafety);
+ };
+
+ //_id = [_unit, format ["%1", localize "STR_ACE_SafeMode_TakeOffSafety"], "DefaultAction", _condition, {}, {true}, _statement, 10] call EFUNC(common,addActionMenuEventHandler);
+ _id = [_unit, "DefaultAction", _condition, {}] call EFUNC(common,addActionEventHandler);
+
+ _unit setVariable [QGVAR(actionID), _id];
+};
+
+_unit selectWeapon _muzzle;//_weapon
+
+// play fire mode selector sound
+[_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
+
+private "_picture";
+_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
+[localize "STR_ACE_SafeMode_PutOnSafety", _picture] call EFUNC(common,displayTextPicture);
diff --git a/TO_MERGE/agm/SafeMode/functions/fn_playChangeFiremodeSound.sqf b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf
similarity index 87%
rename from TO_MERGE/agm/SafeMode/functions/fn_playChangeFiremodeSound.sqf
rename to addons/safemode/functions/fnc_playChangeFiremodeSound.sqf
index e8fecf4c13..c0b58604b9 100644
--- a/TO_MERGE/agm/SafeMode/functions/fn_playChangeFiremodeSound.sqf
+++ b/addons/safemode/functions/fnc_playChangeFiremodeSound.sqf
@@ -1,14 +1,13 @@
// by commy2
+#include "script_component.hpp"
-private ["_unit", "_weapon", "_sound"];
-
-_unit = _this select 0;
-_weapon = _this select 1;
+EXPLODE_2_PVT(_this,_unit,_weapon);
+private ["_sound"];
_sound = getArray (configFile >> "CfgWeapons" >> _weapon >> "changeFiremodeSound");
if (count _sound == 0) exitWith {
- playSound "AGM_Sound_Click";
+ playSound "ACE_Sound_Click";
};
// add file extension
@@ -27,7 +26,6 @@ if (count _sound < 3) then {_sound pushBack 1};
if (count _sound < 4) then {_sound pushBack 0};
private "_position";
-
_position = _unit modelToWorld (_unit selectionPosition "RightHand");
_position set [2, (_position select 2) + ((getPosASLW _unit select 2) - (getPosATL _unit select 2) max 0)];
diff --git a/TO_MERGE/agm/SafeMode/functions/fn_setSafeModeVisual.sqf b/addons/safemode/functions/fnc_setSafeModeVisual.sqf
similarity index 77%
rename from TO_MERGE/agm/SafeMode/functions/fn_setSafeModeVisual.sqf
rename to addons/safemode/functions/fnc_setSafeModeVisual.sqf
index 6ea156abe5..ae449e05e8 100644
--- a/TO_MERGE/agm/SafeMode/functions/fn_setSafeModeVisual.sqf
+++ b/addons/safemode/functions/fnc_setSafeModeVisual.sqf
@@ -1,11 +1,12 @@
// by commy2
+#include "script_component.hpp"
-private ["_show", "_control"];
-
-_show = _this select 0;
+EXPLODE_1_PVT(_this,_show);
disableSerialization;
-_control = (uiNamespace getVariable ["AGM_dlgSoldier", displayNull]) displayCtrl 187;
+
+private ["_control"];
+_control = (uiNamespace getVariable ["ACE_dlgSoldier", displayNull]) displayCtrl 187;
if (isNull _control) exitWith {};
diff --git a/TO_MERGE/agm/SafeMode/functions/fn_unlockSafety.sqf b/addons/safemode/functions/fnc_unlockSafety.sqf
similarity index 59%
rename from TO_MERGE/agm/SafeMode/functions/fn_unlockSafety.sqf
rename to addons/safemode/functions/fnc_unlockSafety.sqf
index 89a8cc0206..341cad182f 100644
--- a/TO_MERGE/agm/SafeMode/functions/fn_unlockSafety.sqf
+++ b/addons/safemode/functions/fnc_unlockSafety.sqf
@@ -1,25 +1,23 @@
// by commy2
+#include "script_component.hpp"
-private ["_unit", "_weapon", "_muzzle", "_safedWeapons"];
+EXPLODE_3_PVT(_this,_unit,_weapon,_muzzle);
-_unit = _this select 0;
-_weapon = _this select 1;
-_muzzle = _this select 2;
-
-_safedWeapons = _unit getVariable ["AGM_SafeMode_safedWeapons", []];
+private ["_safedWeapons"];
+_safedWeapons = _unit getVariable [QGVAR(safedWeapons), []];
if (_weapon in _safedWeapons) then {
_safedWeapons = _safedWeapons - [_weapon];
- _unit setVariable ["AGM_SafeMode_safedWeapons", _safedWeapons];
+ _unit setVariable [QGVAR(safedWeapons), _safedWeapons];
if (count _safedWeapons == 0) then {
private "_id";
- _id = _unit getVariable ["AGM_SafeWeapon_actionID", -1];
+ _id = _unit getVariable [QGVAR(actionID), -1];
- //[_unit, "DefaultAction", _id] call AGM_Core_fnc_removeActionMenuEventHandler;
- [_unit, "DefaultAction", _id] call AGM_Core_fnc_removeActionEventHandler;
- _unit setVariable ["AGM_SafeWeapon_actionID", -1];
+ //[_unit, "DefaultAction", _id] call EFUNC(common,removeActionMenuEventHandler);
+ [_unit, "DefaultAction", _id] call EFUNC(common,removeActionEventHandler);
+ _unit setVariable [QGVAR(actionID), -1];
};
};
@@ -53,12 +51,12 @@ if (inputAction "nextWeapon" > 0) then {
};
} else {
// play fire mode selector sound
- [_unit, _weapon, _muzzle] call AGM_SafeMode_fnc_playChangeFiremodeSound;
+ [_unit, _weapon, _muzzle] call FUNC(playChangeFiremodeSound);
};
// player hud
-[true] call AGM_SafeMode_fnc_setSafeModeVisual;
+[true] call FUNC(setSafeModeVisual);
private "_picture";
_picture = getText (configFile >> "CfgWeapons" >> _weapon >> "picture");
-[localize "STR_AGM_SafeMode_TookOffSafety", _picture] call AGM_Core_fnc_displayTextPicture;
+[localize "STR_ACE_SafeMode_TookOffSafety", _picture] call EFUNC(common,displayTextPicture);
diff --git a/addons/safemode/functions/script_component.hpp b/addons/safemode/functions/script_component.hpp
new file mode 100644
index 0000000000..a25fbfa4c7
--- /dev/null
+++ b/addons/safemode/functions/script_component.hpp
@@ -0,0 +1 @@
+#include "\z\ace\addons\safemode\script_component.hpp"
\ No newline at end of file
diff --git a/addons/safemode/script_component.hpp b/addons/safemode/script_component.hpp
new file mode 100644
index 0000000000..f76396afdf
--- /dev/null
+++ b/addons/safemode/script_component.hpp
@@ -0,0 +1,12 @@
+#define COMPONENT safemode
+#include "\z\ace\Addons\main\script_mod.hpp"
+
+#ifdef DEBUG_ENABLED_SAFEMODE
+ #define DEBUG_MODE_FULL
+#endif
+
+#ifdef DEBUG_SETTINGS_SAFEMODE
+ #define DEBUG_SETTINGS DEBUG_SETTINGS_SAFEMODE
+#endif
+
+#include "\z\ace\Addons\main\script_macros.hpp"
diff --git a/TO_MERGE/agm/SafeMode/stringtable.xml b/addons/safemode/stringtable.xml
similarity index 86%
rename from TO_MERGE/agm/SafeMode/stringtable.xml
rename to addons/safemode/stringtable.xml
index ff3415831d..9684babfdf 100644
--- a/TO_MERGE/agm/SafeMode/stringtable.xml
+++ b/addons/safemode/stringtable.xml
@@ -1,8 +1,8 @@
-
+
-
+
Safe Mode
Waffe sichern
Seguro puesto
@@ -11,7 +11,7 @@
Veszélytelenités
Предохранитель
-
+
Take off Safety
Waffe entsichern
Quitar seguro
@@ -20,7 +20,7 @@
Veszélyesités
Снять с предохранителя
-
+
Put on Safety
Waffe gesichert
Poner seguro
@@ -29,7 +29,7 @@
Veszélytelenitve
Поставить на предохранитель
-
+
Took off Safety
Waffe entsichert
Seguro quitado