From e27110aac361b07339c754a68f75f84f92a476be Mon Sep 17 00:00:00 2001 From: Freddo Date: Sat, 3 Oct 2020 19:00:06 +0200 Subject: [PATCH] Explosives - Add CBA settings for max/min/default timer values (#7916) * Transfer to CBA settings, add timer options * Remove wiki note * Tweak arrays, stringtables * moveToSQF --- addons/explosives/ACE_Settings.hpp | 18 +----- addons/explosives/XEH_preInit.sqf | 2 + .../explosives/functions/fnc_openTimerUI.sqf | 9 +-- addons/explosives/initSettings.sqf | 56 +++++++++++++++++++ addons/explosives/stringtable.xml | 18 ++++++ docs/wiki/framework/explosives-framework.md | 6 -- 6 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 addons/explosives/initSettings.sqf diff --git a/addons/explosives/ACE_Settings.hpp b/addons/explosives/ACE_Settings.hpp index dbde3ea19b..5fce8ac000 100644 --- a/addons/explosives/ACE_Settings.hpp +++ b/addons/explosives/ACE_Settings.hpp @@ -1,23 +1,11 @@ class ACE_Settings { class GVAR(requireSpecialist) { - category = CSTRING(Menu); - displayName = CSTRING(RequireSpecialist_DisplayName); - description = CSTRING(RequireSpecialist_Description); - value = 0; - typeName = "BOOL"; + movedToSQF = 1; }; class GVAR(punishNonSpecialists) { - category = CSTRING(Menu); - displayName = CSTRING(PunishNonSpecialists_DisplayName); - description = CSTRING(PunishNonSpecialists_Description); - value = 1; - typeName = "BOOL"; + movedToSQF = 1; }; class GVAR(explodeOnDefuse) { - category = CSTRING(Menu); - displayName = CSTRING(ExplodeOnDefuse_DisplayName); - description = CSTRING(ExplodeOnDefuse_Description); - value = 1; - typeName = "BOOL"; + movedToSQF = 1; }; }; diff --git a/addons/explosives/XEH_preInit.sqf b/addons/explosives/XEH_preInit.sqf index d9a8d39ff4..3ca414f051 100644 --- a/addons/explosives/XEH_preInit.sqf +++ b/addons/explosives/XEH_preInit.sqf @@ -8,6 +8,8 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +#include "initSettings.sqf" + GVAR(detonationHandlers) = []; ADDON = true; diff --git a/addons/explosives/functions/fnc_openTimerUI.sqf b/addons/explosives/functions/fnc_openTimerUI.sqf index b7715d08a2..7844f6da04 100644 --- a/addons/explosives/functions/fnc_openTimerUI.sqf +++ b/addons/explosives/functions/fnc_openTimerUI.sqf @@ -15,9 +15,6 @@ * Public: No */ -#define TIMER_VALUE_MIN_CUSTOM (missionNamespace getVariable [QGVAR(customTimerMin), TIMER_VALUE_MIN]) -#define TIMER_VALUE_MAX_CUSTOM (missionNamespace getVariable [QGVAR(customTimerMax), TIMER_VALUE_MAX]) - params ["_explosive"]; TRACE_1("Opening timer UI",_explosive); @@ -26,8 +23,8 @@ private _display = uiNamespace getVariable [QGVAR(timerDisplay), displayNull]; // Update slider speed to 1s (_display displayCtrl IDC_TIMER_SLIDER) sliderSetSpeed [1, 1]; -(_display displayCtrl IDC_TIMER_SLIDER) sliderSetRange [TIMER_VALUE_MIN_CUSTOM, TIMER_VALUE_MAX_CUSTOM]; -(_display displayCtrl IDC_TIMER_SLIDER) sliderSetPosition (TIMER_VALUE_DEFAULT max TIMER_VALUE_MIN_CUSTOM min TIMER_VALUE_MAX_CUSTOM); +(_display displayCtrl IDC_TIMER_SLIDER) sliderSetRange [GVAR(customTimerMin), GVAR(customTimerMax)]; +(_display displayCtrl IDC_TIMER_SLIDER) sliderSetPosition (GVAR(customTimerDefault) max GVAR(customTimerMin) min GVAR(customTimerMax)); // Add confirm button action @@ -58,7 +55,7 @@ _display displayAddEventHandler ["MouseZChanged", { if (cba_events_control) then {_change = _change * 10}; private _slider = _display displayCtrl IDC_TIMER_SLIDER; - private _value = (sliderPosition _slider + _change) max TIMER_VALUE_MIN_CUSTOM min TIMER_VALUE_MAX_CUSTOM; + private _value = (sliderPosition _slider + _change) max GVAR(customTimerMin) min GVAR(customTimerMax); _slider sliderSetPosition _value; }]; diff --git a/addons/explosives/initSettings.sqf b/addons/explosives/initSettings.sqf new file mode 100644 index 0000000000..bdbd488550 --- /dev/null +++ b/addons/explosives/initSettings.sqf @@ -0,0 +1,56 @@ +private _categoryStr = format ["ACE %1", LLSTRING(Menu)]; + +[ + QGVAR(requireSpecialist), + "CHECKBOX", + [LLSTRING(RequireSpecialist_DisplayName),LLSTRING(RequireSpecialist_Description)], + _categoryStr, + false, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(punishNonSpecialists), + "CHECKBOX", + [LLSTRING(PunishNonSpecialists_DisplayName),LLSTRING(PunishNonSpecialists_Description)], + _categoryStr, + true, + true +] call CBA_fnc_addSetting; + +[ + QGVAR(explodeOnDefuse), + "CHECKBOX", + [LLSTRING(ExplodeOnDefuse_DisplayName),LLSTRING(ExplodeOnDefuse_Description)], + _categoryStr, + true, + true +] call CBA_fnc_addSetting; + +// Variable names to preserve https://github.com/acemod/ACE3/pull/6882 +[ + QGVAR(customTimerMin), + "TIME", + [LLSTRING(TimerMin_DisplayName), LLSTRING(TimerMin_Description)], + [_categoryStr, LLSTRING(ExplosiveTimer)], + [0, 5999, TIMER_VALUE_MIN], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(customTimerMax), + "TIME", + [LLSTRING(TimerMax_DisplayName), LLSTRING(TimerMax_Description)], + [_categoryStr, LLSTRING(ExplosiveTimer)], + [0, 5999, TIMER_VALUE_MAX], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(customTimerDefault), + "TIME", + [LLSTRING(TimerDefault_DisplayName), LLSTRING(TimerDefault_Description)], + [_categoryStr, LLSTRING(ExplosiveTimer)], + [0, 5999, TIMER_VALUE_DEFAULT], + false +] call CBA_fnc_addSetting; diff --git a/addons/explosives/stringtable.xml b/addons/explosives/stringtable.xml index 4ead75bd6c..0a7341c3ad 100644 --- a/addons/explosives/stringtable.xml +++ b/addons/explosives/stringtable.xml @@ -1101,5 +1101,23 @@ Kontroluje, czy jednostka jest specjalistą od materiałów wybuchowych. Определяет, является ли юнит сапёром. + + Minimum Time + + + Maximum Time + + + Default Time + + + Minimum time value (in seconds) for the explosive timer. + + + Maximum time value (in seconds) for the explosive timer. + + + Default time value (in seconds) for the explosive timer. + diff --git a/docs/wiki/framework/explosives-framework.md b/docs/wiki/framework/explosives-framework.md index fe59e388ef..bd6779b68e 100644 --- a/docs/wiki/framework/explosives-framework.md +++ b/docs/wiki/framework/explosives-framework.md @@ -204,9 +204,3 @@ Jammer that blocks RF triggers: true }] call ace_explosives_fnc_addDetonateHandler; ``` - -#### 5.4 Custom timer limits -`Added in 3.12.7` - -Can set custom min and max time for the timer trigger, can set one or both, time in seconds -`ace_explosives_customTimerMin` / `ace_explosives_customTimerMax`