From 14fa5d729fa71c98ea9583b6267b7adfbb3c8c47 Mon Sep 17 00:00:00 2001
From: Salluci <69561145+Salluci@users.noreply.github.com>
Date: Sun, 3 Oct 2021 11:12:14 -0300
Subject: [PATCH 1/4] add setting to repack equipped magazines
---
addons/magazinerepack/ACE_Settings.hpp | 18 ++--------
addons/magazinerepack/XEH_preInit.sqf | 2 ++
.../functions/fnc_canRepackMagazine.sqf | 2 +-
.../functions/fnc_getMagazineChildren.sqf | 2 +-
.../functions/fnc_startRepackingMagazine.sqf | 5 ++-
addons/magazinerepack/initSettings.sqf | 36 +++++++++++++++++++
addons/magazinerepack/script_component.hpp | 2 +-
addons/magazinerepack/stringtable.xml | 9 +++++
8 files changed, 57 insertions(+), 19 deletions(-)
create mode 100644 addons/magazinerepack/initSettings.sqf
diff --git a/addons/magazinerepack/ACE_Settings.hpp b/addons/magazinerepack/ACE_Settings.hpp
index b66fe5f2549..dc82f4e2008 100644
--- a/addons/magazinerepack/ACE_Settings.hpp
+++ b/addons/magazinerepack/ACE_Settings.hpp
@@ -1,26 +1,14 @@
class ACE_Settings {
//Time to move a round from one magazine to another
class GVAR(timePerAmmo) {
- category = CSTRING(DisplayName);
- displayName = CSTRING(timePerAmmo);
- value = 1.5;
- typeName = "SCALAR";
- sliderSettings[] = {1, 10, 1.5, 1};
+ movedToSQF = 1;
};
//Time to swap between magazines when repacking
class GVAR(timePerMagazine) {
- category = CSTRING(DisplayName);
- displayName = CSTRING(timePerMagazine);
- value = 2.0;
- typeName = "SCALAR";
- sliderSettings[] = {1, 10, 2, 1};
+ movedToSQF = 1;
};
//Time to relink 2 belts together
class GVAR(timePerBeltLink) {
- category = CSTRING(DisplayName);
- displayName = CSTRING(timePerBeltLink);
- value = 8.0;
- typeName = "SCALAR";
- sliderSettings[] = {1, 10, 8, 1};
+ movedToSQF = 1;
};
};
diff --git a/addons/magazinerepack/XEH_preInit.sqf b/addons/magazinerepack/XEH_preInit.sqf
index b47cf6628db..9361d05015e 100644
--- a/addons/magazinerepack/XEH_preInit.sqf
+++ b/addons/magazinerepack/XEH_preInit.sqf
@@ -6,4 +6,6 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
+#include "initSettings.sqf"
+
ADDON = true;
diff --git a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
index f448b91b646..aa17e575765 100644
--- a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
+++ b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
@@ -25,5 +25,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >>
_magazineType == _magazine // Magazine is of given type
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
- && {!_isLoaded || {[_unit, _magazineType] call CBA_fnc_canAddItem}} // In inventory or can be moved into it
+ && {!_isLoaded || {(GVAR(repackEquippedMagazines) > 0) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
} count magazinesAmmoFull _unit > 1
diff --git a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
index 3c87b434a71..3eb9fc2a643 100644
--- a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
+++ b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
@@ -27,7 +27,7 @@ private _unitMagCounts = [];
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
//for every partial magazine, that is either in inventory or can be moved there
- if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {[_player, _xClassname] call CBA_fnc_canAddItem}}) then {
+ if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {(GVAR(repackEquippedMagazines) > 0) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}}) then {
private _index = _unitMagazines find _xClassname;
if (_index == -1) then {
_unitMagazines pushBack _xClassname;
diff --git a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
index b776d4bcdbd..5ef22766dcf 100644
--- a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
+++ b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
@@ -39,7 +39,7 @@ private _startingAmmoCounts = [];
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
if (_xLoaded) then {
//Try to Remove from weapon and add to inventory, otherwise ignore
- if ([_player, _magazineClassname] call CBA_fnc_canAddItem) then {
+ if ((GVAR(repackEquippedMagazines) > 0) && {[_player, _magazineClassname] call CBA_fnc_canAddItem}) then {
switch (_xType) do {
case (1): {_player removePrimaryWeaponItem _magazineClassname};
case (2): {_player removeHandgunItem _magazineClassname};
@@ -48,6 +48,9 @@ private _startingAmmoCounts = [];
};
_player addMagazine [_magazineClassname, _xCount];
_startingAmmoCounts pushBack _xCount;
+ if (GVAR(repackEquippedMagazines) == 2) then {
+ [LLSTRING(repackEquippedMagazinesHint)] call EFUNC(common,displayTextStructured);
+ };
};
} else {
_startingAmmoCounts pushBack _xCount;
diff --git a/addons/magazinerepack/initSettings.sqf b/addons/magazinerepack/initSettings.sqf
new file mode 100644
index 00000000000..ebeebc6cf9a
--- /dev/null
+++ b/addons/magazinerepack/initSettings.sqf
@@ -0,0 +1,36 @@
+private _category = format ["ACE %1", localize LSTRING(DisplayName)];
+
+[
+ QGVAR(timePerAmmo),
+ "SLIDER",
+ LSTRING(timePerAmmo),
+ _category,
+ [1, 10, 1.5, 1],
+ 1
+] call CBA_fnc_addSetting;
+
+[
+ QGVAR(timePerMagazine),
+ "SLIDER",
+ LSTRING(timePerMagazine),
+ _category,
+ [1, 10, 2, 1],
+ 1
+] call CBA_fnc_addSetting;
+
+[
+ QGVAR(timePerBeltLink),
+ "SLIDER",
+ LSTRING(timePerBeltLink),
+ _category,
+ [1, 10, 8, 1],
+ 1
+] call CBA_fnc_addSetting;
+
+[
+ QGVAR(repackEquippedMagazines), "LIST",
+ LSTRING(repackEquippedMagazines),
+ _category,
+ [[0, 1, 2], [ELSTRING(common,No), ELSTRING(common,Yes), LSTRING(repackEquippedMagazinesShowHint)], 2],
+ 0
+] call CBA_fnc_addSetting;
diff --git a/addons/magazinerepack/script_component.hpp b/addons/magazinerepack/script_component.hpp
index 0b81c73d98a..0020a3227de 100644
--- a/addons/magazinerepack/script_component.hpp
+++ b/addons/magazinerepack/script_component.hpp
@@ -3,7 +3,7 @@
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
-// #define DISABLE_COMPILE_CACHE
+#define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_MAGAZINEREPACK
diff --git a/addons/magazinerepack/stringtable.xml b/addons/magazinerepack/stringtable.xml
index 18c37c7289b..872a479962c 100644
--- a/addons/magazinerepack/stringtable.xml
+++ b/addons/magazinerepack/stringtable.xml
@@ -166,5 +166,14 @@
%1個滿的與%2個部分的
%1 Dolu ve %2 Partial
+
+ Repack Equipped Magazines
+
+
+ Yes and Show Hint
+
+
+ Repacking magazines, weapon unloaded
+
From 79e220309a129a98efb66b7b9d80d92a7deec232 Mon Sep 17 00:00:00 2001
From: Salluci <69561145+Salluci@users.noreply.github.com>
Date: Sun, 3 Oct 2021 11:12:36 -0300
Subject: [PATCH 2/4] derp
---
addons/magazinerepack/script_component.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/magazinerepack/script_component.hpp b/addons/magazinerepack/script_component.hpp
index 0020a3227de..0b81c73d98a 100644
--- a/addons/magazinerepack/script_component.hpp
+++ b/addons/magazinerepack/script_component.hpp
@@ -3,7 +3,7 @@
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
-#define DISABLE_COMPILE_CACHE
+// #define DISABLE_COMPILE_CACHE
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_MAGAZINEREPACK
From 656f7119180d02a1e641b708f8dbffdc1e66eadd Mon Sep 17 00:00:00 2001
From: Salluci <69561145+Salluci@users.noreply.github.com>
Date: Sun, 3 Oct 2021 11:27:23 -0300
Subject: [PATCH 3/4] derpderp
---
addons/magazinerepack/functions/fnc_getMagazineChildren.sqf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
index 3eb9fc2a643..89723e23c08 100644
--- a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
+++ b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
@@ -27,7 +27,7 @@ private _unitMagCounts = [];
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
//for every partial magazine, that is either in inventory or can be moved there
- if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {(GVAR(repackEquippedMagazines) > 0) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}}) then {
+ if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {(GVAR(repackEquippedMagazines) > 0) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
private _index = _unitMagazines find _xClassname;
if (_index == -1) then {
_unitMagazines pushBack _xClassname;
From 45b460eaf3dec50ec84106b4286f7e7a0ec8f3d1 Mon Sep 17 00:00:00 2001
From: Salluci <69561145+Salluci@users.noreply.github.com>
Date: Sun, 10 Oct 2021 13:02:06 -0300
Subject: [PATCH 4/4] always show hint, remove setting
---
.../magazinerepack/functions/fnc_canRepackMagazine.sqf | 2 +-
.../magazinerepack/functions/fnc_getMagazineChildren.sqf | 2 +-
.../functions/fnc_startRepackingMagazine.sqf | 6 ++----
addons/magazinerepack/initSettings.sqf | 6 +++---
addons/magazinerepack/stringtable.xml | 9 +++------
5 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
index aa17e575765..b5b159b7c28 100644
--- a/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
+++ b/addons/magazinerepack/functions/fnc_canRepackMagazine.sqf
@@ -25,5 +25,5 @@ private _maxAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magazine >>
_magazineType == _magazine // Magazine is of given type
&& {_ammoCount > 0 && {_ammoCount < _maxAmmoCount}} // Is a partial magazine
- && {!_isLoaded || {(GVAR(repackEquippedMagazines) > 0) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
+ && {!_isLoaded || {GVAR(repackLoadedMagazines) && {[_unit, _magazineType] call CBA_fnc_canAddItem}}} // In inventory or can be moved into it
} count magazinesAmmoFull _unit > 1
diff --git a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
index 89723e23c08..70018cd31d3 100644
--- a/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
+++ b/addons/magazinerepack/functions/fnc_getMagazineChildren.sqf
@@ -27,7 +27,7 @@ private _unitMagCounts = [];
private _xFullMagazineCount = getNumber (configFile >> "CfgMagazines" >> _xClassname >> "count");
//for every partial magazine, that is either in inventory or can be moved there
- if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {(GVAR(repackEquippedMagazines) > 0) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
+ if ((_xCount < _xFullMagazineCount) && {_xCount > 0} && {(!_xLoaded) || {GVAR(repackLoadedMagazines) && {[_player, _xClassname] call CBA_fnc_canAddItem}}}) then {
private _index = _unitMagazines find _xClassname;
if (_index == -1) then {
_unitMagazines pushBack _xClassname;
diff --git a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
index 5ef22766dcf..f62e6dc0e37 100644
--- a/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
+++ b/addons/magazinerepack/functions/fnc_startRepackingMagazine.sqf
@@ -39,7 +39,7 @@ private _startingAmmoCounts = [];
if (_xClassname == _magazineClassname && {_xCount != _fullMagazineCount && {_xCount > 0}}) then {
if (_xLoaded) then {
//Try to Remove from weapon and add to inventory, otherwise ignore
- if ((GVAR(repackEquippedMagazines) > 0) && {[_player, _magazineClassname] call CBA_fnc_canAddItem}) then {
+ if (GVAR(repackLoadedMagazines) && {[_player, _magazineClassname] call CBA_fnc_canAddItem}) then {
switch (_xType) do {
case (1): {_player removePrimaryWeaponItem _magazineClassname};
case (2): {_player removeHandgunItem _magazineClassname};
@@ -48,9 +48,7 @@ private _startingAmmoCounts = [];
};
_player addMagazine [_magazineClassname, _xCount];
_startingAmmoCounts pushBack _xCount;
- if (GVAR(repackEquippedMagazines) == 2) then {
- [LLSTRING(repackEquippedMagazinesHint)] call EFUNC(common,displayTextStructured);
- };
+ [LLSTRING(repackLoadedMagazinesHint)] call EFUNC(common,displayTextStructured);
};
} else {
_startingAmmoCounts pushBack _xCount;
diff --git a/addons/magazinerepack/initSettings.sqf b/addons/magazinerepack/initSettings.sqf
index ebeebc6cf9a..46cf96083c5 100644
--- a/addons/magazinerepack/initSettings.sqf
+++ b/addons/magazinerepack/initSettings.sqf
@@ -28,9 +28,9 @@ private _category = format ["ACE %1", localize LSTRING(DisplayName)];
] call CBA_fnc_addSetting;
[
- QGVAR(repackEquippedMagazines), "LIST",
- LSTRING(repackEquippedMagazines),
+ QGVAR(repackLoadedMagazines), "CHECKBOX",
+ LSTRING(repackLoadedMagazines),
_category,
- [[0, 1, 2], [ELSTRING(common,No), ELSTRING(common,Yes), LSTRING(repackEquippedMagazinesShowHint)], 2],
+ true,
0
] call CBA_fnc_addSetting;
diff --git a/addons/magazinerepack/stringtable.xml b/addons/magazinerepack/stringtable.xml
index 872a479962c..106c44c23d0 100644
--- a/addons/magazinerepack/stringtable.xml
+++ b/addons/magazinerepack/stringtable.xml
@@ -166,13 +166,10 @@
%1個滿的與%2個部分的
%1 Dolu ve %2 Partial
-
- Repack Equipped Magazines
+
+ Repack Loaded Magazines
-
- Yes and Show Hint
-
-
+
Repacking magazines, weapon unloaded