From ea657b5a76868128765f13eb625d62d32c058682 Mon Sep 17 00:00:00 2001 From: john681611 Date: Tue, 19 Mar 2024 23:41:20 +0000 Subject: [PATCH 01/30] Added: QTE Framework --- addons/common/CfgFunctions.hpp | 6 + addons/common/fnc_generateQTESequence.sqf | 28 +++ addons/common/fnc_getFormattedQTESequence.sqf | 20 +++ addons/common/fnc_runQTE.sqf | 163 ++++++++++++++++++ addons/common/stringtable.xml | 18 ++ 5 files changed, 235 insertions(+) create mode 100644 addons/common/fnc_generateQTESequence.sqf create mode 100644 addons/common/fnc_getFormattedQTESequence.sqf create mode 100644 addons/common/fnc_runQTE.sqf diff --git a/addons/common/CfgFunctions.hpp b/addons/common/CfgFunctions.hpp index 9366f9803..48a7d7531 100644 --- a/addons/common/CfgFunctions.hpp +++ b/addons/common/CfgFunctions.hpp @@ -141,5 +141,11 @@ class CfgFunctions { class Broken { PATHTO_FNC(actionArgument); }; + + class QuickTimeEvent { + PATHTO_FNC(generateQTESequence); + PATHTO_FNC(getFormattedQTESequence); + PATHTO_FNC(runQTE); + }; }; }; diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf new file mode 100644 index 000000000..b1bfd9130 --- /dev/null +++ b/addons/common/fnc_generateQTESequence.sqf @@ -0,0 +1,28 @@ +#include "script_component.hpp" +/* + * Author: john681611 + * Generates a Quick Time Event seqence (= a random sequence of arrow characters of a given length). + * + * Arguments: + * 0: Code length + * + * Return Value: + * Array of arrow characters + * + * Example: + * 5 call ace_common_fnc_generateQTESequence + * + * Public: Yes + */ + +params [["_length", 0, [0]]]; + +if (_length <= 0) exitWith {[]}; + +private _code = []; + +for "_i" from 0 to _length do { + _code pushBack (selectRandom ["↑", "↓", "→", "←"]); +}; + +_code diff --git a/addons/common/fnc_getFormattedQTESequence.sqf b/addons/common/fnc_getFormattedQTESequence.sqf new file mode 100644 index 000000000..72b5cd2ae --- /dev/null +++ b/addons/common/fnc_getFormattedQTESequence.sqf @@ -0,0 +1,20 @@ +#include "script_component.hpp" +/* + * Author: john681611 + * Formats QTE code into something displayable. + * + * Argument: + * 0: QTE Code + * + * Return Value: + * Formatted QTE Code + * + * Example: + * [["↑", "↓", "→", "←"]] call ace_common_fnc_getFormattedQTESequence + * + * Public: Yes + */ + +params ["_code"]; + +_code joinString " " // Arma doesn't know how to space ↑ so we need loads of spaces between diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf new file mode 100644 index 000000000..bc8a8f8d1 --- /dev/null +++ b/addons/common/fnc_runQTE.sqf @@ -0,0 +1,163 @@ +#include "script_component.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" +/* + * Author: john681611 + * Runs a Quick time Event. + * + * Arguments: + * 0: Object QTE is attached to + * 1: Arguments, passed to condition, fail and finish + * 2: On Display: Code callback on displayable event. + * 2: On Finish: Code called or STRING raised as event. + * 3: On Failure: Code called or STRING raised as event. + * 4: QTE Seqence + * 5: max interaction distance from attached object (default: 10) + * 6: timout (default: 30) + * + * Return Value: + * None + * + * Example: + * [car, [], { + hint "Finished!" + }, { + hint "Failure!" + }, ["↑", "↓", "→", "←"]] call ace_common_fnc_runQTE + * + * Public: Yes + */ + +params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_seqence", ["_max_distance", 10], ["_timeout", 30]]; + +if (!GVAR(settingsInitFinished)) exitWith { + // only run this after the settings are initialized + GVAR(runAtSettingsInitialized) pushBack [FUNC(runQTE), _this]; +}; + +if (GVAR(QTERunning)) exitWith { + TRACE_1("QTE already running qeueing up", GVAR(QTERunning)); + [{ + !GVAR(QTERunning) + }, { + _this call FUNC(runQTE); + }, _this] call CBA_fnc_waitUntilAndExecute; +}; + +private _display = findDisplay 46; + +if (isNull _display) exitWith { + TRACE_1("Waiting for main display to be ready", isNull (_display)); + [{ + !isNull (findDisplay 46) + }, { + _this call FUNC(runQTE); + }, _this] call CBA_fnc_waitUntilAndExecute; +}; + +if (_onDisplay isEqualType "") then { + [_onDisplay, [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[], ""]]] call CBA_fnc_localEvent; +} else { + [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[], ""]] call _onDisplay; +}; + +GVAR(QTEHistory) = []; +GVAR(QTERunning) = true; +private _start_time = CBA_missionTime; + +[_display, "KeyUp", { + params ["_displayOrControl", "_key", "_shift", "_ctrl", "_alt"]; + _thisArgs params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_max_distance", "_qte_seqence", "_start_time", "_timeout", "_display"]; + private _elapsedTime = CBA_missionTime - _start_time; + + if (player distance _object > _max_distance || _elapsedTime > _timeout) exitWith { + _display displayRemoveEventHandler ["KeyUp", _thisID]; + GVAR(QTERunning) = false; + if (_onFail isEqualType "") then { + [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFail; + }; + }; + + private _inputKeys = [DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT]; + switch (GVAR(QTEInputKeys)) do { + case 1: { + _inputKeys = [DIK_W, DIK_S, DIK_A, DIK_D]; + }; + case 2: { + _inputKeys = [DIK_I, DIK_K, DIK_J, DIK_L]; + }; + case 3: { + _inputKeys = [DIK_NUMPAD8, DIK_NUMPAD2, DIK_NUMPAD4, DIK_NUMPAD6]; + }; + default { + _inputKeys = [DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT]; + }; + }; + + if !(_key in _inputKeys) exitWith {}; + + if ((GVAR(QTEHoldKey) == 0 && !_ctrl) || + (GVAR(QTEHoldKey) == 1 &&!_alt) || + (GVAR(QTEHoldKey) == 2 &&!_shift)) exitWith { + GVAR(QTEHistory) = []; + if (_onDisplay isEqualType "") then { + [_onDisplay, [ + _args, + [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], + [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]] + ]] call CBA_fnc_localEvent; + } else { + [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]] call _onDisplay; + }; + }; + _override = true; + + if (_key == (_inputKeys select 0)) then { + GVAR(QTEHistory) pushBack "↑"; + }; + + if (_key == (_inputKeys select 1)) then { + GVAR(QTEHistory) pushBack "↓"; + }; + + if (_key == (_inputKeys select 2)) then { + GVAR(QTEHistory) pushBack "←"; + }; + + if (_key == (_inputKeys select 3)) then { + GVAR(QTEHistory) pushBack "→"; + }; + if (GVAR(QTEHistory) isEqualTo _qte_seqence) exitWith { + GVAR(QTEHistory) = []; + _display displayRemoveEventHandler ["KeyUp", _thisID]; + GVAR(QTERunning) = false; + if (_onFinish isEqualType "") then { + [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFinish; + }; + }; + + if !(GVAR(QTEHistory) isEqualTo (_qte_seqence select [0, count GVAR(QTEHistory)])) then { + GVAR(QTEHistory) = []; + }; + + if (_onDisplay isEqualType "") then { + [_onDisplay, [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]]] call CBA_fnc_localEvent; + } else { + [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]] call _onDisplay; + }; + true; + }, [ + _object, + _args, + _onDisplay, + _onFinish, + _onFail, + _max_distance, + _qte_seqence, + _start_time, + _timeout, + _display + ]] call CBA_fnc_addBISEventHandler; \ No newline at end of file diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index a81dca8ea..05164a601 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -43,5 +43,23 @@ CBA Оружие CBA 무기 + + Hold Down Key + + + Input Keys + + + Arrows + + + WASD + + + IJKL + + + Numpad + From 964cefef189b1309dec2c81c842b868369d23641 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:16:58 +0000 Subject: [PATCH 02/30] Update addons/common/fnc_generateQTESequence.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_generateQTESequence.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf index b1bfd9130..1fcaf49ae 100644 --- a/addons/common/fnc_generateQTESequence.sqf +++ b/addons/common/fnc_generateQTESequence.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: john681611 - * Generates a Quick Time Event seqence (= a random sequence of arrow characters of a given length). + * Generates a Quick Time Event sequence (= a random sequence of arrow characters of a given length). * * Arguments: * 0: Code length From 45929cd76759e4cf223b79a0a7276f8e956012b6 Mon Sep 17 00:00:00 2001 From: john681611 Date: Sat, 23 Mar 2024 19:54:20 +0000 Subject: [PATCH 03/30] refactor to use Keybinds --- addons/common/CfgFunctions.hpp | 1 + addons/common/XEH_preInit.sqf | 17 ++ addons/common/fnc_generateQTESequence.sqf | 34 ++-- addons/common/fnc_keyPressedQTE.sqf | 62 ++++++ addons/common/fnc_runQTE.sqf | 230 ++++++++-------------- 5 files changed, 182 insertions(+), 162 deletions(-) create mode 100644 addons/common/fnc_keyPressedQTE.sqf diff --git a/addons/common/CfgFunctions.hpp b/addons/common/CfgFunctions.hpp index 48a7d7531..42e59ca1b 100644 --- a/addons/common/CfgFunctions.hpp +++ b/addons/common/CfgFunctions.hpp @@ -146,6 +146,7 @@ class CfgFunctions { PATHTO_FNC(generateQTESequence); PATHTO_FNC(getFormattedQTESequence); PATHTO_FNC(runQTE); + PATHTO_FNC(keyPressedQTE); }; }; }; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index f75233a19..29fb2c269 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -1,5 +1,6 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" SCRIPT(XEH_preInit); LOG(MSG_INIT); @@ -78,3 +79,19 @@ activateAddons GVAR(addons); ["CAManBase", "InitPost", CBA_fnc_randomizeFacewear] call CBA_fnc_addClassEventHandler; ADDON = true; + +["CBA QTE", QGVAR(keyUpQTE), ["↑", "Up key used in QTE events."], {}, { + ["↑"] call CBA_fnc_keyPressedQTE; +}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; + +["CBA QTE", QGVAR(keyDownQTE), ["↓", "Down key used in QTE events."], {}, { + ["↓"] call CBA_fnc_keyPressedQTE; +}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; + +["CBA QTE", QGVAR(keyLeftQTE), ["←", "Left key used in QTE events."], {}, { + ["←"] call CBA_fnc_keyPressedQTE; +}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; + +["CBA QTE", QGVAR(keyRightQTE), ["→", "Right key used in QTE events."], {}, { + ["→"] call CBA_fnc_keyPressedQTE; +}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf index b1bfd9130..d2720a621 100644 --- a/addons/common/fnc_generateQTESequence.sqf +++ b/addons/common/fnc_generateQTESequence.sqf @@ -1,19 +1,23 @@ #include "script_component.hpp" -/* - * Author: john681611 - * Generates a Quick Time Event seqence (= a random sequence of arrow characters of a given length). - * - * Arguments: - * 0: Code length - * - * Return Value: - * Array of arrow characters - * - * Example: - * 5 call ace_common_fnc_generateQTESequence - * - * Public: Yes - */ +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_generateQTESequence + +Description: + Generate a QTE sequence of a given length. + +Parameters: + _length - + + +Example: + [5] call CBA_fnc_generateQTESequence; + +Returns: + QTE seqence of requested length made up of ["↑", "↓", "→", "←"] + +Author: + john681611 +---------------------------------------------------------------------------- */ params [["_length", 0, [0]]]; diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf new file mode 100644 index 000000000..bef2f24e8 --- /dev/null +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -0,0 +1,62 @@ +#include "script_component.hpp" +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_keyPressedQTE + +Description: + Process QTE Key Press + +Parameters: + _eventQTE - + + +Example: + ["↑"] call CBA_fnc_keyPressedQTE; + +Returns: + Nil + +Author: + john681611 +---------------------------------------------------------------------------- */ + + +params ["_eventQTE"]; + +if!(GVAR(QTERunning)) exitWith {}; // Continues if undefined :( +if!(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; + + +private _object = GVAR(QTEArgs) get "object"; +private _args = GVAR(QTEArgs) get "args"; +private _onDisplay = GVAR(QTEArgs) get "onDisplay"; +private _onFinish = GVAR(QTEArgs) get "onFinish"; +private _onFail = GVAR(QTEArgs) get "onFail"; +private _max_distance = GVAR(QTEArgs) get "max_distance"; +private _qte_seqence = GVAR(QTEArgs) get "qte_seqence"; +private _start_time = GVAR(QTEArgs) get "start_time"; + +private _elapsedTime = CBA_missionTime - _start_time; + +GVAR(QTEHistory) pushBack _eventQTE; + + +if (GVAR(QTEHistory) isEqualTo _qte_seqence) exitWith { + GVAR(QTEHistory) = []; + GVAR(QTERunning) = false; + TRACE_1("QTE Completed",_elapsedTime); + if (_onFinish isEqualType "") then { + [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFinish; + }; +}; + +if !(GVAR(QTEHistory) isEqualTo (_qte_seqence select [0, count GVAR(QTEHistory)])) then { + GVAR(QTEHistory) = []; +}; + +if (_onDisplay isEqualType "") then { + [_onDisplay, [_args, _qte_seqence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; +} else { + [_args, _qte_seqence, GVAR(QTEHistory)] call _onDisplay; +}; \ No newline at end of file diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index bc8a8f8d1..8b26079bf 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -1,41 +1,51 @@ #include "script_component.hpp" -#include "\a3\ui_f\hpp\defineDIKCodes.inc" -/* - * Author: john681611 - * Runs a Quick time Event. - * - * Arguments: - * 0: Object QTE is attached to - * 1: Arguments, passed to condition, fail and finish - * 2: On Display: Code callback on displayable event. - * 2: On Finish: Code called or STRING raised as event. - * 3: On Failure: Code called or STRING raised as event. - * 4: QTE Seqence - * 5: max interaction distance from attached object (default: 10) - * 6: timout (default: 30) - * - * Return Value: - * None - * - * Example: - * [car, [], { - hint "Finished!" - }, { - hint "Failure!" - }, ["↑", "↓", "→", "←"]] call ace_common_fnc_runQTE - * - * Public: Yes - */ - -params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_seqence", ["_max_distance", 10], ["_timeout", 30]]; +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_runQTE + +Description: + Runs a Quick time Event. + +Parameters: + _object - + _args - Extra arguments passed to the _on... functions + _onDisplay - Code callback on displayable event passed [_args, _qte_seqence, _qte_history]. + _onFinish - Code callback on QTE completed passed [_args, _elapsedTime]. + _onFinish - Code callback on QTE timeout/outranged passed [_args, _elapsedTime]. + _qte_seqence - QTE seqence usually made up of ["↑", "↓", "→", "←"] + _max_distance - max interaction distance from attached object (default: 10) + _timeout - ingame timeout (default: 30) + +Example: + [ + car, + [], + { + hint format [ + "%1 \n %2", + [_this select 1] call CBA_fnc_getFormattedQTESequence, + [_this select 2] call CBA_fnc_getFormattedQTESequence + ] + }, + { + hint "Finished!"; + }, + { + hint "Failure!"; + }, + ["↑", "↓", "→", "←"] + ] call CBA_fnc_runQTE + +Returns: + Nil + +Author: + john681611 +---------------------------------------------------------------------------- */ -if (!GVAR(settingsInitFinished)) exitWith { - // only run this after the settings are initialized - GVAR(runAtSettingsInitialized) pushBack [FUNC(runQTE), _this]; -}; +params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_seqence", ["_max_distance", 10], ["_timeout", 30]]; if (GVAR(QTERunning)) exitWith { - TRACE_1("QTE already running qeueing up", GVAR(QTERunning)); + TRACE_1("QTE already running qeueing up",GVAR(QTERunning)); [{ !GVAR(QTERunning) }, { @@ -43,121 +53,47 @@ if (GVAR(QTERunning)) exitWith { }, _this] call CBA_fnc_waitUntilAndExecute; }; -private _display = findDisplay 46; - -if (isNull _display) exitWith { - TRACE_1("Waiting for main display to be ready", isNull (_display)); - [{ - !isNull (findDisplay 46) - }, { - _this call FUNC(runQTE); - }, _this] call CBA_fnc_waitUntilAndExecute; -}; - -if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[], ""]]] call CBA_fnc_localEvent; -} else { - [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[], ""]] call _onDisplay; -}; - GVAR(QTEHistory) = []; GVAR(QTERunning) = true; private _start_time = CBA_missionTime; - -[_display, "KeyUp", { - params ["_displayOrControl", "_key", "_shift", "_ctrl", "_alt"]; - _thisArgs params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_max_distance", "_qte_seqence", "_start_time", "_timeout", "_display"]; - private _elapsedTime = CBA_missionTime - _start_time; - - if (player distance _object > _max_distance || _elapsedTime > _timeout) exitWith { - _display displayRemoveEventHandler ["KeyUp", _thisID]; - GVAR(QTERunning) = false; - if (_onFail isEqualType "") then { - [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; - } else { - [_args, _elapsedTime] call _onFail; - }; +private _qteArgsArray = [ + ["object", _object], + ["args", _args], + ["onDisplay", _onDisplay], + ["onFinish", _onFinish], + ["onFail", _onFail], + ["max_distance", _max_distance], + ["qte_seqence", _qte_seqence], + ["start_time", _start_time], + ["timeout", _timeout] +]; +GVAR(QTEArgs) = createHashMapObject [_qteArgsArray]; + +// Setup +[{ + private _timeout = GVAR(QTEArgs) get "timeout"; + private _object = GVAR(QTEArgs) get "object"; + private _max_distance = GVAR(QTEArgs) get "max_distance"; + private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "start_time"); + + !GVAR(QTERunning) || player distance _object > _max_distance || _elapsedTime > _timeout; +}, { + TRACE_1("QTE ended",GVAR(QTERunning)); + if(!GVAR(QTERunning)) exitWith {}; + GVAR(QTERunning) = false; + GVAR(QTEHistory) = []; + private _onFail = (GVAR(QTEArgs) get "onFail"); + private _args = (GVAR(QTEArgs) get "args"); + TRACE_1("QTE Failed",_args); + if (_onFail isEqualType "") then { + [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFail; }; +}, _this] call CBA_fnc_waitUntilAndExecute; - private _inputKeys = [DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT]; - switch (GVAR(QTEInputKeys)) do { - case 1: { - _inputKeys = [DIK_W, DIK_S, DIK_A, DIK_D]; - }; - case 2: { - _inputKeys = [DIK_I, DIK_K, DIK_J, DIK_L]; - }; - case 3: { - _inputKeys = [DIK_NUMPAD8, DIK_NUMPAD2, DIK_NUMPAD4, DIK_NUMPAD6]; - }; - default { - _inputKeys = [DIK_UP, DIK_DOWN, DIK_LEFT, DIK_RIGHT]; - }; - }; - - if !(_key in _inputKeys) exitWith {}; - - if ((GVAR(QTEHoldKey) == 0 && !_ctrl) || - (GVAR(QTEHoldKey) == 1 &&!_alt) || - (GVAR(QTEHoldKey) == 2 &&!_shift)) exitWith { - GVAR(QTEHistory) = []; - if (_onDisplay isEqualType "") then { - [_onDisplay, [ - _args, - [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], - [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]] - ]] call CBA_fnc_localEvent; - } else { - [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]] call _onDisplay; - }; - }; - _override = true; - - if (_key == (_inputKeys select 0)) then { - GVAR(QTEHistory) pushBack "↑"; - }; - - if (_key == (_inputKeys select 1)) then { - GVAR(QTEHistory) pushBack "↓"; - }; - - if (_key == (_inputKeys select 2)) then { - GVAR(QTEHistory) pushBack "←"; - }; - - if (_key == (_inputKeys select 3)) then { - GVAR(QTEHistory) pushBack "→"; - }; - if (GVAR(QTEHistory) isEqualTo _qte_seqence) exitWith { - GVAR(QTEHistory) = []; - _display displayRemoveEventHandler ["KeyUp", _thisID]; - GVAR(QTERunning) = false; - if (_onFinish isEqualType "") then { - [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; - } else { - [_args, _elapsedTime] call _onFinish; - }; - }; - - if !(GVAR(QTEHistory) isEqualTo (_qte_seqence select [0, count GVAR(QTEHistory)])) then { - GVAR(QTEHistory) = []; - }; - - if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]]] call CBA_fnc_localEvent; - } else { - [_args, [_qte_seqence, [_qte_seqence] call FUNC(getFormattedQTESequence)], [[GVAR(QTEHistory), [GVAR(QTEHistory)] call FUNC(getFormattedQTESequence)]]] call _onDisplay; - }; - true; - }, [ - _object, - _args, - _onDisplay, - _onFinish, - _onFail, - _max_distance, - _qte_seqence, - _start_time, - _timeout, - _display - ]] call CBA_fnc_addBISEventHandler; \ No newline at end of file +if (_onDisplay isEqualType "") then { + [_onDisplay, [_args, _qte_seqence, []]] call CBA_fnc_localEvent; +} else { + [_args, _qte_seqence, []] call _onDisplay; +}; \ No newline at end of file From 3576e8e8fa63fa0530c1b8513aa9dd17fe5c7405 Mon Sep 17 00:00:00 2001 From: john681611 Date: Sat, 23 Mar 2024 20:06:48 +0000 Subject: [PATCH 04/30] Fix null issue on key press --- addons/common/XEH_preInit.sqf | 8 ++++---- addons/common/fnc_keyPressedQTE.sqf | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 29fb2c269..72ed401d7 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -80,18 +80,18 @@ activateAddons GVAR(addons); ADDON = true; -["CBA QTE", QGVAR(keyUpQTE), ["↑", "Up key used in QTE events."], {}, { +["CBA QTE", "QTE_Up_Key", ["↑", "Up key used in QTE events."], {}, { ["↑"] call CBA_fnc_keyPressedQTE; }, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", QGVAR(keyDownQTE), ["↓", "Down key used in QTE events."], {}, { +["CBA QTE", "QTE_Down_Key", ["↓", "Down key used in QTE events."], {}, { ["↓"] call CBA_fnc_keyPressedQTE; }, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", QGVAR(keyLeftQTE), ["←", "Left key used in QTE events."], {}, { +["CBA QTE", "QTE_Left_Key", ["←", "Left key used in QTE events."], {}, { ["←"] call CBA_fnc_keyPressedQTE; }, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", QGVAR(keyRightQTE), ["→", "Right key used in QTE events."], {}, { +["CBA QTE", "QTE_Right_Key", ["→", "Right key used in QTE events."], {}, { ["→"] call CBA_fnc_keyPressedQTE; }, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index bef2f24e8..271598c60 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -21,8 +21,8 @@ Author: params ["_eventQTE"]; - -if!(GVAR(QTERunning)) exitWith {}; // Continues if undefined :( +GVAR(QTERunning) = RETDEF(GVAR(QTERunning),false); +if!(GVAR(QTERunning)) exitWith {}; if!(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; From dbc5abe33bdc4566015301a5319ce4c3c015545b Mon Sep 17 00:00:00 2001 From: john681611 Date: Sat, 23 Mar 2024 22:17:35 +0000 Subject: [PATCH 05/30] review improvements --- addons/common/XEH_preInit.sqf | 8 +-- addons/common/fnc_generateQTESequence.sqf | 4 +- addons/common/fnc_getFormattedQTESequence.sqf | 34 +++++++------ addons/common/fnc_keyPressedQTE.sqf | 12 ++--- addons/common/fnc_runQTE.sqf | 50 +++++++++---------- 5 files changed, 55 insertions(+), 53 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 72ed401d7..b2d7ea966 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -80,18 +80,18 @@ activateAddons GVAR(addons); ADDON = true; -["CBA QTE", "QTE_Up_Key", ["↑", "Up key used in QTE events."], {}, { +["CBA Quick-Time Events", "QTE_Up_Key", ["↑", "Up key used in Quick-Time Events."], {}, { ["↑"] call CBA_fnc_keyPressedQTE; }, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", "QTE_Down_Key", ["↓", "Down key used in QTE events."], {}, { +["CBA Quick-Time Events", "QTE_Down_Key", ["↓", "Down key used in Quick-Time Events."], {}, { ["↓"] call CBA_fnc_keyPressedQTE; }, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", "QTE_Left_Key", ["←", "Left key used in QTE events."], {}, { +["CBA Quick-Time Events", "QTE_Left_Key", ["←", "Left key used in Quick-Time Events."], {}, { ["←"] call CBA_fnc_keyPressedQTE; }, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA QTE", "QTE_Right_Key", ["→", "Right key used in QTE events."], {}, { +["CBA Quick-Time Events", "QTE_Right_Key", ["→", "Right key used in Quick-Time Events."], {}, { ["→"] call CBA_fnc_keyPressedQTE; }, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf index d2720a621..15c17579e 100644 --- a/addons/common/fnc_generateQTESequence.sqf +++ b/addons/common/fnc_generateQTESequence.sqf @@ -3,7 +3,7 @@ Function: CBA_fnc_generateQTESequence Description: - Generate a QTE sequence of a given length. + Generate a Quick-Time sequence of a given length. Parameters: _length - @@ -13,7 +13,7 @@ Example: [5] call CBA_fnc_generateQTESequence; Returns: - QTE seqence of requested length made up of ["↑", "↓", "→", "←"] + Quick-Time sequence of requested length made up of ["↑", "↓", "→", "←"] Author: john681611 diff --git a/addons/common/fnc_getFormattedQTESequence.sqf b/addons/common/fnc_getFormattedQTESequence.sqf index 72b5cd2ae..d62f1a350 100644 --- a/addons/common/fnc_getFormattedQTESequence.sqf +++ b/addons/common/fnc_getFormattedQTESequence.sqf @@ -1,19 +1,23 @@ #include "script_component.hpp" -/* - * Author: john681611 - * Formats QTE code into something displayable. - * - * Argument: - * 0: QTE Code - * - * Return Value: - * Formatted QTE Code - * - * Example: - * [["↑", "↓", "→", "←"]] call ace_common_fnc_getFormattedQTESequence - * - * Public: Yes - */ +/* ---------------------------------------------------------------------------- +Function: CBA_fnc_getFormattedQTESequence + +Description: + Formats Quick-Time sequence into a displayable string. + +Parameters: + _code - Quick-Time sequence + + +Example: + [["↑", "↓", "→", "←"]] call CBA_fnc_getFormattedQTESequence; + +Returns: + Formatted Quick-Time sequence + +Author: + john681611 +---------------------------------------------------------------------------- */ params ["_code"]; diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index 271598c60..8daa2ab09 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -3,7 +3,7 @@ Function: CBA_fnc_keyPressedQTE Description: - Process QTE Key Press + Process Quick-Time Key Press Parameters: _eventQTE - @@ -32,7 +32,7 @@ private _onDisplay = GVAR(QTEArgs) get "onDisplay"; private _onFinish = GVAR(QTEArgs) get "onFinish"; private _onFail = GVAR(QTEArgs) get "onFail"; private _max_distance = GVAR(QTEArgs) get "max_distance"; -private _qte_seqence = GVAR(QTEArgs) get "qte_seqence"; +private _qte_sequence = GVAR(QTEArgs) get "qte_seqence"; private _start_time = GVAR(QTEArgs) get "start_time"; private _elapsedTime = CBA_missionTime - _start_time; @@ -40,7 +40,7 @@ private _elapsedTime = CBA_missionTime - _start_time; GVAR(QTEHistory) pushBack _eventQTE; -if (GVAR(QTEHistory) isEqualTo _qte_seqence) exitWith { +if (GVAR(QTEHistory) isEqualTo _qte_sequence) exitWith { GVAR(QTEHistory) = []; GVAR(QTERunning) = false; TRACE_1("QTE Completed",_elapsedTime); @@ -51,12 +51,12 @@ if (GVAR(QTEHistory) isEqualTo _qte_seqence) exitWith { }; }; -if !(GVAR(QTEHistory) isEqualTo (_qte_seqence select [0, count GVAR(QTEHistory)])) then { +if !(GVAR(QTEHistory) isEqualTo (_qte_sequence select [0, count GVAR(QTEHistory)])) then { GVAR(QTEHistory) = []; }; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_seqence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qte_sequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; } else { - [_args, _qte_seqence, GVAR(QTEHistory)] call _onDisplay; + [_args, _qte_sequence, GVAR(QTEHistory)] call _onDisplay; }; \ No newline at end of file diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 8b26079bf..5bd1a640d 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -8,32 +8,30 @@ Description: Parameters: _object - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qte_seqence, _qte_history]. - _onFinish - Code callback on QTE completed passed [_args, _elapsedTime]. - _onFinish - Code callback on QTE timeout/outranged passed [_args, _elapsedTime]. - _qte_seqence - QTE seqence usually made up of ["↑", "↓", "→", "←"] + _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. + _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. + _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. + _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] _max_distance - max interaction distance from attached object (default: 10) _timeout - ingame timeout (default: 30) Example: - [ - car, - [], - { - hint format [ - "%1 \n %2", - [_this select 1] call CBA_fnc_getFormattedQTESequence, - [_this select 2] call CBA_fnc_getFormattedQTESequence - ] - }, - { - hint "Finished!"; - }, - { - hint "Failure!"; - }, - ["↑", "↓", "→", "←"] - ] call CBA_fnc_runQTE + [car, + [], + { + hint format [ + "%1 \n %2", + [_this select 1] call CBA_fnc_getFormattedQTESequence, + [_this select 2] call CBA_fnc_getFormattedQTESequence + ] + }, + { + hint "Finished!"; + }, + { + hint "Failure!"; + }, + ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE Returns: Nil @@ -43,7 +41,7 @@ Author: ---------------------------------------------------------------------------- */ -params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_seqence", ["_max_distance", 10], ["_timeout", 30]]; +params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_sequence", ["_max_distance", 10], ["_timeout", 30]]; if (GVAR(QTERunning)) exitWith { TRACE_1("QTE already running qeueing up",GVAR(QTERunning)); [{ @@ -63,7 +61,7 @@ private _qteArgsArray = [ ["onFinish", _onFinish], ["onFail", _onFail], ["max_distance", _max_distance], - ["qte_seqence", _qte_seqence], + ["qte_seqence", _qte_sequence], ["start_time", _start_time], ["timeout", _timeout] ]; @@ -93,7 +91,7 @@ GVAR(QTEArgs) = createHashMapObject [_qteArgsArray]; }, _this] call CBA_fnc_waitUntilAndExecute; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_seqence, []]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; } else { - [_args, _qte_seqence, []] call _onDisplay; + [_args, _qte_sequence, []] call _onDisplay; }; \ No newline at end of file From d35bfb8bcf32e9a8dbde01e11d44d9748449a8e7 Mon Sep 17 00:00:00 2001 From: john681611 Date: Sat, 23 Mar 2024 22:24:26 +0000 Subject: [PATCH 06/30] Support localization --- addons/common/XEH_preInit.sqf | 8 ++++---- addons/common/stringtable.xml | 24 +++++++++++------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index b2d7ea966..35574211a 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -80,18 +80,18 @@ activateAddons GVAR(addons); ADDON = true; -["CBA Quick-Time Events", "QTE_Up_Key", ["↑", "Up key used in Quick-Time Events."], {}, { +[ELSTRING(QTEKeybindGroup), "QTE_Up_Key", ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { ["↑"] call CBA_fnc_keyPressedQTE; }, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA Quick-Time Events", "QTE_Down_Key", ["↓", "Down key used in Quick-Time Events."], {}, { +[ELSTRING(QTEKeybindGroup), "QTE_Down_Key", ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { ["↓"] call CBA_fnc_keyPressedQTE; }, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA Quick-Time Events", "QTE_Left_Key", ["←", "Left key used in Quick-Time Events."], {}, { +[ELSTRING(QTEKeybindGroup), "QTE_Left_Key", ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { ["←"] call CBA_fnc_keyPressedQTE; }, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -["CBA Quick-Time Events", "QTE_Right_Key", ["→", "Right key used in Quick-Time Events."], {}, { +[ELSTRING(QTEKeybindGroup), "QTE_Right_Key", ["→", LSTRING(QTEKeybindRightTooltip)], {}, { ["→"] call CBA_fnc_keyPressedQTE; }, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 05164a601..7dc8abe85 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -43,23 +43,21 @@ CBA Оружие CBA 무기 - - Hold Down Key + + CBA Quick-Time Events - - Input Keys + + Up key used in Quick-Time Events. - - Arrows + + Down key used in Quick-Time Events. - - WASD + + Left key used in Quick-Time Events. - - IJKL - - - Numpad + + Right key used in Quick-Time Events. + From 986d8281168434b332e04f314d226f7f87d02371 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:10:35 +0000 Subject: [PATCH 07/30] Update addons/common/XEH_preInit.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/XEH_preInit.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 35574211a..0a323ce4f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -80,18 +80,18 @@ activateAddons GVAR(addons); ADDON = true; -[ELSTRING(QTEKeybindGroup), "QTE_Up_Key", ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { +[ELSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { ["↑"] call CBA_fnc_keyPressedQTE; }, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), "QTE_Down_Key", ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { +[ELSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { ["↓"] call CBA_fnc_keyPressedQTE; }, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), "QTE_Left_Key", ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { +[ELSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { ["←"] call CBA_fnc_keyPressedQTE; }, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), "QTE_Right_Key", ["→", LSTRING(QTEKeybindRightTooltip)], {}, { +[ELSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], {}, { ["→"] call CBA_fnc_keyPressedQTE; }, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; From 26529cc6ac8da475784df30999125d2b562dc88a Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:10:45 +0000 Subject: [PATCH 08/30] Update addons/common/fnc_generateQTESequence.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_generateQTESequence.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf index 15c17579e..f8ee4c24d 100644 --- a/addons/common/fnc_generateQTESequence.sqf +++ b/addons/common/fnc_generateQTESequence.sqf @@ -6,8 +6,7 @@ Description: Generate a Quick-Time sequence of a given length. Parameters: - _length - - + _length - Length of QTE sequence Example: [5] call CBA_fnc_generateQTESequence; From 5255969e1739b3c417435b13019f353f3dc12bf8 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:11:01 +0000 Subject: [PATCH 09/30] Update addons/common/fnc_keyPressedQTE.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_keyPressedQTE.sqf | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index 8daa2ab09..7e0d1ebd1 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -8,7 +8,6 @@ Description: Parameters: _eventQTE - - Example: ["↑"] call CBA_fnc_keyPressedQTE; From 96806a9305064d46a1379c840d2373ecb438b0d1 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:12:26 +0000 Subject: [PATCH 10/30] Update addons/common/fnc_runQTE.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_runQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 5bd1a640d..b37780de0 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -94,4 +94,4 @@ if (_onDisplay isEqualType "") then { [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; } else { [_args, _qte_sequence, []] call _onDisplay; -}; \ No newline at end of file +}; From 6597fc88496e4d0c175acebf446b4f66f135cfc3 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:12:48 +0000 Subject: [PATCH 11/30] Update addons/common/stringtable.xml Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/stringtable.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 7dc8abe85..7c6410100 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -58,6 +58,5 @@ Right key used in Quick-Time Events. - From 9feffc8c4c1ce48d5672333ffada23df2e017ebe Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:30:23 +0000 Subject: [PATCH 12/30] Update addons/common/fnc_keyPressedQTE.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_keyPressedQTE.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index 7e0d1ebd1..bc38010cd 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -20,9 +20,9 @@ Author: params ["_eventQTE"]; -GVAR(QTERunning) = RETDEF(GVAR(QTERunning),false); -if!(GVAR(QTERunning)) exitWith {}; -if!(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; + +if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith {}; +if !(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; private _object = GVAR(QTEArgs) get "object"; From c851040c46112d4962b05f5c2868188ccc48c455 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:30:43 +0000 Subject: [PATCH 13/30] Update addons/common/fnc_keyPressedQTE.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_keyPressedQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index bc38010cd..bee6d4c2a 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -50,7 +50,7 @@ if (GVAR(QTEHistory) isEqualTo _qte_sequence) exitWith { }; }; -if !(GVAR(QTEHistory) isEqualTo (_qte_sequence select [0, count GVAR(QTEHistory)])) then { +if (GVAR(QTEHistory) isNotEqualTo (_qte_sequence select [0, count GVAR(QTEHistory)])) then { GVAR(QTEHistory) = []; }; From 68c586bf7a9cd1be737aacf6d4bb36acb6025633 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 26 Mar 2024 07:31:30 +0000 Subject: [PATCH 14/30] Update addons/common/fnc_keyPressedQTE.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/fnc_keyPressedQTE.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index bee6d4c2a..f7cf028d6 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -55,7 +55,7 @@ if (GVAR(QTEHistory) isNotEqualTo (_qte_sequence select [0, count GVAR(QTEHistor }; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_sequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qte_sequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; } else { - [_args, _qte_sequence, GVAR(QTEHistory)] call _onDisplay; -}; \ No newline at end of file + [_args, _qte_sequence, GVAR(QTEHistory)] call _onDisplay; +}; From f48ebaae5e35bbbc076787f3a080bea5264a5426 Mon Sep 17 00:00:00 2001 From: john681611 Date: Tue, 26 Mar 2024 07:35:51 +0000 Subject: [PATCH 15/30] review comments --- addons/common/fnc_generateQTESequence.sqf | 2 +- addons/common/fnc_getFormattedQTESequence.sqf | 2 +- addons/common/fnc_keyPressedQTE.sqf | 45 +++---- addons/common/fnc_runQTE.sqf | 117 +++++++++--------- 4 files changed, 79 insertions(+), 87 deletions(-) diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/common/fnc_generateQTESequence.sqf index f8ee4c24d..31a92e80e 100644 --- a/addons/common/fnc_generateQTESequence.sqf +++ b/addons/common/fnc_generateQTESequence.sqf @@ -3,7 +3,7 @@ Function: CBA_fnc_generateQTESequence Description: - Generate a Quick-Time sequence of a given length. + Generate a Quick-Time sequence of a given length. Parameters: _length - Length of QTE sequence diff --git a/addons/common/fnc_getFormattedQTESequence.sqf b/addons/common/fnc_getFormattedQTESequence.sqf index d62f1a350..a7b88419e 100644 --- a/addons/common/fnc_getFormattedQTESequence.sqf +++ b/addons/common/fnc_getFormattedQTESequence.sqf @@ -3,7 +3,7 @@ Function: CBA_fnc_getFormattedQTESequence Description: - Formats Quick-Time sequence into a displayable string. + Formats Quick-Time sequence into a displayable string. Parameters: _code - Quick-Time sequence diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index f7cf028d6..b3825eb42 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -3,16 +3,16 @@ Function: CBA_fnc_keyPressedQTE Description: - Process Quick-Time Key Press + Process Quick-Time Key Press Parameters: - _eventQTE - + _eventQTE - Character to test against Quick-Time Event Example: ["↑"] call CBA_fnc_keyPressedQTE; Returns: - Nil + None Author: john681611 @@ -25,37 +25,32 @@ if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith {}; if !(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; -private _object = GVAR(QTEArgs) get "object"; private _args = GVAR(QTEArgs) get "args"; -private _onDisplay = GVAR(QTEArgs) get "onDisplay"; -private _onFinish = GVAR(QTEArgs) get "onFinish"; -private _onFail = GVAR(QTEArgs) get "onFail"; -private _max_distance = GVAR(QTEArgs) get "max_distance"; -private _qte_sequence = GVAR(QTEArgs) get "qte_seqence"; -private _start_time = GVAR(QTEArgs) get "start_time"; - -private _elapsedTime = CBA_missionTime - _start_time; +private _qteSequence = GVAR(QTEArgs) get "qte_seqence"; +private _elapsedTime = CBA_missionTime - GVAR(QTEArgs) get "start_time"; GVAR(QTEHistory) pushBack _eventQTE; -if (GVAR(QTEHistory) isEqualTo _qte_sequence) exitWith { - GVAR(QTEHistory) = []; - GVAR(QTERunning) = false; - TRACE_1("QTE Completed",_elapsedTime); - if (_onFinish isEqualType "") then { - [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; - } else { - [_args, _elapsedTime] call _onFinish; - }; +if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { + GVAR(QTEHistory) = []; + GVAR(QTERunning) = false; + TRACE_1("QTE Completed",_elapsedTime); + private _onFinish = GVAR(QTEArgs) get "onFinish"; + if (_onFinish isEqualType "") then { + [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFinish; + }; }; -if (GVAR(QTEHistory) isNotEqualTo (_qte_sequence select [0, count GVAR(QTEHistory)])) then { - GVAR(QTEHistory) = []; +if (GVAR(QTEHistory) isNotEqualTo (_qteSequence select [0, count GVAR(QTEHistory)])) then { + GVAR(QTEHistory) = []; }; +private _onDisplay = GVAR(QTEArgs) get "onDisplay"; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_sequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qteSequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; } else { - [_args, _qte_sequence, GVAR(QTEHistory)] call _onDisplay; + [_args, _qteSequence, GVAR(QTEHistory)] call _onDisplay; }; diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index b37780de0..f215c9305 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -3,35 +3,35 @@ Function: CBA_fnc_runQTE Description: - Runs a Quick time Event. + Runs a Quick time Event. Parameters: - _object - - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. - _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. - _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. - _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] - _max_distance - max interaction distance from attached object (default: 10) - _timeout - ingame timeout (default: 30) + _object - + _args - Extra arguments passed to the _on... functions + _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. + _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. + _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. + _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] + _max_distance - max interaction distance from attached object (default: 10) + _timeout - ingame timeout (default: 30) Example: [car, - [], - { - hint format [ - "%1 \n %2", - [_this select 1] call CBA_fnc_getFormattedQTESequence, - [_this select 2] call CBA_fnc_getFormattedQTESequence - ] - }, - { - hint "Finished!"; - }, - { - hint "Failure!"; - }, - ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE + [], + { + hint format [ + "%1 \n %2", + [_this select 1] call CBA_fnc_getFormattedQTESequence, + [_this select 2] call CBA_fnc_getFormattedQTESequence + ] + }, + { + hint "Finished!"; + }, + { + hint "Failure!"; + }, + ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE Returns: Nil @@ -43,55 +43,52 @@ Author: params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_sequence", ["_max_distance", 10], ["_timeout", 30]]; if (GVAR(QTERunning)) exitWith { - TRACE_1("QTE already running qeueing up",GVAR(QTERunning)); - [{ - !GVAR(QTERunning) - }, { - _this call FUNC(runQTE); - }, _this] call CBA_fnc_waitUntilAndExecute; + false }; GVAR(QTEHistory) = []; GVAR(QTERunning) = true; private _start_time = CBA_missionTime; private _qteArgsArray = [ - ["object", _object], - ["args", _args], - ["onDisplay", _onDisplay], - ["onFinish", _onFinish], - ["onFail", _onFail], - ["max_distance", _max_distance], - ["qte_seqence", _qte_sequence], - ["start_time", _start_time], - ["timeout", _timeout] + ["object", _object], + ["args", _args], + ["onDisplay", _onDisplay], + ["onFinish", _onFinish], + ["onFail", _onFail], + ["max_distance", _max_distance], + ["qte_seqence", _qte_sequence], + ["start_time", _start_time], + ["timeout", _timeout] ]; -GVAR(QTEArgs) = createHashMapObject [_qteArgsArray]; +GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; // Setup [{ - private _timeout = GVAR(QTEArgs) get "timeout"; - private _object = GVAR(QTEArgs) get "object"; - private _max_distance = GVAR(QTEArgs) get "max_distance"; - private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "start_time"); - - !GVAR(QTERunning) || player distance _object > _max_distance || _elapsedTime > _timeout; + private _timeout = GVAR(QTEArgs) get "timeout"; + private _object = GVAR(QTEArgs) get "object"; + private _max_distance = GVAR(QTEArgs) get "max_distance"; + private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "start_time"); + + !GVAR(QTERunning) || player distance _object > _max_distance || _elapsedTime > _timeout; }, { - TRACE_1("QTE ended",GVAR(QTERunning)); - if(!GVAR(QTERunning)) exitWith {}; - GVAR(QTERunning) = false; - GVAR(QTEHistory) = []; - private _onFail = (GVAR(QTEArgs) get "onFail"); - private _args = (GVAR(QTEArgs) get "args"); - TRACE_1("QTE Failed",_args); - if (_onFail isEqualType "") then { - [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; - } else { - [_args, _elapsedTime] call _onFail; - }; + TRACE_1("QTE ended",GVAR(QTERunning)); + if(!GVAR(QTERunning)) exitWith {}; + GVAR(QTERunning) = false; + GVAR(QTEHistory) = []; + private _onFail = (GVAR(QTEArgs) get "onFail"); + private _args = (GVAR(QTEArgs) get "args"); + TRACE_1("QTE Failed",_args); + if (_onFail isEqualType "") then { + [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; + } else { + [_args, _elapsedTime] call _onFail; + }; }, _this] call CBA_fnc_waitUntilAndExecute; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; } else { - [_args, _qte_sequence, []] call _onDisplay; + [_args, _qte_sequence, []] call _onDisplay; }; + +true From d99bb4f9e6221ada28ba3314a9202e9b27a28d1a Mon Sep 17 00:00:00 2001 From: john681611 Date: Wed, 27 Mar 2024 09:48:50 +0000 Subject: [PATCH 16/30] minor improvements --- addons/common/fnc_keyPressedQTE.sqf | 10 +++++++--- addons/common/fnc_runQTE.sqf | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index b3825eb42..14ee20a1b 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -12,7 +12,7 @@ Example: ["↑"] call CBA_fnc_keyPressedQTE; Returns: - None + - True if QTE is running Author: john681611 @@ -21,8 +21,9 @@ Author: params ["_eventQTE"]; -if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith {}; -if !(_eventQTE in ["↑", "↓", "→", "←"]) exitWith {}; +if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { + false +}; private _args = GVAR(QTEArgs) get "args"; @@ -42,6 +43,7 @@ if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { } else { [_args, _elapsedTime] call _onFinish; }; + true }; if (GVAR(QTEHistory) isNotEqualTo (_qteSequence select [0, count GVAR(QTEHistory)])) then { @@ -54,3 +56,5 @@ if (_onDisplay isEqualType "") then { } else { [_args, _qteSequence, GVAR(QTEHistory)] call _onDisplay; }; + +true diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index f215c9305..9c8b3c569 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -8,12 +8,12 @@ Description: Parameters: _object - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. + _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. - _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] - _max_distance - max interaction distance from attached object (default: 10) - _timeout - ingame timeout (default: 30) + _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] + _max_distance - max interaction distance from attached object (default: 10) + _timeout - ingame timeout (default: 30) Example: [car, @@ -34,7 +34,7 @@ Example: ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE Returns: - Nil + - True if the QTE was started, false if it was already running. Author: john681611 @@ -83,7 +83,7 @@ GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; } else { [_args, _elapsedTime] call _onFail; }; -}, _this] call CBA_fnc_waitUntilAndExecute; +}, []] call CBA_fnc_waitUntilAndExecute; if (_onDisplay isEqualType "") then { [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; From 97fc243ceb2c7eff1c783f87d6efb6a419cf50ef Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:22:48 +0000 Subject: [PATCH 17/30] Update addons/common/fnc_keyPressedQTE.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/common/fnc_keyPressedQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/common/fnc_keyPressedQTE.sqf index 14ee20a1b..3907eaf48 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/common/fnc_keyPressedQTE.sqf @@ -12,7 +12,7 @@ Example: ["↑"] call CBA_fnc_keyPressedQTE; Returns: - - True if QTE is running + True if QTE is running Author: john681611 From 29f9f11711df12c6f28e0252e0f9f41de04e47cd Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:22:59 +0000 Subject: [PATCH 18/30] Update addons/common/fnc_runQTE.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/common/fnc_runQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 9c8b3c569..328e31b27 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -34,7 +34,7 @@ Example: ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE Returns: - - True if the QTE was started, false if it was already running. + True if the QTE was started, false if it was already running Author: john681611 From 1fbb063b2b63a1f6ba0a33c8d79a500737f2655e Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:24:01 +0100 Subject: [PATCH 19/30] Update addons/common/fnc_runQTE.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/common/fnc_runQTE.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 328e31b27..e7c9950d3 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -19,10 +19,10 @@ Example: [car, [], { - hint format [ - "%1 \n %2", - [_this select 1] call CBA_fnc_getFormattedQTESequence, - [_this select 2] call CBA_fnc_getFormattedQTESequence + hint format [ + "%1 \n %2", + [_this select 1] call CBA_fnc_getFormattedQTESequence, + [_this select 2] call CBA_fnc_getFormattedQTESequence ] }, { From c8e951b716c363c0f5bf6a372a943400b4ea9a16 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:16:14 +0100 Subject: [PATCH 20/30] Update addons/common/fnc_runQTE.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/common/fnc_runQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index e7c9950d3..1dc9a716b 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -26,7 +26,7 @@ Example: ] }, { - hint "Finished!"; + hint "Finished!"; }, { hint "Failure!"; From 24bf821131103b1903b3db9fab487d83e0ca5cd3 Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:21:07 +0100 Subject: [PATCH 21/30] Update addons/common/fnc_runQTE.sqf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jouni Järvinen --- addons/common/fnc_runQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 1dc9a716b..050d27e61 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -3,7 +3,7 @@ Function: CBA_fnc_runQTE Description: - Runs a Quick time Event. + Runs a Quick-Time Event. Parameters: _object - From 9eb7b18a78c054078c35cbe84aa494f926c3c823 Mon Sep 17 00:00:00 2001 From: john681611 Date: Tue, 30 Apr 2024 21:29:24 +0100 Subject: [PATCH 22/30] format: camelcasing --- addons/common/fnc_runQTE.sqf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/addons/common/fnc_runQTE.sqf b/addons/common/fnc_runQTE.sqf index 9c8b3c569..883d10240 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/common/fnc_runQTE.sqf @@ -8,11 +8,11 @@ Description: Parameters: _object - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qte_sequence, _qte_history]. + _onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qte_history]. _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. - _qte_sequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] - _max_distance - max interaction distance from attached object (default: 10) + _qteSequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] + _maxDistance - max interaction distance from attached object (default: 10) _timeout - ingame timeout (default: 30) Example: @@ -41,23 +41,23 @@ Author: ---------------------------------------------------------------------------- */ -params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qte_sequence", ["_max_distance", 10], ["_timeout", 30]]; +params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qteSequence", ["_maxDistance", 10], ["_timeout", 30]]; if (GVAR(QTERunning)) exitWith { false }; GVAR(QTEHistory) = []; GVAR(QTERunning) = true; -private _start_time = CBA_missionTime; +private _startTime = CBA_missionTime; private _qteArgsArray = [ ["object", _object], ["args", _args], ["onDisplay", _onDisplay], ["onFinish", _onFinish], ["onFail", _onFail], - ["max_distance", _max_distance], - ["qte_seqence", _qte_sequence], - ["start_time", _start_time], + ["maxDistance", _maxDistance], + ["qte_seqence", _qteSequence], + ["startTime", _startTime], ["timeout", _timeout] ]; GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; @@ -66,10 +66,10 @@ GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; [{ private _timeout = GVAR(QTEArgs) get "timeout"; private _object = GVAR(QTEArgs) get "object"; - private _max_distance = GVAR(QTEArgs) get "max_distance"; - private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "start_time"); + private _maxDistance = GVAR(QTEArgs) get "maxDistance"; + private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); - !GVAR(QTERunning) || player distance _object > _max_distance || _elapsedTime > _timeout; + !GVAR(QTERunning) || player distance _object > _maxDistance || _elapsedTime > _timeout; }, { TRACE_1("QTE ended",GVAR(QTERunning)); if(!GVAR(QTERunning)) exitWith {}; @@ -86,9 +86,9 @@ GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; }, []] call CBA_fnc_waitUntilAndExecute; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qte_sequence, []]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qteSequence, []]] call CBA_fnc_localEvent; } else { - [_args, _qte_sequence, []] call _onDisplay; + [_args, _qteSequence, []] call _onDisplay; }; true From a22d373a735d6b98e2b8bfe8eed68c1d6ccc345e Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Tue, 30 Apr 2024 21:31:12 +0100 Subject: [PATCH 23/30] Update addons/common/XEH_preInit.sqf Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- addons/common/XEH_preInit.sqf | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 0a323ce4f..3a2140f1f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -80,18 +80,18 @@ activateAddons GVAR(addons); ADDON = true; -[ELSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { - ["↑"] call CBA_fnc_keyPressedQTE; -}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], { + ["↑"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { - ["↓"] call CBA_fnc_keyPressedQTE; -}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], { + ["↓"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { - ["←"] call CBA_fnc_keyPressedQTE; -}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { + ["←"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], {}, { - ["→"] call CBA_fnc_keyPressedQTE; -}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], { + ["→"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; From 9a6cfb28c216284d1da85a8dc72a31b73a2ac795 Mon Sep 17 00:00:00 2001 From: john681611 Date: Wed, 1 May 2024 00:23:39 +0100 Subject: [PATCH 24/30] migrate to quicktime component --- addons/common/CfgFunctions.hpp | 7 ------ addons/common/XEH_preInit.sqf | 18 +------------- addons/common/stringtable.xml | 15 ------------ addons/main/config.cpp | 3 ++- addons/quicktime/$PBOPREFIX$ | 1 + addons/quicktime/CfgEventHandlers.hpp | 12 ++++++++++ addons/quicktime/CfgFunctions.hpp | 10 ++++++++ addons/quicktime/XEH_preInit.sqf | 24 +++++++++++++++++++ addons/quicktime/XEH_preStart.sqf | 4 ++++ addons/quicktime/config.cpp | 18 ++++++++++++++ .../fnc_generateQTESequence.sqf | 0 .../fnc_getFormattedQTESequence.sqf | 0 .../fnc_keyPressedQTE.sqf | 4 ++-- addons/{common => quicktime}/fnc_runQTE.sqf | 4 ++-- addons/quicktime/script_component.hpp | 20 ++++++++++++++++ addons/quicktime/stringtable.xml | 20 ++++++++++++++++ 16 files changed, 116 insertions(+), 44 deletions(-) create mode 100644 addons/quicktime/$PBOPREFIX$ create mode 100644 addons/quicktime/CfgEventHandlers.hpp create mode 100644 addons/quicktime/CfgFunctions.hpp create mode 100644 addons/quicktime/XEH_preInit.sqf create mode 100644 addons/quicktime/XEH_preStart.sqf create mode 100644 addons/quicktime/config.cpp rename addons/{common => quicktime}/fnc_generateQTESequence.sqf (100%) rename addons/{common => quicktime}/fnc_getFormattedQTESequence.sqf (100%) rename addons/{common => quicktime}/fnc_keyPressedQTE.sqf (91%) rename addons/{common => quicktime}/fnc_runQTE.sqf (97%) create mode 100644 addons/quicktime/script_component.hpp create mode 100644 addons/quicktime/stringtable.xml diff --git a/addons/common/CfgFunctions.hpp b/addons/common/CfgFunctions.hpp index 42e59ca1b..9366f9803 100644 --- a/addons/common/CfgFunctions.hpp +++ b/addons/common/CfgFunctions.hpp @@ -141,12 +141,5 @@ class CfgFunctions { class Broken { PATHTO_FNC(actionArgument); }; - - class QuickTimeEvent { - PATHTO_FNC(generateQTESequence); - PATHTO_FNC(getFormattedQTESequence); - PATHTO_FNC(runQTE); - PATHTO_FNC(keyPressedQTE); - }; }; }; diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 0a323ce4f..e8a9f107f 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -1,6 +1,6 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" -#include "\a3\ui_f\hpp\defineDIKCodes.inc" + SCRIPT(XEH_preInit); LOG(MSG_INIT); @@ -79,19 +79,3 @@ activateAddons GVAR(addons); ["CAManBase", "InitPost", CBA_fnc_randomizeFacewear] call CBA_fnc_addClassEventHandler; ADDON = true; - -[ELSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { - ["↑"] call CBA_fnc_keyPressedQTE; -}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; - -[ELSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { - ["↓"] call CBA_fnc_keyPressedQTE; -}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; - -[ELSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { - ["←"] call CBA_fnc_keyPressedQTE; -}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; - -[ELSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], {}, { - ["→"] call CBA_fnc_keyPressedQTE; -}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 7c6410100..a81dca8ea 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -43,20 +43,5 @@ CBA Оружие CBA 무기 - - CBA Quick-Time Events - - - Up key used in Quick-Time Events. - - - Down key used in Quick-Time Events. - - - Left key used in Quick-Time Events. - - - Right key used in Quick-Time Events. - diff --git a/addons/main/config.cpp b/addons/main/config.cpp index f753e1b55..bc04591e6 100644 --- a/addons/main/config.cpp +++ b/addons/main/config.cpp @@ -31,7 +31,8 @@ class CfgPatches { "cba_ui", "cba_versioning", "cba_optics", - "cba_disposable" + "cba_disposable", + "cba_quicktime" }; author = "$STR_CBA_Author"; authors[] = {}; diff --git a/addons/quicktime/$PBOPREFIX$ b/addons/quicktime/$PBOPREFIX$ new file mode 100644 index 000000000..d8afc5cdf --- /dev/null +++ b/addons/quicktime/$PBOPREFIX$ @@ -0,0 +1 @@ +x\cba\addons\quicktime diff --git a/addons/quicktime/CfgEventHandlers.hpp b/addons/quicktime/CfgEventHandlers.hpp new file mode 100644 index 000000000..29494ba1a --- /dev/null +++ b/addons/quicktime/CfgEventHandlers.hpp @@ -0,0 +1,12 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; + diff --git a/addons/quicktime/CfgFunctions.hpp b/addons/quicktime/CfgFunctions.hpp new file mode 100644 index 000000000..2287ab086 --- /dev/null +++ b/addons/quicktime/CfgFunctions.hpp @@ -0,0 +1,10 @@ +class CfgFunctions { + class CBA { + class QuickTimeEvent { + PATHTO_FNC(generateQTESequence); + PATHTO_FNC(getFormattedQTESequence); + PATHTO_FNC(runQTE); + PATHTO_FNC(keyPressedQTE); + }; + }; +}; diff --git a/addons/quicktime/XEH_preInit.sqf b/addons/quicktime/XEH_preInit.sqf new file mode 100644 index 000000000..dc5ade1a6 --- /dev/null +++ b/addons/quicktime/XEH_preInit.sqf @@ -0,0 +1,24 @@ +#include "script_component.hpp" +#include "\a3\ui_f\hpp\defineDIKCodes.inc" + +SCRIPT(XEH_preInit); + +ADDON = false; + +[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { + ["↑"] call CBA_fnc_keyPressedQTE; +}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; + +[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { + ["↓"] call CBA_fnc_keyPressedQTE; +}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; + +[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { + ["←"] call CBA_fnc_keyPressedQTE; +}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; + +[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], {}, { + ["→"] call CBA_fnc_keyPressedQTE; +}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; + +ADDON = true; diff --git a/addons/quicktime/XEH_preStart.sqf b/addons/quicktime/XEH_preStart.sqf new file mode 100644 index 000000000..84dccabbb --- /dev/null +++ b/addons/quicktime/XEH_preStart.sqf @@ -0,0 +1,4 @@ +#include "script_component.hpp" + + + diff --git a/addons/quicktime/config.cpp b/addons/quicktime/config.cpp new file mode 100644 index 000000000..2c732eb0a --- /dev/null +++ b/addons/quicktime/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = CSTRING(component); + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"cba_common","cba_events"}; + author = "$STR_CBA_Author"; + authors[] = {"john681611"}; + url = "$STR_CBA_URL"; + VERSION_CONFIG; + }; +}; + +#include "CfgFunctions.hpp" +#include "CfgEventHandlers.hpp" diff --git a/addons/common/fnc_generateQTESequence.sqf b/addons/quicktime/fnc_generateQTESequence.sqf similarity index 100% rename from addons/common/fnc_generateQTESequence.sqf rename to addons/quicktime/fnc_generateQTESequence.sqf diff --git a/addons/common/fnc_getFormattedQTESequence.sqf b/addons/quicktime/fnc_getFormattedQTESequence.sqf similarity index 100% rename from addons/common/fnc_getFormattedQTESequence.sqf rename to addons/quicktime/fnc_getFormattedQTESequence.sqf diff --git a/addons/common/fnc_keyPressedQTE.sqf b/addons/quicktime/fnc_keyPressedQTE.sqf similarity index 91% rename from addons/common/fnc_keyPressedQTE.sqf rename to addons/quicktime/fnc_keyPressedQTE.sqf index 3907eaf48..ed9082193 100644 --- a/addons/common/fnc_keyPressedQTE.sqf +++ b/addons/quicktime/fnc_keyPressedQTE.sqf @@ -27,8 +27,8 @@ if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { private _args = GVAR(QTEArgs) get "args"; -private _qteSequence = GVAR(QTEArgs) get "qte_seqence"; -private _elapsedTime = CBA_missionTime - GVAR(QTEArgs) get "start_time"; +private _qteSequence = GVAR(QTEArgs) get "qteSeqence"; +private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); GVAR(QTEHistory) pushBack _eventQTE; diff --git a/addons/common/fnc_runQTE.sqf b/addons/quicktime/fnc_runQTE.sqf similarity index 97% rename from addons/common/fnc_runQTE.sqf rename to addons/quicktime/fnc_runQTE.sqf index 29f5fde64..13af395f6 100644 --- a/addons/common/fnc_runQTE.sqf +++ b/addons/quicktime/fnc_runQTE.sqf @@ -8,7 +8,7 @@ Description: Parameters: _object - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qte_history]. + _onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qteHistory]. _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. _qteSequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] @@ -56,7 +56,7 @@ private _qteArgsArray = [ ["onFinish", _onFinish], ["onFail", _onFail], ["maxDistance", _maxDistance], - ["qte_seqence", _qteSequence], + ["qteSeqence", _qteSequence], ["startTime", _startTime], ["timeout", _timeout] ]; diff --git a/addons/quicktime/script_component.hpp b/addons/quicktime/script_component.hpp new file mode 100644 index 000000000..50e9e57e9 --- /dev/null +++ b/addons/quicktime/script_component.hpp @@ -0,0 +1,20 @@ +#define COMPONENT quicktime +#include "\x\cba\addons\main\script_mod.hpp" + +//#define DEBUG_MODE_FULL +//#define DISABLE_COMPILE_CACHE +//#define DEBUG_ENABLED_quicktime + +#ifdef DEBUG_ENABLED_QUICKTIME + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_QUICKTIME + #define DEBUG_SETTINGS DEBUG_SETTINGS_QUICKTIME +#endif + +#define DEBUG_SYNCHRONOUS +#include "\x\cba\addons\main\script_macros.hpp" + +#include "\a3\ui_f\hpp\defineResincl.inc" + diff --git a/addons/quicktime/stringtable.xml b/addons/quicktime/stringtable.xml new file mode 100644 index 000000000..ca28777d3 --- /dev/null +++ b/addons/quicktime/stringtable.xml @@ -0,0 +1,20 @@ + + + + + CBA Quick-Time Events + + + Up key used in Quick-Time Events. + + + Down key used in Quick-Time Events. + + + Left key used in Quick-Time Events. + + + Right key used in Quick-Time Events. + + + From 6d2f3fe6ac3ff5138fcb20b47aa44399fae9a39f Mon Sep 17 00:00:00 2001 From: john681611 Date: Wed, 1 May 2024 00:28:47 +0100 Subject: [PATCH 25/30] minor fixes --- addons/common/XEH_preInit.sqf | 1 - addons/quicktime/XEH_preInit.sqf | 24 ++++++++++++------------ addons/quicktime/XEH_preStart.sqf | 3 --- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index e8a9f107f..f75233a19 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -1,6 +1,5 @@ //#define DEBUG_MODE_FULL #include "script_component.hpp" - SCRIPT(XEH_preInit); LOG(MSG_INIT); diff --git a/addons/quicktime/XEH_preInit.sqf b/addons/quicktime/XEH_preInit.sqf index dc5ade1a6..bb024d410 100644 --- a/addons/quicktime/XEH_preInit.sqf +++ b/addons/quicktime/XEH_preInit.sqf @@ -5,20 +5,20 @@ SCRIPT(XEH_preInit); ADDON = false; -[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], {}, { - ["↑"] call CBA_fnc_keyPressedQTE; -}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], { + ["↑"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], {}, { - ["↓"] call CBA_fnc_keyPressedQTE; -}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], { + ["↓"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { - ["←"] call CBA_fnc_keyPressedQTE; -}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { + ["←"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; -[ELSTRING(quicktime,QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], {}, { - ["→"] call CBA_fnc_keyPressedQTE; -}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; +[LSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], { + ["→"] call CBA_fnc_keyPressedQTE // return +}, {}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; ADDON = true; diff --git a/addons/quicktime/XEH_preStart.sqf b/addons/quicktime/XEH_preStart.sqf index 84dccabbb..421c54b49 100644 --- a/addons/quicktime/XEH_preStart.sqf +++ b/addons/quicktime/XEH_preStart.sqf @@ -1,4 +1 @@ #include "script_component.hpp" - - - From 60247041b910d400887a202dfda24c020876ed2a Mon Sep 17 00:00:00 2001 From: john681611 Date: Wed, 1 May 2024 00:33:23 +0100 Subject: [PATCH 26/30] Fix sneaky keybind error --- addons/quicktime/XEH_preInit.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/quicktime/XEH_preInit.sqf b/addons/quicktime/XEH_preInit.sqf index bb024d410..35e547495 100644 --- a/addons/quicktime/XEH_preInit.sqf +++ b/addons/quicktime/XEH_preInit.sqf @@ -13,7 +13,7 @@ ADDON = false; ["↓"] call CBA_fnc_keyPressedQTE // return }, {}, [DIK_DOWN, [false, true, false]]] call CBA_fnc_addKeybind; -[LSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], {}, { +[LSTRING(QTEKeybindGroup), QGVAR(qteLeftKey), ["←", LSTRING(QTEKeybindLeftTooltip)], { ["←"] call CBA_fnc_keyPressedQTE // return }, {}, [DIK_LEFT, [false, true, false]]] call CBA_fnc_addKeybind; From 8e236f2f42ca224197fb2ec3c79fe5dbf4982493 Mon Sep 17 00:00:00 2001 From: john681611 Date: Sun, 5 May 2024 16:15:55 +0100 Subject: [PATCH 27/30] Review comment improvements --- addons/quicktime/CfgEventHandlers.hpp | 6 ------ addons/quicktime/CfgFunctions.hpp | 2 +- addons/quicktime/XEH_preStart.sqf | 1 - addons/quicktime/fnc_keyPressedQTE.sqf | 5 +++-- addons/quicktime/fnc_runQTE.sqf | 13 ++++++------- 5 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 addons/quicktime/XEH_preStart.sqf diff --git a/addons/quicktime/CfgEventHandlers.hpp b/addons/quicktime/CfgEventHandlers.hpp index 29494ba1a..d863ae661 100644 --- a/addons/quicktime/CfgEventHandlers.hpp +++ b/addons/quicktime/CfgEventHandlers.hpp @@ -1,9 +1,3 @@ -class Extended_PreStart_EventHandlers { - class ADDON { - init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); - }; -}; - class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); diff --git a/addons/quicktime/CfgFunctions.hpp b/addons/quicktime/CfgFunctions.hpp index 2287ab086..6e3f0ca67 100644 --- a/addons/quicktime/CfgFunctions.hpp +++ b/addons/quicktime/CfgFunctions.hpp @@ -3,8 +3,8 @@ class CfgFunctions { class QuickTimeEvent { PATHTO_FNC(generateQTESequence); PATHTO_FNC(getFormattedQTESequence); - PATHTO_FNC(runQTE); PATHTO_FNC(keyPressedQTE); + PATHTO_FNC(runQTE); }; }; }; diff --git a/addons/quicktime/XEH_preStart.sqf b/addons/quicktime/XEH_preStart.sqf deleted file mode 100644 index 421c54b49..000000000 --- a/addons/quicktime/XEH_preStart.sqf +++ /dev/null @@ -1 +0,0 @@ -#include "script_component.hpp" diff --git a/addons/quicktime/fnc_keyPressedQTE.sqf b/addons/quicktime/fnc_keyPressedQTE.sqf index ed9082193..03269e417 100644 --- a/addons/quicktime/fnc_keyPressedQTE.sqf +++ b/addons/quicktime/fnc_keyPressedQTE.sqf @@ -27,12 +27,12 @@ if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { private _args = GVAR(QTEArgs) get "args"; -private _qteSequence = GVAR(QTEArgs) get "qteSeqence"; +private _qteSequence = GVAR(QTEArgs) get "qteSequence"; private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); GVAR(QTEHistory) pushBack _eventQTE; - +// Check if the input corresponds to the sequence if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { GVAR(QTEHistory) = []; GVAR(QTERunning) = false; @@ -46,6 +46,7 @@ if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { true }; +// If the user failed an input, wipe the previous input from memory if (GVAR(QTEHistory) isNotEqualTo (_qteSequence select [0, count GVAR(QTEHistory)])) then { GVAR(QTEHistory) = []; }; diff --git a/addons/quicktime/fnc_runQTE.sqf b/addons/quicktime/fnc_runQTE.sqf index 13af395f6..34428e63b 100644 --- a/addons/quicktime/fnc_runQTE.sqf +++ b/addons/quicktime/fnc_runQTE.sqf @@ -39,13 +39,12 @@ Returns: Author: john681611 ---------------------------------------------------------------------------- */ - - -params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qteSequence", ["_maxDistance", 10], ["_timeout", 30]]; -if (GVAR(QTERunning)) exitWith { +if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { false }; +params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qteSequence", ["_maxDistance", 10], ["_timeout", 30]]; + GVAR(QTEHistory) = []; GVAR(QTERunning) = true; private _startTime = CBA_missionTime; @@ -56,7 +55,7 @@ private _qteArgsArray = [ ["onFinish", _onFinish], ["onFail", _onFail], ["maxDistance", _maxDistance], - ["qteSeqence", _qteSequence], + ["qteSequence", _qteSequence], ["startTime", _startTime], ["timeout", _timeout] ]; @@ -75,8 +74,8 @@ GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; if(!GVAR(QTERunning)) exitWith {}; GVAR(QTERunning) = false; GVAR(QTEHistory) = []; - private _onFail = (GVAR(QTEArgs) get "onFail"); - private _args = (GVAR(QTEArgs) get "args"); + private _onFail = GVAR(QTEArgs) get "onFail"; + private _args = GVAR(QTEArgs) get "args"; TRACE_1("QTE Failed",_args); if (_onFail isEqualType "") then { [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; From 83ca39fc96872f62f059a835f4dea7afce6d2e20 Mon Sep 17 00:00:00 2001 From: john681611 Date: Sun, 5 May 2024 17:36:59 +0100 Subject: [PATCH 28/30] Use more generic condition and reset counter --- addons/quicktime/fnc_keyPressedQTE.sqf | 9 ++-- addons/quicktime/fnc_runQTE.sqf | 64 +++++++++++++++----------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/addons/quicktime/fnc_keyPressedQTE.sqf b/addons/quicktime/fnc_keyPressedQTE.sqf index 03269e417..b9f041823 100644 --- a/addons/quicktime/fnc_keyPressedQTE.sqf +++ b/addons/quicktime/fnc_keyPressedQTE.sqf @@ -39,9 +39,9 @@ if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { TRACE_1("QTE Completed",_elapsedTime); private _onFinish = GVAR(QTEArgs) get "onFinish"; if (_onFinish isEqualType "") then { - [_onFinish, [_args, _elapsedTime]] call CBA_fnc_localEvent; + [_onFinish, [_args, _elapsedTime, GVAR(QTEResetCount)]] call CBA_fnc_localEvent; } else { - [_args, _elapsedTime] call _onFinish; + [_args, _elapsedTime, GVAR(QTEResetCount)] call _onFinish; }; true }; @@ -49,13 +49,14 @@ if (GVAR(QTEHistory) isEqualTo _qteSequence) exitWith { // If the user failed an input, wipe the previous input from memory if (GVAR(QTEHistory) isNotEqualTo (_qteSequence select [0, count GVAR(QTEHistory)])) then { GVAR(QTEHistory) = []; + GVAR(QTEResetCount) = GVAR(QTEResetCount) + 1; }; private _onDisplay = GVAR(QTEArgs) get "onDisplay"; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qteSequence, GVAR(QTEHistory)]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qteSequence, GVAR(QTEHistory), GVAR(QTEResetCount)]] call CBA_fnc_localEvent; } else { - [_args, _qteSequence, GVAR(QTEHistory)] call _onDisplay; + [_args, _qteSequence, GVAR(QTEHistory), GVAR(QTEResetCount)] call _onDisplay; }; true diff --git a/addons/quicktime/fnc_runQTE.sqf b/addons/quicktime/fnc_runQTE.sqf index 34428e63b..03f8a2c1c 100644 --- a/addons/quicktime/fnc_runQTE.sqf +++ b/addons/quicktime/fnc_runQTE.sqf @@ -6,30 +6,35 @@ Description: Runs a Quick-Time Event. Parameters: - _object - _args - Extra arguments passed to the _on... functions - _onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qteHistory]. - _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime]. - _onFinish - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime]. + _failCondition - Code condition to fail the Quick-Time Event passed [_args, _elapsedTime, _resetCount]. (default: {false}) + _onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qteHistory, _resetCount]. + _onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime, _resetCount]. + _onFail - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime, _resetCount]. _qteSequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] - _maxDistance - max interaction distance from attached object (default: 10) - _timeout - ingame timeout (default: 30) Example: [car, - [], + { + params ["_args", "_elapsedTime", "_resetCount"]; + player distance _args > 10 || _elapsedTime > 10 || _resetCount > 3; + }, { + params ["_args", "_qteSequence", "_qteHistory", "_resetCount"]; hint format [ - "%1 \n %2", - [_this select 1] call CBA_fnc_getFormattedQTESequence, - [_this select 2] call CBA_fnc_getFormattedQTESequence + "%3/3 \n %1 \n %2", + [_qteSequence] call CBA_fnc_getFormattedQTESequence, + [_qteHistory] call CBA_fnc_getFormattedQTESequence, + _resetCount ] }, { - hint "Finished!"; + params ["_args", "_elapsedTime", "_resetCount"]; + hint format ["Finished! %1s %2", _elapsedTime, _resetCount]; }, - { - hint "Failure!"; + { + params ["_args", "_elapsedTime", "_resetCount"]; + hint format ["Failure! %1s %2", _elapsedTime, _resetCount]; }, ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE @@ -39,36 +44,42 @@ Returns: Author: john681611 ---------------------------------------------------------------------------- */ -if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { +if (missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { false }; -params ["_object", "_args", "_onDisplay", "_onFinish", "_onFail", "_qteSequence", ["_maxDistance", 10], ["_timeout", 30]]; +params [ + "_args", + ["_failCondition",{false}, ["", {}]], + ["_onDisplay",{}, ["", {}]], + ["_onFinish",{}, ["", {}]], + ["_onFail",{}, ["", {}]], + ["_qteSequence", [], [[]]] +]; GVAR(QTEHistory) = []; +GVAR(QTEResetCount) = 0; GVAR(QTERunning) = true; private _startTime = CBA_missionTime; private _qteArgsArray = [ - ["object", _object], ["args", _args], + ["failCondition", _failCondition], ["onDisplay", _onDisplay], ["onFinish", _onFinish], ["onFail", _onFail], ["maxDistance", _maxDistance], ["qteSequence", _qteSequence], - ["startTime", _startTime], - ["timeout", _timeout] + ["startTime", _startTime] ]; GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; // Setup [{ - private _timeout = GVAR(QTEArgs) get "timeout"; - private _object = GVAR(QTEArgs) get "object"; - private _maxDistance = GVAR(QTEArgs) get "maxDistance"; + private _args = GVAR(QTEArgs) get "args"; + private _failCondition = GVAR(QTEArgs) get "failCondition"; private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); - !GVAR(QTERunning) || player distance _object > _maxDistance || _elapsedTime > _timeout; + !GVAR(QTERunning) || [_args, _elapsedTime, GVAR(QTEResetCount)] call _failCondition; }, { TRACE_1("QTE ended",GVAR(QTERunning)); if(!GVAR(QTERunning)) exitWith {}; @@ -76,18 +87,19 @@ GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; GVAR(QTEHistory) = []; private _onFail = GVAR(QTEArgs) get "onFail"; private _args = GVAR(QTEArgs) get "args"; + private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); TRACE_1("QTE Failed",_args); if (_onFail isEqualType "") then { - [_onFail, [_args, _elapsedTime]] call CBA_fnc_localEvent; + [_onFail, [_args, _elapsedTime, GVAR(QTEResetCount)]] call CBA_fnc_localEvent; } else { - [_args, _elapsedTime] call _onFail; + [_args, _elapsedTime, GVAR(QTEResetCount)] call _onFail; }; }, []] call CBA_fnc_waitUntilAndExecute; if (_onDisplay isEqualType "") then { - [_onDisplay, [_args, _qteSequence, []]] call CBA_fnc_localEvent; + [_onDisplay, [_args, _qteSequence, [], GVAR(QTEResetCount)]] call CBA_fnc_localEvent; } else { - [_args, _qteSequence, []] call _onDisplay; + [_args, _qteSequence, [], GVAR(QTEResetCount)] call _onDisplay; }; true From 46d200d758ac11a2a4067262c66ad006706be34c Mon Sep 17 00:00:00 2001 From: John Harvey <10814889+john681611@users.noreply.github.com> Date: Mon, 24 Jun 2024 09:27:33 +0100 Subject: [PATCH 29/30] Update addons/quicktime/fnc_runQTE.sqf Co-authored-by: Mike-MF --- addons/quicktime/fnc_runQTE.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/quicktime/fnc_runQTE.sqf b/addons/quicktime/fnc_runQTE.sqf index 03f8a2c1c..b7977d31c 100644 --- a/addons/quicktime/fnc_runQTE.sqf +++ b/addons/quicktime/fnc_runQTE.sqf @@ -39,7 +39,7 @@ Example: ["↑", "↓", "→", "←"]] call CBA_fnc_runQTE Returns: - True if the QTE was started, false if it was already running + True if the QTE was started, false if it was already running Author: john681611 From 91e2722e93f08e51f3b001de69b5607691477d7d Mon Sep 17 00:00:00 2001 From: john681611 Date: Mon, 2 Dec 2024 20:15:48 +0000 Subject: [PATCH 30/30] Implement Single Key press as Accessability option --- addons/quicktime/XEH_preInit.sqf | 2 ++ addons/quicktime/fnc_runQTE.sqf | 3 +++ addons/quicktime/initSettings.inc.sqf | 9 +++++++++ addons/quicktime/stringtable.xml | 9 +++++++++ 4 files changed, 23 insertions(+) create mode 100644 addons/quicktime/initSettings.inc.sqf diff --git a/addons/quicktime/XEH_preInit.sqf b/addons/quicktime/XEH_preInit.sqf index 35e547495..028c6737d 100644 --- a/addons/quicktime/XEH_preInit.sqf +++ b/addons/quicktime/XEH_preInit.sqf @@ -5,6 +5,8 @@ SCRIPT(XEH_preInit); ADDON = false; +#include "initSettings.inc.sqf" + [LSTRING(QTEKeybindGroup), QGVAR(qteUpKey), ["↑", LSTRING(QTEKeybindUpTooltip)], { ["↑"] call CBA_fnc_keyPressedQTE // return }, {}, [DIK_UP, [false, true, false]]] call CBA_fnc_addKeybind; diff --git a/addons/quicktime/fnc_runQTE.sqf b/addons/quicktime/fnc_runQTE.sqf index b7977d31c..1a51c6356 100644 --- a/addons/quicktime/fnc_runQTE.sqf +++ b/addons/quicktime/fnc_runQTE.sqf @@ -61,6 +61,9 @@ GVAR(QTEHistory) = []; GVAR(QTEResetCount) = 0; GVAR(QTERunning) = true; private _startTime = CBA_missionTime; +if(GVAR(qteShorten)) then { + _qteSequence = _qteSequence select [0, 1]; +}; private _qteArgsArray = [ ["args", _args], ["failCondition", _failCondition], diff --git a/addons/quicktime/initSettings.inc.sqf b/addons/quicktime/initSettings.inc.sqf new file mode 100644 index 000000000..6d1826811 --- /dev/null +++ b/addons/quicktime/initSettings.inc.sqf @@ -0,0 +1,9 @@ +[ + QGVAR(qteShorten), + "CHECKBOX", + [LLSTRING(QTEAccessabilitySingleKey), LLSTRING(QTEAccessabilitySingleKeyTooltip)], + [LELSTRING(main,DisplayName), LLSTRING(QTETitle)], + false, // default value + 0 // isGlobal +] call CBA_fnc_addSetting; + diff --git a/addons/quicktime/stringtable.xml b/addons/quicktime/stringtable.xml index ca28777d3..e784c5489 100644 --- a/addons/quicktime/stringtable.xml +++ b/addons/quicktime/stringtable.xml @@ -1,6 +1,9 @@ + + Quick-Time Events + CBA Quick-Time Events @@ -16,5 +19,11 @@ Right key used in Quick-Time Events. + + Single Key press + + + When enabled, all Quick-Time Events will be shortened to a single key press. +