2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-21 20:11:03 +00:00
|
|
|
/*
|
2015-03-24 15:27:27 +00:00
|
|
|
* Author: NouberNou and esteldunedain
|
|
|
|
* Handle interactions key down
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-24 15:27:27 +00:00
|
|
|
* 0: Type of key: 0 interaction / 1 self interaction <NUMBER>
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-02-21 20:11:03 +00:00
|
|
|
* true <BOOL>
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [0] call ACE_interact_menu_fnc_keyDown
|
|
|
|
*
|
2015-02-21 20:11:03 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_menuType"];
|
2015-02-28 20:48:46 +00:00
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
if (GVAR(openedMenuType) == _menuType) exitWith {true};
|
2015-02-28 20:48:46 +00:00
|
|
|
|
2015-06-07 19:21:51 +00:00
|
|
|
// Conditions: canInteract (these don't apply to zeus)
|
|
|
|
if ((isNull curatorCamera) && {
|
2017-09-10 19:43:03 +00:00
|
|
|
!([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder", "isNotRefueling"]] call EFUNC(common,canInteractWith))
|
2015-06-07 19:21:51 +00:00
|
|
|
}) exitWith {false};
|
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
while {dialog} do {
|
|
|
|
closeDialog 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_menuType == 0) then {
|
2015-02-19 13:49:36 +00:00
|
|
|
GVAR(keyDown) = true;
|
2015-03-24 15:27:27 +00:00
|
|
|
GVAR(keyDownSelfAction) = false;
|
|
|
|
} else {
|
|
|
|
GVAR(keyDown) = false;
|
|
|
|
GVAR(keyDownSelfAction) = true;
|
|
|
|
};
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(keyDownTime) = diag_tickTime;
|
2015-03-24 15:27:27 +00:00
|
|
|
GVAR(openedMenuType) = _menuType;
|
2015-04-20 04:16:51 +00:00
|
|
|
GVAR(lastTimeSearchedActions) = -1000;
|
2015-04-26 10:41:15 +00:00
|
|
|
GVAR(ParsedTextCached) = [];
|
2015-03-10 20:48:08 +00:00
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
|
2017-08-22 21:07:45 +00:00
|
|
|
(!(isNull (ACE_controlledUAV select 0))) ||
|
2015-03-24 15:27:27 +00:00
|
|
|
visibleMap ||
|
2015-06-04 22:11:35 +00:00
|
|
|
(!isNull curatorCamera) ||
|
2015-04-20 16:54:20 +00:00
|
|
|
{(_menuType == 1) && {(isWeaponDeployed ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || {cameraView == "GUNNER"}}} ||
|
|
|
|
{(_menuType == 0) && GVAR(AlwaysUseCursorInteraction)};
|
|
|
|
|
2015-05-02 04:33:28 +00:00
|
|
|
// Delete existing controls in case there's any left
|
|
|
|
GVAR(iconCount) = 0;
|
|
|
|
for "_i" from 0 to (count GVAR(iconCtrls))-1 do {
|
|
|
|
ctrlDelete (GVAR(iconCtrls) select _i);
|
|
|
|
GVAR(ParsedTextCached) set [_i, ""];
|
|
|
|
};
|
|
|
|
GVAR(iconCtrls) resize GVAR(iconCount);
|
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
if (GVAR(useCursorMenu)) then {
|
2015-06-06 15:20:22 +00:00
|
|
|
// Don't close zeus interface if open
|
|
|
|
if (isNull curatorCamera) then {
|
|
|
|
(findDisplay 46) createDisplay QGVAR(cursorMenu); //"RscCinemaBorder";//
|
|
|
|
} else {
|
|
|
|
createDialog QGVAR(cursorMenu);
|
|
|
|
};
|
2015-05-02 04:33:28 +00:00
|
|
|
(finddisplay 91919) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
|
2017-05-31 16:41:53 +00:00
|
|
|
(finddisplay 91919) displayAddEventHandler ["KeyDown", {
|
|
|
|
// Handle the escape key being pressed with menu open:
|
|
|
|
if ((_this select [1,4]) isEqualTo [1,false,false,false]) exitWith { // escape key with no modifiers
|
|
|
|
[displayNull] call FUNC(handleEscapeMenu);
|
|
|
|
};
|
|
|
|
[_this,'keydown'] call CBA_events_fnc_keyHandler;
|
|
|
|
}];
|
2015-03-24 15:27:27 +00:00
|
|
|
// The dialog sets:
|
|
|
|
// uiNamespace getVariable QGVAR(dlgCursorMenu);
|
|
|
|
// uiNamespace getVariable QGVAR(cursorMenuOpened);
|
2015-04-08 03:44:41 +00:00
|
|
|
GVAR(cursorPos) = [0.5,0.5,0];
|
2015-05-02 04:33:28 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _ctrl = (findDisplay 91919) ctrlCreate ["RscStructuredText", 9922];
|
2015-05-02 04:33:28 +00:00
|
|
|
_ctrl ctrlSetPosition [safeZoneX, safeZoneY, safeZoneW, safeZoneH];
|
|
|
|
_ctrl ctrlCommit 0;
|
|
|
|
|
|
|
|
// handles Mouse moving and LMB in cursor mode when action on keyrelease is disabled
|
|
|
|
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
|
|
|
|
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
|
2015-03-24 15:27:27 +00:00
|
|
|
setMousePosition [0.5, 0.5];
|
2017-05-31 16:41:53 +00:00
|
|
|
} else {
|
|
|
|
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
|
|
|
(findDisplay 91919) closeDisplay 2;
|
|
|
|
};
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
GVAR(selfMenuOffset) = (AGLtoASL (positionCameraToWorld [0, 0, 2])) vectorDiff (AGLtoASL (positionCameraToWorld [0, 0, 0]));
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-02-27 18:44:53 +00:00
|
|
|
//Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice)
|
|
|
|
if (GVAR(openedMenuType) == 0) then {
|
|
|
|
if (isNull curatorCamera) then {
|
2017-08-22 21:07:45 +00:00
|
|
|
if (!(isNull (ACE_controlledUAV select 0))) then {
|
|
|
|
GVAR(menuDepthPath) = [["ACE_SelfActions", (ACE_controlledUAV select 0)]];
|
2016-02-27 18:44:53 +00:00
|
|
|
GVAR(expanded) = true;
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
2016-02-27 18:44:53 +00:00
|
|
|
GVAR(lastPath) = +GVAR(menuDepthPath);
|
|
|
|
GVAR(startHoverTime) = -1000;
|
2017-08-22 21:07:45 +00:00
|
|
|
} else {
|
|
|
|
if (vehicle ACE_player != ACE_player) then {
|
|
|
|
GVAR(menuDepthPath) = [["ACE_SelfActions", (vehicle ACE_player)]];
|
|
|
|
GVAR(expanded) = true;
|
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
|
|
|
GVAR(lastPath) = +GVAR(menuDepthPath);
|
|
|
|
GVAR(startHoverTime) = -1000;
|
|
|
|
};
|
2015-10-20 18:31:09 +00:00
|
|
|
};
|
|
|
|
} else {
|
2016-02-27 18:44:53 +00:00
|
|
|
GVAR(menuDepthPath) = [["ACE_ZeusActions", (getAssignedCuratorLogic player)]];
|
|
|
|
GVAR(expanded) = true;
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
2016-02-27 18:44:53 +00:00
|
|
|
GVAR(lastPath) = +GVAR(menuDepthPath);
|
|
|
|
GVAR(startHoverTime) = -1000;
|
2015-10-20 18:31:09 +00:00
|
|
|
};
|
2016-02-27 18:44:53 +00:00
|
|
|
} else {
|
|
|
|
GVAR(menuDepthPath) = [["ACE_SelfActions", ACE_player]];
|
|
|
|
GVAR(expanded) = true;
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
2016-02-27 18:44:53 +00:00
|
|
|
GVAR(lastPath) = +GVAR(menuDepthPath);
|
|
|
|
GVAR(startHoverTime) = -1000;
|
|
|
|
};
|
|
|
|
|
2016-05-24 13:13:11 +00:00
|
|
|
["ace_interactMenuOpened", [_menuType]] call CBA_fnc_localEvent;
|
2015-03-24 15:27:27 +00:00
|
|
|
|
2016-08-05 17:05:15 +00:00
|
|
|
//Remove the old "DefaultAction" action event handler if it already exists
|
|
|
|
GVAR(blockDefaultActions) params [["_player", objNull], ["_ehid", -1]];
|
|
|
|
TRACE_2("blockDefaultActions",_player,_ehid);
|
|
|
|
if (!isNull _player) then {
|
|
|
|
[_player, "DefaultAction", _ehid] call EFUNC(common,removeActionEventHandler);
|
|
|
|
GVAR(blockDefaultActions) = [];
|
|
|
|
};
|
|
|
|
//Add the "DefaultAction" action event handler
|
|
|
|
if (alive ACE_player) then {
|
|
|
|
private _ehid = [ACE_player, "DefaultAction", {GVAR(openedMenuType) >= 0}, {
|
|
|
|
if (!GVAR(actionOnKeyRelease) && GVAR(actionSelected)) then {
|
|
|
|
[GVAR(openedMenuType),true] call FUNC(keyUp);
|
|
|
|
};
|
|
|
|
}] call EFUNC(common,addActionEventHandler);
|
|
|
|
TRACE_2("Added",ACE_player,_ehid);
|
|
|
|
GVAR(blockDefaultActions) = [ACE_player, _ehid];
|
|
|
|
};
|
|
|
|
|
2015-01-18 18:38:27 +00:00
|
|
|
true
|