-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added: QTE Framework #1649
Open
john681611
wants to merge
33
commits into
CBATeam:master
Choose a base branch
from
john681611:quickTimeEvents
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added: QTE Framework #1649
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
ea657b5
Added: QTE Framework
john681611 964cefe
Update addons/common/fnc_generateQTESequence.sqf
john681611 45929cd
refactor to use Keybinds
john681611 bfa6ea8
Merge branch 'quickTimeEvents' of github.com:john681611/CBA_A3 into q…
john681611 3576e8e
Fix null issue on key press
john681611 dbc5abe
review improvements
john681611 d35bfb8
Support localization
john681611 986d828
Update addons/common/XEH_preInit.sqf
john681611 26529cc
Update addons/common/fnc_generateQTESequence.sqf
john681611 5255969
Update addons/common/fnc_keyPressedQTE.sqf
john681611 96806a9
Update addons/common/fnc_runQTE.sqf
john681611 6597fc8
Update addons/common/stringtable.xml
john681611 9feffc8
Update addons/common/fnc_keyPressedQTE.sqf
john681611 c851040
Update addons/common/fnc_keyPressedQTE.sqf
john681611 68c586b
Update addons/common/fnc_keyPressedQTE.sqf
john681611 f48ebaa
review comments
john681611 d99bb4f
minor improvements
john681611 97fc243
Update addons/common/fnc_keyPressedQTE.sqf
john681611 29f9f11
Update addons/common/fnc_runQTE.sqf
john681611 1fbb063
Update addons/common/fnc_runQTE.sqf
john681611 c8e951b
Update addons/common/fnc_runQTE.sqf
john681611 24bf821
Update addons/common/fnc_runQTE.sqf
john681611 9eb7b18
format: camelcasing
john681611 7dc983f
Merge branch 'quickTimeEvents' of github.com:john681611/CBA_A3 into q…
john681611 a22d373
Update addons/common/XEH_preInit.sqf
john681611 9a6cfb2
migrate to quicktime component
john681611 976eca3
Merge branch 'quickTimeEvents' of github.com:john681611/CBA_A3 into q…
john681611 6d2f3fe
minor fixes
john681611 6024704
Fix sneaky keybind error
john681611 8e236f2
Review comment improvements
john681611 83ca39f
Use more generic condition and reset counter
john681611 46d200d
Update addons/quicktime/fnc_runQTE.sqf
john681611 91e2722
Implement Single Key press as Accessability option
john681611 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
x\cba\addons\quicktime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Extended_PreInit_EventHandlers { | ||
class ADDON { | ||
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CfgFunctions { | ||
class CBA { | ||
class QuickTimeEvent { | ||
PATHTO_FNC(generateQTESequence); | ||
PATHTO_FNC(getFormattedQTESequence); | ||
PATHTO_FNC(keyPressedQTE); | ||
PATHTO_FNC(runQTE); | ||
}; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "script_component.hpp" | ||
#include "\a3\ui_f\hpp\defineDIKCodes.inc" | ||
|
||
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; | ||
|
||
[LSTRING(QTEKeybindGroup), QGVAR(qteDownKey), ["↓", LSTRING(QTEKeybindDownTooltip)], { | ||
["↓"] call CBA_fnc_keyPressedQTE // return | ||
}, {}, [DIK_DOWN, [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; | ||
|
||
[LSTRING(QTEKeybindGroup), QGVAR(qteRightKey), ["→", LSTRING(QTEKeybindRightTooltip)], { | ||
["→"] call CBA_fnc_keyPressedQTE // return | ||
}, {}, [DIK_RIGHT, [false, true, false]]] call CBA_fnc_addKeybind; | ||
|
||
ADDON = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_generateQTESequence | ||
|
||
Description: | ||
Generate a Quick-Time sequence of a given length. | ||
|
||
Parameters: | ||
_length - Length of QTE sequence <NUMBER> | ||
|
||
Example: | ||
[5] call CBA_fnc_generateQTESequence; | ||
|
||
Returns: | ||
Quick-Time sequence of requested length made up of ["↑", "↓", "→", "←"] <ARRAY> | ||
|
||
Author: | ||
john681611 | ||
---------------------------------------------------------------------------- */ | ||
|
||
params [["_length", 0, [0]]]; | ||
|
||
if (_length <= 0) exitWith {[]}; | ||
|
||
private _code = []; | ||
|
||
for "_i" from 0 to _length do { | ||
_code pushBack (selectRandom ["↑", "↓", "→", "←"]); | ||
}; | ||
|
||
_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getFormattedQTESequence | ||
|
||
Description: | ||
Formats Quick-Time sequence into a displayable string. | ||
|
||
Parameters: | ||
_code - Quick-Time sequence <ARRAY> | ||
|
||
|
||
Example: | ||
[["↑", "↓", "→", "←"]] call CBA_fnc_getFormattedQTESequence; | ||
|
||
Returns: | ||
Formatted Quick-Time sequence <STRING> | ||
|
||
Author: | ||
john681611 | ||
---------------------------------------------------------------------------- */ | ||
|
||
params ["_code"]; | ||
|
||
_code joinString " " // Arma doesn't know how to space ↑ so we need loads of spaces between |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_keyPressedQTE | ||
|
||
Description: | ||
Process Quick-Time Key Press | ||
|
||
Parameters: | ||
_eventQTE - Character to test against Quick-Time Event <STRING> | ||
|
||
Example: | ||
["↑"] call CBA_fnc_keyPressedQTE; | ||
|
||
Returns: | ||
True if QTE is running <BOOLEAN> | ||
|
||
Author: | ||
john681611 | ||
---------------------------------------------------------------------------- */ | ||
|
||
|
||
params ["_eventQTE"]; | ||
|
||
if !(missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { | ||
false | ||
}; | ||
|
||
|
||
private _args = GVAR(QTEArgs) get "args"; | ||
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; | ||
TRACE_1("QTE Completed",_elapsedTime); | ||
private _onFinish = GVAR(QTEArgs) get "onFinish"; | ||
if (_onFinish isEqualType "") then { | ||
[_onFinish, [_args, _elapsedTime, GVAR(QTEResetCount)]] call CBA_fnc_localEvent; | ||
} else { | ||
[_args, _elapsedTime, GVAR(QTEResetCount)] call _onFinish; | ||
}; | ||
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) = []; | ||
GVAR(QTEResetCount) = GVAR(QTEResetCount) + 1; | ||
}; | ||
|
||
private _onDisplay = GVAR(QTEArgs) get "onDisplay"; | ||
if (_onDisplay isEqualType "") then { | ||
[_onDisplay, [_args, _qteSequence, GVAR(QTEHistory), GVAR(QTEResetCount)]] call CBA_fnc_localEvent; | ||
} else { | ||
[_args, _qteSequence, GVAR(QTEHistory), GVAR(QTEResetCount)] call _onDisplay; | ||
}; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#include "script_component.hpp" | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_runQTE | ||
|
||
Description: | ||
Runs a Quick-Time Event. | ||
|
||
Parameters: | ||
_args - Extra arguments passed to the _on... functions<ARRAY> | ||
_failCondition - Code condition to fail the Quick-Time Event passed [_args, _elapsedTime, _resetCount]. <CODE, STRING> (default: {false}) | ||
_onDisplay - Code callback on displayable event passed [_args, _qteSequence, _qteHistory, _resetCount]. <CODE, STRING> | ||
_onFinish - Code callback on Quick-Time Event completed passed [_args, _elapsedTime, _resetCount]. <CODE, STRING> | ||
_onFail - Code callback on Quick-Time Event timeout/outranged passed [_args, _elapsedTime, _resetCount]. <CODE, STRING> | ||
_qteSequence - Quick-Time sequence made up of ["↑", "↓", "→", "←"] <ARRAY> | ||
|
||
Example: | ||
[car, | ||
{ | ||
params ["_args", "_elapsedTime", "_resetCount"]; | ||
player distance _args > 10 || _elapsedTime > 10 || _resetCount > 3; | ||
}, | ||
{ | ||
params ["_args", "_qteSequence", "_qteHistory", "_resetCount"]; | ||
hint format [ | ||
"%3/3 \n %1 \n %2", | ||
[_qteSequence] call CBA_fnc_getFormattedQTESequence, | ||
[_qteHistory] call CBA_fnc_getFormattedQTESequence, | ||
_resetCount | ||
] | ||
}, | ||
{ | ||
params ["_args", "_elapsedTime", "_resetCount"]; | ||
hint format ["Finished! %1s %2", _elapsedTime, _resetCount]; | ||
}, | ||
{ | ||
params ["_args", "_elapsedTime", "_resetCount"]; | ||
hint format ["Failure! %1s %2", _elapsedTime, _resetCount]; | ||
}, | ||
["↑", "↓", "→", "←"]] call CBA_fnc_runQTE | ||
|
||
Returns: | ||
True if the QTE was started, false if it was already running <BOOLEAN> | ||
|
||
Author: | ||
john681611 | ||
---------------------------------------------------------------------------- */ | ||
if (missionNamespace getVariable [QGVAR(QTERunning), false]) exitWith { | ||
false | ||
}; | ||
|
||
params [ | ||
"_args", | ||
["_failCondition",{false}, ["", {}]], | ||
["_onDisplay",{}, ["", {}]], | ||
["_onFinish",{}, ["", {}]], | ||
["_onFail",{}, ["", {}]], | ||
["_qteSequence", [], [[]]] | ||
]; | ||
|
||
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], | ||
["onDisplay", _onDisplay], | ||
["onFinish", _onFinish], | ||
["onFail", _onFail], | ||
["maxDistance", _maxDistance], | ||
["qteSequence", _qteSequence], | ||
["startTime", _startTime] | ||
]; | ||
GVAR(QTEArgs) = createHashMapFromArray _qteArgsArray; | ||
|
||
// Setup | ||
[{ | ||
private _args = GVAR(QTEArgs) get "args"; | ||
private _failCondition = GVAR(QTEArgs) get "failCondition"; | ||
private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); | ||
|
||
!GVAR(QTERunning) || [_args, _elapsedTime, GVAR(QTEResetCount)] call _failCondition; | ||
}, { | ||
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"; | ||
private _elapsedTime = CBA_missionTime - (GVAR(QTEArgs) get "startTime"); | ||
TRACE_1("QTE Failed",_args); | ||
if (_onFail isEqualType "") then { | ||
[_onFail, [_args, _elapsedTime, GVAR(QTEResetCount)]] call CBA_fnc_localEvent; | ||
} else { | ||
[_args, _elapsedTime, GVAR(QTEResetCount)] call _onFail; | ||
}; | ||
}, []] call CBA_fnc_waitUntilAndExecute; | ||
|
||
if (_onDisplay isEqualType "") then { | ||
[_onDisplay, [_args, _qteSequence, [], GVAR(QTEResetCount)]] call CBA_fnc_localEvent; | ||
} else { | ||
[_args, _qteSequence, [], GVAR(QTEResetCount)] call _onDisplay; | ||
}; | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project name="CBA_A3"> | ||
<Package name="Quicktime"> | ||
<Key ID="STR_cba_quicktime_QTETitle"> | ||
<English>Quick-Time Events</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEKeybindGroup"> | ||
<English>CBA Quick-Time Events</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEKeybindUpTooltip"> | ||
<English>Up key used in Quick-Time Events.</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEKeybindDownTooltip"> | ||
<English>Down key used in Quick-Time Events.</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEKeybindLeftTooltip"> | ||
<English>Left key used in Quick-Time Events.</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEKeybindRightTooltip"> | ||
<English>Right key used in Quick-Time Events.</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEAccessabilitySingleKey"> | ||
<English>Single Key press</English> | ||
</Key> | ||
<Key ID="STR_cba_quicktime_QTEAccessabilitySingleKeyTooltip"> | ||
<English>When enabled, all Quick-Time Events will be shortened to a single key press.</English> | ||
</Key> | ||
</Package> | ||
</Project> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.