2015-10-14 22:26:31 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-10-26 15:49:39 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
|
|
|
|
2015-10-14 22:26:31 +00:00
|
|
|
#include "key.sqf"
|
|
|
|
|
|
|
|
// reload mutex, you can't play signal while reloading
|
|
|
|
GVAR(ReloadMutex) = true;
|
|
|
|
|
2015-10-26 15:49:39 +00:00
|
|
|
// Event for main display to be loaded:
|
|
|
|
["mainDisplayLoaded", {
|
|
|
|
// handle reloading
|
|
|
|
(findDisplay 46) displayAddEventHandler ["KeyDown", {
|
2015-10-14 22:26:31 +00:00
|
|
|
if ((_this select 1) in actionKeys "ReloadMagazine") then {
|
2015-10-26 15:49:39 +00:00
|
|
|
if ((isNull ACE_player) || {!alive ACE_player}) exitWith {false};
|
2015-11-20 21:36:37 +00:00
|
|
|
private _weapon = currentWeapon ACE_player;
|
2015-10-14 22:26:31 +00:00
|
|
|
|
|
|
|
if (_weapon != "") then {
|
|
|
|
GVAR(ReloadMutex) = false;
|
|
|
|
|
2015-11-20 21:36:37 +00:00
|
|
|
private _gesture = getText (configfile >> "CfgWeapons" >> _weapon >> "reloadAction");
|
|
|
|
private _isLauncher = _weapon isKindOf ["Launcher", (configFile >> "CfgWeapons")];
|
|
|
|
private _config = ["CfgGesturesMale", "CfgMovesMaleSdr"] select _isLauncher;
|
|
|
|
private _duration = getNumber (configfile >> _config >> "States" >> _gesture >> "speed");
|
2015-10-14 22:26:31 +00:00
|
|
|
|
|
|
|
if (_duration != 0) then {
|
|
|
|
_duration = if (_duration < 0) then { abs _duration } else { 1 / _duration };
|
|
|
|
} else {
|
|
|
|
_duration = 3;
|
|
|
|
};
|
|
|
|
|
2015-10-26 15:49:39 +00:00
|
|
|
TRACE_2("Reloading, blocking gestures",_weapon,_duration);
|
2015-10-14 22:26:31 +00:00
|
|
|
[{GVAR(ReloadMutex) = true;}, [], _duration] call EFUNC(common,waitAndExecute);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
false
|
2015-10-26 15:49:39 +00:00
|
|
|
}];
|
|
|
|
}] call EFUNC(common,addEventHandler);
|