Skip to content

Commit

Permalink
Remove Keybinds/Events for Zeus now handeld in CBA
Browse files Browse the repository at this point in the history
Close #2937
  • Loading branch information
PabstMirror committed Dec 30, 2015
1 parent 6a21b7d commit 1e29c02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 45 deletions.
28 changes: 14 additions & 14 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ACE - Common
// #define ENABLE_PERFORMANCE_COUNTERS
#include "script_component.hpp"

// #define ENABLE_PERFORMANCE_COUNTERS

//////////////////////////////////////////////////
// PFHs
Expand Down Expand Up @@ -293,6 +293,17 @@ enableCamShake true;
// Set up numerous eventhanders for player controlled units
//////////////////////////////////////////////////

//CBA has events for zeus's display onLoad and onUnload (Need to delay a frame for display to be ready)
private _zeusDisplayChangedFNC = {
[{
private _data = !(isNull findDisplay 312);
["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
}, []] call FUNC(execNextFrame);
};
["CBA_curatorOpened", _zeusDisplayChangedFNC] call CBA_fnc_addEventHandler;
["CBA_curatorClosed", _zeusDisplayChangedFNC] call CBA_fnc_addEventHandler;


// default variables
GVAR(OldPlayerVehicle) = vehicle objNull;
GVAR(OldPlayerTurret) = [objNull] call FUNC(getTurretIndex);
Expand All @@ -302,7 +313,6 @@ GVAR(OldPlayerVisionMode) = currentVisionMode objNull;
GVAR(OldCameraView) = "";
GVAR(OldVisibleMap) = false;
GVAR(OldInventoryDisplayIsOpen) = nil; //@todo check this
GVAR(OldZeusDisplayIsOpen) = false;
GVAR(OldIsCamera) = false;

// 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
Expand All @@ -314,13 +324,11 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
// PFH to raise varios events
[{
BEGIN_COUNTER(stateChecker);
private "_data"; // reuse one variable to reduce number of variables that have to be set to private each frame

// "playerChanged" event
_data = call FUNC(player);
private _data = call FUNC(player); // reuse one variable to reduce number of variables that have to be set to private each frame
if !(_data isEqualTo ACE_player) then {
private "_oldPlayer";
_oldPlayer = ACE_player;
private _oldPlayer = ACE_player;

ACE_player = _data;
uiNamespace setVariable ["ACE_player", _data];
Expand Down Expand Up @@ -393,14 +401,6 @@ if (!isNil QGVAR(PreInit_playerChanged_PFHID)) then {
["inventoryDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
};

// "zeusDisplayChanged" event
_data = !(isNull findDisplay 312);
if !(_data isEqualTo GVAR(OldZeusDisplayIsOpen)) then {
// Raise ACE event locally
GVAR(OldZeusDisplayIsOpen) = _data;
["zeusDisplayChanged", [ACE_player, _data]] call FUNC(localEvent);
};

// "activeCameraChanged" event
_data = call FUNC(isfeatureCameraActive);
if !(_data isEqualTo GVAR(OldIsCamera)) then {
Expand Down
31 changes: 0 additions & 31 deletions addons/interact_menu/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,6 @@ GVAR(ParsedTextCached) = [];
if (GVAR(menuBackground)==2) then {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;};
}] call EFUNC(common,addEventHandler);

// Let key work with zeus open (not perfect, contains workaround to prevent other CBA keybindings)
["zeusDisplayChanged",{
if (_this select 1) then {
(finddisplay 312) displayAddEventHandler ["KeyUp", {
_key = ["ACE3 Common","ace_interact_menu_InteractKey"] call CBA_fnc_getKeybind;
_key = _key select 5;
_dik = _key select 0;
_mods = _key select 1;

if ((_this select 1) == _dik) then {
if ((_this select [2,3]) isEqualTo _mods) then {
[_this,'keyup'] call CBA_events_fnc_keyHandler
};
};
}];
(finddisplay 312) displayAddEventHandler ["KeyDown", {
_key = ["ACE3 Common","ace_interact_menu_InteractKey"] call CBA_fnc_getKeybind;
_key = _key select 5;
_dik = _key select 0;
_mods = _key select 1;

if ((_this select 1) == _dik) then {
if ((_this select [2,3]) isEqualTo _mods) then {
[_this,'keydown'] call CBA_events_fnc_keyHandler
};
};
}];
};
}] call EFUNC(common,addEventHandler);


//Debug to help end users identify mods that break CBA's XEH
[{
private ["_badClassnames"];
Expand Down

0 comments on commit 1e29c02

Please sign in to comment.