2015-01-12 18:22:58 +00:00
// ACE - Common
2015-09-21 15:00:53 +00:00
#include "script_component.hpp"
2015-08-30 20:26:43 +00:00
// #define ENABLE_PERFORMANCE_COUNTERS
2015-01-11 16:42:31 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// PFHs
//////////////////////////////////////////////////
2015-02-03 00:14:16 +00:00
2015-08-24 15:10:54 +00:00
//Singe PFEH to handle execNextFrame, waitAndExec and waitUntilAndExec:
2015-06-11 07:45:42 +00:00
[{
2015-10-04 16:38:31 +00:00
BEGIN_COUNTER(waitAndExec);
2015-07-03 01:14:58 +00:00
2015-06-11 07:45:42 +00:00
//Handle the waitAndExec array:
2015-09-21 15:00:53 +00:00
while {!(GVAR(waitAndExecArray) isEqualTo []) && {GVAR(waitAndExecArray) select 0 select 0 <= ACE_Time}} do {
2015-11-17 16:43:07 +00:00
private _entry = GVAR(waitAndExecArray) deleteAt 0;
2015-06-11 07:45:42 +00:00
(_entry select 2) call (_entry select 1);
};
//Handle the execNextFrame array:
{
(_x select 0) call (_x select 1);
2015-09-21 15:00:53 +00:00
false
} count GVAR(nextFrameBufferA);
2015-06-11 07:45:42 +00:00
//Swap double-buffer:
GVAR(nextFrameBufferA) = GVAR(nextFrameBufferB);
GVAR(nextFrameBufferB) = [];
GVAR(nextFrameNo) = diag_frameno + 1;
2015-08-29 12:54:42 +00:00
2015-08-25 18:18:59 +00:00
//Handle the waitUntilAndExec array:
2015-08-24 15:10:54 +00:00
{
2015-10-04 09:43:13 +00:00
// if condition is satisifed call statement
if ((_x select 2) call (_x select 0)) then {
// make sure to delete the correct handle when multiple conditions are met in one frame
2015-11-18 13:10:01 +00:00
GVAR(waitUntilAndExecArray) deleteAt (GVAR(waitUntilAndExecArray) find _x);
2015-10-04 09:43:13 +00:00
(_x select 2) call (_x select 1);
2015-08-24 15:10:54 +00:00
};
2015-11-18 13:10:01 +00:00
nil
} count +GVAR(waitUntilAndExecArray);
2015-11-17 03:31:17 +00:00
2015-10-04 16:38:31 +00:00
END_COUNTER(waitAndExec);
2015-06-11 07:45:42 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Get Map Data
//////////////////////////////////////////////////
//Find MGRS zone and 100km grid for current map
[] call FUNC(getMGRSdata);
//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid)
[] call FUNC(getMapGridData);
//////////////////////////////////////////////////
// Eventhandlers
//////////////////////////////////////////////////
2015-02-03 04:45:04 +00:00
// Listens for global "SettingChanged" events, to update the force status locally
["SettingChanged", {
2015-09-21 15:00:53 +00:00
params ["_name", "_value", "_force"];
2015-02-03 04:45:04 +00:00
if (_force) then {
2015-09-21 15:00:53 +00:00
private "_settingData";
2015-02-03 04:45:04 +00:00
_settingData = [_name] call FUNC(getSettingData);
2015-09-21 15:00:53 +00:00
if (_settingData isEqualTo []) exitWith {};
_settingData set [6, _force];
2015-02-03 04:45:04 +00:00
};
}] call FUNC(addEventhandler);
2015-08-02 01:01:35 +00:00
2015-09-21 15:00:53 +00:00
// Event to log Fix Headbug output
2015-08-02 01:01:35 +00:00
["HeadbugFixUsed", {
2015-09-21 15:00:53 +00:00
params ["_profileName", "_animation"];
2015-08-26 15:39:44 +00:00
ACE_LOGINFO_2("Headbug Used: Name: %1, Animation: %2",_profileName,_animation);
2015-08-02 01:01:35 +00:00
}] call FUNC(addEventHandler);
2015-09-21 15:00:53 +00:00
["fixCollision", FUNC(fixCollision)] call FUNC(addEventhandler);
["fixFloating", FUNC(fixFloating)] call FUNC(addEventhandler);
["fixPosition", FUNC(fixPosition)] call FUNC(addEventhandler);
2015-08-02 01:01:35 +00:00
2015-09-21 15:00:53 +00:00
["unloadPersonEvent", FUNC(unloadPersonLocal)] call FUNC(addEventhandler);
2015-06-11 22:56:11 +00:00
2015-03-18 10:29:58 +00:00
["lockVehicle", {
_this setVariable [QGVAR(lockStatus), locked _this];
_this lock 2;
}] call FUNC(addEventhandler);
["unlockVehicle", {
_this lock (_this getVariable [QGVAR(lockStatus), locked _this]);
}] call FUNC(addEventhandler);
2015-03-24 18:07:39 +00:00
["setDir", {(_this select 0) setDir (_this select 1)}] call FUNC(addEventhandler);
2015-03-27 23:30:51 +00:00
["setFuel", {(_this select 0) setFuel (_this select 1)}] call FUNC(addEventhandler);
2015-04-12 08:05:49 +00:00
["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler);
2015-09-28 12:35:05 +00:00
["selectLeader", {(_this select 0) selectLeader (_this select 1)}] call FUNC(addEventHandler);
["setVelocity", {(_this select 0) setVelocity (_this select 1)}] call FUNC(addEventHandler);
2015-03-24 18:07:39 +00:00
2015-07-03 01:14:58 +00:00
if (isServer) then {
["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler);
2015-09-26 01:16:55 +00:00
["enableSimulationGlobal", {(_this select 0) enableSimulationGlobal (_this select 1)}] call FUNC(addEventHandler);
2015-07-03 01:14:58 +00:00
};
2015-01-11 16:42:31 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up remote execution
//////////////////////////////////////////////////
2015-01-11 16:42:31 +00:00
2015-04-18 02:26:27 +00:00
// ACE events
2015-09-26 01:16:55 +00:00
"ACEg" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)};
"ACEc" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)};
2015-01-13 23:27:42 +00:00
2015-04-18 02:26:27 +00:00
// Synced ACE events
// Handle JIP scenario
2015-09-21 15:00:53 +00:00
if (!isServer) then {
2015-04-30 18:49:38 +00:00
["PlayerJip", {
2015-08-26 13:20:11 +00:00
ACE_LOGINFO("JIP event synchronization initialized");
2015-04-18 02:26:27 +00:00
["SEH_all", [player]] call FUNC(serverEvent);
}] call FUNC(addEventHandler);
} else {
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
};
2015-09-21 15:00:53 +00:00
2015-04-18 02:26:27 +00:00
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
2015-09-21 15:00:53 +00:00
2015-08-06 05:28:43 +00:00
if (isServer) then {
[FUNC(syncedEventPFH), 0.5, []] call CBA_fnc_addPerFrameHandler;
};
2015-08-11 18:10:42 +00:00
2015-09-21 15:00:53 +00:00
// @todo deprecated
QGVAR(remoteFnc) addPublicVariableEventHandler {
(_this select 1) call FUNC(execRemoteFnc);
};
// @todo figure out what this does.
[missionNamespace] call FUNC(executePersistent);
//////////////////////////////////////////////////
// Check files, previous installed version etc.
//////////////////////////////////////////////////
private ["_currentVersion", "_previousVersion"];
_currentVersion = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "version");
_previousVersion = profileNamespace getVariable ["ACE_VersionNumberString", ""];
// check previous version number from profile
if (_currentVersion != _previousVersion) then {
// do something
profileNamespace setVariable ["ACE_VersionNumberString", _currentVersion];
};
2015-05-09 11:25:19 +00:00
call FUNC(checkFiles);
2015-04-18 02:26:27 +00:00
2015-06-13 03:57:01 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up SettingsInitialized eventhandler
//////////////////////////////////////////////////
["SettingsInitialized", {
[
GVAR(checkPBOsAction),
GVAR(checkPBOsCheckAll),
call compile GVAR(checkPBOsWhitelist)
] call FUNC(checkPBOs)
}] call FUNC(addEventHandler);
2015-06-13 03:57:01 +00:00
// Create a pfh to wait until all postinits are ready and settings are initialized
[{
2015-09-21 15:00:53 +00:00
params ["_args"];
_args params ["_waitingMsgSent"];
2015-06-13 03:57:01 +00:00
// If post inits are not ready then wait
if !(SLX_XEH_MACHINE select 8) exitWith {};
// If settings are not initialized then wait
2015-09-21 15:00:53 +00:00
if (isNil QGVAR(settings) || {!isServer && isNil QEGVAR(modules,serverModulesRead)}) exitWith {
if !(_waitingMsgSent) then {
2015-06-13 03:57:01 +00:00
_args set [0, true];
2015-08-26 13:20:11 +00:00
ACE_LOGINFO("Waiting on settings from server...");
2015-06-13 03:57:01 +00:00
};
};
2015-09-21 15:00:53 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-06-13 03:57:01 +00:00
2015-08-26 13:20:11 +00:00
ACE_LOGINFO("Settings received from server.");
2015-06-13 03:57:01 +00:00
2015-11-07 02:46:06 +00:00
if (isServer) then { //read settings from paramsArray
[] call FUNC(readSettingsFromParamsArray);
};
2015-06-13 03:57:01 +00:00
// Event so that ACE_Modules have their settings loaded:
["InitSettingsFromModules", []] call FUNC(localEvent);
2015-10-18 23:49:03 +00:00
if (isServer) then {
// Publish all settings data after all configs and modules are read
publicVariable QGVAR(settings);
};
2015-06-13 03:57:01 +00:00
// Load user settings from profile
if (hasInterface) then {
call FUNC(loadSettingsFromProfile);
call FUNC(loadSettingsLocalizedText);
};
2015-08-26 13:20:11 +00:00
ACE_LOGINFO("Settings initialized.");
2015-06-13 03:57:01 +00:00
//Event that settings are safe to use:
["SettingsInitialized", []] call FUNC(localEvent);
2015-09-03 04:58:24 +00:00
//Set init finished and run all delayed functions:
GVAR(settingsInitFinished) = true;
2015-09-21 15:13:28 +00:00
ACE_LOGINFO_1("%1 delayed functions running.",count GVAR(runAtSettingsInitialized));
2015-09-21 15:00:53 +00:00
2015-09-03 04:58:24 +00:00
{
2015-09-21 15:00:53 +00:00
(_x select 1) call (_x select 0);
false
} count GVAR(runAtSettingsInitialized);
2015-09-03 05:16:48 +00:00
GVAR(runAtSettingsInitialized) = nil; //cleanup
2015-08-04 07:34:31 +00:00
}, 0, [false]] call CBA_fnc_addPerFrameHandler;
2015-06-13 03:57:01 +00:00
2015-09-21 15:00:53 +00:00
/***************************************************************************/
/***************************************************************************/
/** everything that only player controlled machines need, goes below this **/
/***************************************************************************/
/***************************************************************************/
2015-04-18 02:26:27 +00:00
2015-01-11 16:42:31 +00:00
if (!hasInterface) exitWith {};
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up mouse wheel eventhandler
//////////////////////////////////////////////////
call FUNC(assignedItemFix);
2015-09-21 16:37:19 +00:00
2015-09-21 15:00:53 +00:00
GVAR(ScrollWheelFrame) = diag_frameno;
2015-09-21 16:37:19 +00:00
2015-09-26 01:16:55 +00:00
["mainDisplayLoaded", {
[{
2015-09-30 17:29:17 +00:00
call FUNC(handleScrollWheelInit);
2015-09-26 01:16:55 +00:00
call FUNC(handleModifierKeyInit);
}, [], 0.1] call FUNC(waitAndExecute); // needs delay, otherwise doesn't work without pressing "RESTART" in editor once. Tested in 1.52RC
}] call FUNC(addEventHandler);
// add PFH to execute event that fires when the main display (46) is created
private "_fnc_initMainDisplayCheck";
_fnc_initMainDisplayCheck = {
[{
if !(isNull findDisplay 46) then {
// Raise ACE event locally
["mainDisplayLoaded", [findDisplay 46]] call FUNC(localEvent);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
};
call _fnc_initMainDisplayCheck;
// repeat this every time a savegame is loaded
addMissionEventHandler ["Loaded", _fnc_initMainDisplayCheck];
2015-04-25 07:49:47 +00:00
2015-09-21 15:00:53 +00:00
// @todo remove?
2015-01-11 16:42:31 +00:00
enableCamShake true;
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Eventhandler to set player names
//////////////////////////////////////////////////
2015-01-12 04:02:33 +00:00
// Set the name for the current player
2015-01-16 15:14:18 +00:00
["playerChanged", {
2015-09-21 15:00:53 +00:00
params ["_newPlayer","_oldPlayer"];
2015-04-30 18:49:38 +00:00
2015-01-16 15:14:18 +00:00
if (alive _newPlayer) then {
2015-09-21 15:00:53 +00:00
[_newPlayer] call FUNC(setName);
2015-01-12 21:34:01 +00:00
};
2015-09-21 15:00:53 +00:00
2015-01-16 15:14:18 +00:00
if (alive _oldPlayer) then {
2015-09-21 15:00:53 +00:00
[_oldPlayer] call FUNC(setName);
2015-01-12 21:34:01 +00:00
};
2015-01-16 15:14:18 +00:00
}] call FUNC(addEventhandler);
2015-01-13 23:27:42 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Set up numerous eventhanders for player controlled units
//////////////////////////////////////////////////
// default variables
GVAR(OldPlayerVehicle) = vehicle objNull;
GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex);
GVAR(OldPlayerWeapon) = currentWeapon objNull;
GVAR(OldPlayerInventory) = [objNull] call FUNC(getAllGear);
GVAR(OldPlayerVisionMode) = currentVisionMode objNull;
GVAR(OldCameraView) = "";
2015-08-11 18:10:42 +00:00
GVAR(OldVisibleMap) = false;
2015-09-21 15:00:53 +00:00
GVAR(OldInventoryDisplayIsOpen) = nil; //@todo check this
GVAR(OldZeusDisplayIsOpen) = false;
GVAR(OldIsCamera) = false;
2015-01-13 23:27:42 +00:00
2015-09-21 15:32:21 +00:00
// clean up playerChanged eventhandler from preinit and put it in the same PFH as the other events to reduce overhead and guarantee advantageous execution order
if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
[GVAR(PreInit_playerChanged_PFHID)] call CBA_fnc_removePerFrameHandler;
GVAR(PreInit_playerChanged_PFHID) = nil;
};
2015-01-16 18:39:19 +00:00
// PFH to raise varios events
2015-01-16 18:28:37 +00:00
[{
2015-08-30 20:26:43 +00:00
BEGIN_COUNTER(stateChecker);
2015-09-21 15:00:53 +00:00
private "_data"; // reuse one variable to reduce number of variables that have to be set to private each frame
2015-09-21 15:32:21 +00:00
// "playerChanged" event
_data = call FUNC(player);
2015-09-29 03:41:45 +00:00
if !(_data isEqualTo ACE_player) then {
2015-09-21 15:32:21 +00:00
private "_oldPlayer";
_oldPlayer = ACE_player;
ACE_player = _data;
uiNamespace setVariable ["ACE_player", _data];
// Raise ACE event locally
["playerChanged", [ACE_player, _oldPlayer]] call FUNC(localEvent);
};
2015-09-21 15:00:53 +00:00
// "playerVehicleChanged" event
_data = vehicle ACE_player;
if !(_data isEqualTo GVAR(OldPlayerVehicle)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldPlayerVehicle) = _data;
["playerVehicleChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-04-04 14:26:32 +00:00
};
2015-09-21 15:00:53 +00:00
// "playerTurretChanged" event
_data = [ACE_player] call FUNC(getTurretIndex);
if !(_data isEqualTo GVAR(OldPlayerTurret)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldPlayerTurret) = _data;
["playerTurretChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-01-16 18:39:19 +00:00
};
2015-04-04 14:26:32 +00:00
2015-09-21 15:00:53 +00:00
// "playerWeaponChanged" event
_data = currentWeapon ACE_player;
if (_data != GVAR(OldPlayerWeapon)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldPlayerWeapon) = _data;
["playerWeaponChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-04-04 14:26:32 +00:00
};
2015-09-21 15:00:53 +00:00
// "playerInventoryChanged" event
_data = [ACE_player] call FUNC(getAllGear);
if !(_data isEqualTo GVAR(OldPlayerInventory)) then {
// Raise ACE event locally
GVAR(OldPlayerInventory) = _data;
["playerInventoryChanged", [ACE_player, _data]] call FUNC(localEvent);
};
// "playerVisionModeChanged" event
_data = currentVisionMode ACE_player;
if !(_data isEqualTo GVAR(OldPlayerVisionMode)) then {
2015-01-16 18:39:38 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldPlayerVisionMode) = _data;
["playerVisionModeChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-01-16 18:39:38 +00:00
};
2015-04-04 14:26:32 +00:00
2015-01-16 20:16:42 +00:00
// "cameraViewChanged" event
2015-09-21 15:00:53 +00:00
_data = cameraView;
if !(_data isEqualTo GVAR(OldCameraView)) then {
2015-01-16 20:16:42 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldCameraView) = _data;
["cameraViewChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-01-16 20:16:42 +00:00
};
2015-04-04 14:26:32 +00:00
2015-09-21 15:00:53 +00:00
// "visibleMapChanged" event
_data = visibleMap;
if (!_data isEqualTo GVAR(OldVisibleMap)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldVisibleMap) = _data;
["visibleMapChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-04-04 14:26:32 +00:00
};
2015-09-21 15:00:53 +00:00
// "inventoryDisplayChanged" event
_data = !(isNull findDisplay 602);
if !(_data isEqualTo GVAR(OldInventoryDisplayIsOpen)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldInventoryDisplayIsOpen) = _data;
["inventoryDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-04-04 14:26:32 +00:00
};
2015-09-21 15:00:53 +00:00
// "zeusDisplayChanged" event
_data = !(isNull findDisplay 312);
if !(_data isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
2015-04-04 14:26:32 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldZeusDisplayIsOpen) = _data;
["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-04-04 14:26:32 +00:00
};
2015-08-26 13:20:11 +00:00
2015-09-21 15:00:53 +00:00
// "activeCameraChanged" event
_data = call FUNC(isfeatureCameraActive);
if !(_data isEqualTo GVAR(OldIsCamera)) then {
2015-08-11 18:10:42 +00:00
// Raise ACE event locally
2015-09-21 15:00:53 +00:00
GVAR(OldIsCamera) = _data;
["activeCameraChanged", [ACE_player, _data]] call FUNC(localEvent);
2015-08-11 18:10:42 +00:00
};
2015-08-26 13:20:11 +00:00
2015-08-30 20:26:43 +00:00
END_COUNTER(stateChecker);
2015-08-04 07:34:31 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Eventhandlers for player controlled machines
//////////////////////////////////////////////////
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
// @todo still needed?
[QGVAR(StateArrested), false, true, QUOTE(ADDON)] call FUNC(defineVariable);
2015-04-18 20:06:42 +00:00
2015-09-27 06:51:42 +00:00
["displayTextStructured", {_this call FUNC(displayTextStructured)}] call FUNC(addEventhandler);
["displayTextPicture", {_this call FUNC(displayTextPicture)}] call FUNC(addEventhandler);
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
["medical_onUnconscious", {
params ["_unit", "_isUnconscious"];
2015-04-18 20:06:42 +00:00
2015-09-21 15:00:53 +00:00
if (local _unit && {!_isUnconscious}) then {
[_unit, false, QFUNC(loadPerson), west /* dummy side */] call FUNC(switchToGroupSide);
};
}] call FUNC(addEventhandler);
2015-04-18 20:06:42 +00:00
2015-01-28 20:38:04 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// Add various canInteractWith conditions
//////////////////////////////////////////////////
2015-03-15 08:26:16 +00:00
2015-03-15 15:12:37 +00:00
["notOnMap", {!visibleMap}] call FUNC(addCanInteractWithCondition);
2015-09-21 15:00:53 +00:00
2015-03-31 21:06:28 +00:00
["isNotInside", {
2015-09-21 15:00:53 +00:00
params ["_unit", "_target"];
2015-03-31 21:06:28 +00:00
// Players can always interact with himself if not boarded
2015-09-21 15:00:53 +00:00
vehicle _unit == _unit ||
2015-03-31 21:06:28 +00:00
// Players can always interact with his vehicle
2015-09-21 15:00:53 +00:00
{vehicle _unit == _target} ||
2015-03-31 21:06:28 +00:00
// Players can always interact with passengers of the same vehicle
2015-09-21 15:00:53 +00:00
{_unit != _target && {vehicle _unit == vehicle _target}}
2015-03-31 21:06:28 +00:00
}] call FUNC(addCanInteractWithCondition);
2015-04-17 23:44:53 +00:00
2015-09-21 16:37:19 +00:00
//////////////////////////////////////////////////
// Set up PlayerJIP eventhandler
//////////////////////////////////////////////////
2015-04-18 02:26:27 +00:00
// Lastly, do JIP events
2015-04-18 01:23:26 +00:00
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
2015-09-21 16:37:19 +00:00
// Note: usage of player is most likely on purpose
2015-08-27 03:39:27 +00:00
if (didJip) then {
2015-04-18 01:23:26 +00:00
// We are jipping! Get ready and wait, and throw the event
[{
2015-09-21 16:37:19 +00:00
if(!isNull player && GVAR(settingsInitFinished)) then {
["PlayerJip", [player]] call FUNC(localEvent);
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-04-30 18:49:38 +00:00
};
2015-08-04 07:34:31 +00:00
}, 0, []] call CBA_fnc_addPerFrameHandler;
2015-04-18 01:23:26 +00:00
};
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
//////////////////////////////////////////////////
// CBA key input handling
//////////////////////////////////////////////////
2015-05-10 19:59:53 +00:00
//Device Handler:
GVAR(deviceKeyHandlingArray) = [];
GVAR(deviceKeyCurrentIndex) = -1;
2015-08-07 01:33:38 +00:00
// Register localizations for the Keybinding categories
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", localize LSTRING(ACEKeybindCategoryEquipment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Common", localize LSTRING(ACEKeybindCategoryCommon)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Weapons", localize LSTRING(ACEKeybindCategoryWeapons)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Movement", localize LSTRING(ACEKeybindCategoryMovement)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Scope Adjustment", localize LSTRING(ACEKeybindCategoryScopeAdjustment)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Vehicles", localize LSTRING(ACEKeybindCategoryVehicles)] call CBA_fnc_registerKeybindModPrettyName;
["ACE3 Equipment", QGVAR(openDevice), (localize "STR_ACE_Common_toggleHandheldDevice"), {
2015-05-10 19:59:53 +00:00
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 3);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [false, false, false]], false] call CBA_fnc_addKeybind; //Home Key
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", QGVAR(closeDevice), (localize "STR_ACE_Common_closeHandheldDevice"), {
2015-05-10 19:59:53 +00:00
[] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
[] call ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 4);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [false, true, false]], false] call CBA_fnc_addKeybind; //CTRL + Home Key
2015-05-10 19:59:53 +00:00
2015-09-21 15:00:53 +00:00
["ACE3 Equipment", QGVAR(cycleDevice), (localize "STR_ACE_Common_cycleHandheldDevices"), {
2015-05-10 19:59:53 +00:00
[1] call FUNC(deviceKeyFindValidIndex);
if (GVAR(deviceKeyCurrentIndex) == -1) exitWith {false};
_displayName = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 0);
_iconImage = ((GVAR(deviceKeyHandlingArray) select GVAR(deviceKeyCurrentIndex)) select 1);
[_displayName, _iconImage] call FUNC(displayTextPicture);
2015-05-12 03:48:03 +00:00
true
2015-05-10 19:59:53 +00:00
},
{false},
2015-09-21 15:00:53 +00:00
[0xC7, [true, false, false]], false] call CBA_fnc_addKeybind; //SHIFT + Home Key
2015-06-05 22:50:04 +00:00
2015-05-14 23:45:53 +00:00
GVAR(commonPostInited) = true;