Convert finger to CBA hashes (#4183)

This commit is contained in:
PabstMirror 2016-07-30 12:28:07 -05:00 committed by GitHub
parent 46adfe1150
commit a2f391cd59
3 changed files with 16 additions and 14 deletions

View File

@ -2,14 +2,15 @@
if (!hasInterface) exitWith {};
GVAR(lastFPTime) = -1;
GVAR(fingersHash) = HASH_CREATE;
GVAR(pfeh_id) = -1;
["ace_settingsInitialized", {
//If not enabled, dont't bother adding eventhandler
TRACE_1("ace_settingsInitialized eh", GVAR(enabled));
if (!GVAR(enabled)) exitWith {};
GVAR(lastFPTime) = -1;
GVAR(fingersHash) = [] call CBA_fnc_hashCreate;
GVAR(pfeh_id) = -1;
[QGVAR(fingered), {_this call FUNC(incomingFinger)}] call CBA_fnc_addEventHandler;
}] call CBA_fnc_addEventHandler;

View File

@ -28,8 +28,9 @@ private _fingerPos = if (_sourceUnit == ACE_player) then {
TRACE_3("incoming finger:", _sourceUnit, _fingerPosPrecise, _fingerPos);
private _data = [diag_tickTime, _fingerPos, ([_sourceUnit, false, true] call EFUNC(common,getName))];
HASH_SET(GVAR(fingersHash), _sourceUnit, _data);
[GVAR(fingersHash), _sourceUnit, _data] call CBA_fnc_hashSet;
if (GVAR(pfeh_id) == -1) then {
GVAR(pfeh_id) = [DFUNC(perFrameEH), 0, []] call CBA_fnc_addPerFrameHandler;
TRACE_1("Started PFEH", GVAR(pfeh_id));
};

View File

@ -15,20 +15,19 @@
*/
#include "script_component.hpp"
if (!alive ACE_player) then {GVAR(fingersHash) = HASH_CREATE;};
if (!alive ACE_player) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;};
// Conditions: canInteract
if !([ACE_player, ACE_player, ["isNotInside"]] call EFUNC(common,canInteractWith)) then {GVAR(fingersHash) = HASH_CREATE;};
if !([ACE_player, ACE_player, ["isNotInside"]] call EFUNC(common,canInteractWith)) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;};
// Make sure player is dismounted or in a static weapon:
if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) then {GVAR(fingersHash) = HASH_CREATE;};
if ((ACE_player != vehicle ACE_player) && {!((vehicle ACE_player) isKindOf "StaticWeapon")}) then {GVAR(fingersHash) = [] call CBA_fnc_hashCreate;};
private _iconSize = BASE_SIZE * 0.10713 * (call EFUNC(common,getZoom));
{
private _data = HASH_GET(GVAR(fingersHash), _x);
_data params ["_lastTime", "_pos", "_name"];
[+GVAR(fingersHash), {
_value params ["_lastTime", "_pos", "_name"];
private _timeLeftToShow = _lastTime + FP_TIMEOUT - diag_tickTime;
if (_timeLeftToShow <= 0) then {
HASH_REM(GVAR(fingersHash), _x);
[GVAR(fingersHash), _key] call CBA_fnc_hashRem;
} else {
private _drawColor = + GVAR(indicatorColor);
// Fade out:
@ -36,9 +35,10 @@ private _iconSize = BASE_SIZE * 0.10713 * (call EFUNC(common,getZoom));
drawIcon3D [QPATHTOF(UI\fp_icon2.paa), _drawColor, ASLtoAGL _pos, _iconSize, _iconSize, 0, _name, 1, 0.03, "RobotoCondensed"];
};
} count (GVAR(fingersHash) select 0);
}] call CBA_fnc_hashEachPair;
if ((count (GVAR(fingersHash) select 0)) == 0) then {
if ((GVAR(fingersHash) select 1) isEqualTo []) then {
TRACE_1("Ending PFEH", GVAR(pfeh_id));
[GVAR(pfeh_id)] call CBA_fnc_removePerFrameHandler;
GVAR(pfeh_id) = -1;
};