mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Refactored interaction key handling while boarded:
- Self-interaction key opens up your own self interaction menu - Interaction key opens interaction options of the vehicle and passengers
This commit is contained in:
parent
5e79970740
commit
a1d6c052ba
@ -16,11 +16,11 @@ addMissionEventHandler ["Draw3D", DFUNC(render)];
|
||||
|
||||
|
||||
["ACE3", QGVAR(InteractKey), "Interact Key",
|
||||
{_this call FUNC(keyDown)},
|
||||
{_this call FUNC(keyUp)},
|
||||
{[0] call FUNC(keyDown)},
|
||||
{[0] call FUNC(keyUp)},
|
||||
[219, [false, false, false]], false] call cba_fnc_addKeybind; //Left Windows Key
|
||||
|
||||
["ACE3", QGVAR(SelfInteractKey), "Self Actions Key",
|
||||
{_this call FUNC(keyDownSelfAction)},
|
||||
{_this call FUNC(keyUpSelfAction)},
|
||||
{[1] call FUNC(keyDown)},
|
||||
{[1] call FUNC(keyUp)},
|
||||
[219, [false, true, false]], false] call cba_fnc_addKeybind; //Left Windows Key + Ctrl/Strg
|
||||
|
@ -11,12 +11,11 @@ PREP(createAction);
|
||||
PREP(findActionNode);
|
||||
PREP(isSubPath);
|
||||
PREP(keyDown);
|
||||
PREP(keyDownSelfAction);
|
||||
PREP(keyUp);
|
||||
PREP(keyUpSelfAction);
|
||||
PREP(removeActionFromClass);
|
||||
PREP(removeActionFromObject);
|
||||
PREP(render);
|
||||
PREP(renderActionPoints);
|
||||
PREP(renderBaseMenu);
|
||||
PREP(renderIcon);
|
||||
PREP(renderMenu);
|
||||
@ -26,6 +25,7 @@ PREP(splitPath);
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
GVAR(keyDownTime) = 0;
|
||||
GVAR(openedMenuType) = -1;
|
||||
|
||||
GVAR(lastTime) = diag_tickTime;
|
||||
GVAR(rotationAngle) = 0;
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Author: NouberNou
|
||||
* Handle interaction key down
|
||||
* Author: NouberNou and esteldunedain
|
||||
* Handle interactions key down
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
* 0: Type of key: 0 interaction / 1 self interaction <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* true <BOOL>
|
||||
@ -12,17 +12,42 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if(!GVAR(keyDown)) then {
|
||||
while {dialog} do {
|
||||
closeDialog 0;
|
||||
};
|
||||
EXPLODE_1_PVT(_this,_menuType);
|
||||
|
||||
// Only interact with others if on foot
|
||||
if (vehicle ACE_player != ACE_player) exitWith {};
|
||||
if (GVAR(openedMenuType) == _menuType) exitWith {true};
|
||||
|
||||
GVAR(keyDown) = true;
|
||||
GVAR(keyDownTime) = diag_tickTime;
|
||||
|
||||
["interactMenuOpened", [0]] call EFUNC(common,localEvent);
|
||||
while {dialog} do {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
if (_menuType == 0) then {
|
||||
GVAR(keyDown) = true;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
} else {
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = true;
|
||||
};
|
||||
GVAR(keyDownTime) = diag_tickTime;
|
||||
GVAR(openedMenuType) = _menuType;
|
||||
|
||||
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) ||
|
||||
visibleMap ||
|
||||
(GVAR(AlwaysUseCursorSelfInteraction) && _menuType == 1);
|
||||
if (GVAR(useCursorMenu)) then {
|
||||
createDialog QGVAR(cursorMenu);
|
||||
// The dialog sets:
|
||||
// uiNamespace getVariable QGVAR(dlgCursorMenu);
|
||||
// uiNamespace getVariable QGVAR(cursorMenuOpened);
|
||||
ctrlEnable [91921, true];
|
||||
((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", {
|
||||
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
|
||||
}];
|
||||
setMousePosition [0.5, 0.5];
|
||||
};
|
||||
|
||||
GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
|
||||
((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
|
||||
|
||||
["interactMenuOpened", [_menuType]] call EFUNC(common,localEvent);
|
||||
|
||||
true
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Author: NouberNou
|
||||
* Handle self action key down
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* true <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if(!GVAR(keyDownSelfAction)) then {
|
||||
while {dialog} do {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
GVAR(keyDownSelfAction) = true;
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownTime) = diag_tickTime;
|
||||
|
||||
["interactMenuOpened", [1]] call EFUNC(common,localEvent);
|
||||
|
||||
GVAR(useCursorMenu) = (vehicle ACE_player != ACE_player) || GVAR(AlwaysUseCursorSelfInteraction) || visibleMap;
|
||||
|
||||
if (GVAR(useCursorMenu)) then {
|
||||
closeDialog 0;
|
||||
createDialog QGVAR(cursorMenu);
|
||||
// The dialog sets:
|
||||
// uiNamespace getVariable QGVAR(dlgCursorMenu);
|
||||
// uiNamespace getVariable QGVAR(cursorMenuOpened);
|
||||
ctrlEnable [91921, true];
|
||||
((finddisplay 91919) displayctrl 91921) ctrlAddEventHandler ["MouseMoving", {
|
||||
GVAR(cursorPos) = [_this select 1, _this select 2, 0];
|
||||
}];
|
||||
setMousePosition [0.5, 0.5];
|
||||
|
||||
};
|
||||
|
||||
GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
|
||||
((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
|
||||
};
|
||||
true
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Author: NouberNou
|
||||
* Handle interaction key up
|
||||
* Author: NouberNou and esteldunedain
|
||||
* Handle interactions key up
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
* 0: Type of key: 0 interaction / 1 self interaction <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* true <BOOL>
|
||||
@ -12,6 +12,9 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
// Exit if there's no menu opened
|
||||
if (GVAR(openedMenuType) < 0) exitWith {true};
|
||||
|
||||
if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
|
||||
@ -33,12 +36,18 @@ if(GVAR(actionSelected)) then {
|
||||
};
|
||||
};
|
||||
|
||||
if (GVAR(keyDown)) then {
|
||||
GVAR(keyDown) = false;
|
||||
["interactMenuClosed", [0]] call EFUNC(common,localEvent);
|
||||
GVAR(keyDown) = false;
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
GVAR(openedMenuType) = -1;
|
||||
|
||||
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
GVAR(expanded) = false;
|
||||
GVAR(lastPath) = [];
|
||||
GVAR(menuDepthPath) = [];
|
||||
|
||||
["interactMenuClosed", [GVAR(openedMenuType)]] call EFUNC(common,localEvent);
|
||||
|
||||
true
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Author: NouberNou
|
||||
* Handle self action key up
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* true <BOOL>
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
closeDialog 0;
|
||||
};
|
||||
|
||||
if(GVAR(actionSelected)) then {
|
||||
this = GVAR(selectedTarget);
|
||||
|
||||
private ["_player","_target","_actionData"];
|
||||
_player = ACE_Player;
|
||||
_target = GVAR(selectedTarget);
|
||||
|
||||
// Clear the conditions caches
|
||||
["clearConditionCaches", []] call EFUNC(common,localEvent);
|
||||
|
||||
// Check the action conditions
|
||||
_actionData = GVAR(selectedAction) select 0;
|
||||
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
|
||||
// Call the statement
|
||||
[_target, _player, _actionData select 6] call (_actionData select 3);
|
||||
|
||||
// Clear the conditions caches again if the action was performed
|
||||
["clearConditionCaches", []] call EFUNC(common,localEvent);
|
||||
};
|
||||
};
|
||||
|
||||
if (GVAR(keyDownSelfAction)) then {
|
||||
GVAR(keyDownSelfAction) = false;
|
||||
["interactMenuClosed", [1]] call EFUNC(common,localEvent);
|
||||
};
|
||||
|
||||
GVAR(expanded) = false;
|
||||
GVAR(lastPath) = [];
|
||||
GVAR(menuDepthPath) = [];
|
||||
true
|
@ -19,98 +19,11 @@ _foundTarget = false;
|
||||
_cursorPos1 = positionCameraToWorld [0, 0, 0];
|
||||
_cursorPos2 = positionCameraToWorld [0, 0, 2];
|
||||
|
||||
GVAR(selfMenuScale) = (((worldToScreen (positionCameraToWorld [1,0,2])) select 0) -
|
||||
((worldToScreen (positionCameraToWorld [0,0,2])) select 0)) / 0.6;
|
||||
//systemChat format ["selfMenuScale: %1", GVAR(selfMenuScale)];
|
||||
GVAR(currentOptions) = [];
|
||||
|
||||
private ["_actionsVarName","_classActions","_objectActions","_target","_player","_action","_actionData","_active"];
|
||||
_player = ACE_player;
|
||||
if (GVAR(keyDown)) then {
|
||||
if (GVAR(openedMenuType) >= 0) then {
|
||||
// Render all available nearby interactions
|
||||
call FUNC(renderActionPoints);
|
||||
|
||||
// Render all nearby interaction menus
|
||||
#define MAXINTERACTOBJECTS 3
|
||||
private ["_numInteractObjects","_numInteractions"];
|
||||
_numInteractObjects = 0;
|
||||
|
||||
_nearestObjects = nearestObjects [(getPos ACE_player), ["All"], 15];
|
||||
{
|
||||
_target = _x;
|
||||
|
||||
_numInteractions = 0;
|
||||
// Prevent interacting with yourself or your own vehicle
|
||||
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
||||
{
|
||||
// Only render them directly if they are base level actions
|
||||
if (count (_x select 1) == 0) then {
|
||||
// Try to render the menu
|
||||
_action = [_x,[]];
|
||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||
_numInteractions = _numInteractions + 1;
|
||||
};
|
||||
};
|
||||
} forEach GVAR(objectActionList);
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
_classActions = missionNamespace getVariable [_actionsVarName, []];
|
||||
{
|
||||
_action = _x;
|
||||
// Try to render the menu
|
||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||
_numInteractions = _numInteractions + 1;
|
||||
};
|
||||
} forEach _classActions;
|
||||
|
||||
// Limit the amount of objects the player can interact with
|
||||
if (_numInteractions > 0) then {
|
||||
_numInteractObjects = _numInteractObjects + 1;
|
||||
};
|
||||
};
|
||||
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};
|
||||
|
||||
} forEach _nearestObjects;
|
||||
|
||||
} else {
|
||||
if (GVAR(keyDownSelfAction)) then {
|
||||
|
||||
// Render only the self action menu
|
||||
_target = vehicle ACE_player;
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
|
||||
/*
|
||||
{
|
||||
_action = _x;
|
||||
// Only render them directly if they are base level actions
|
||||
if (count (_action select 7) == 1) then {
|
||||
[_target, _action, 0, [180, 360]] call FUNC(renderMenu);
|
||||
};
|
||||
} forEach GVAR(objectActionList);
|
||||
*/
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
|
||||
_classActions = missionNamespace getVariable [_actionsVarName, []];
|
||||
{
|
||||
_action = _x;
|
||||
|
||||
_pos = if !(visibleMap) then {
|
||||
(((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition)
|
||||
} else {
|
||||
[0.5, 0.5]
|
||||
};
|
||||
[_target, _action, _pos] call FUNC(renderBaseMenu);
|
||||
} forEach _classActions;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
|
||||
// Draw the red selector only when there's no cursor
|
||||
if !(uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
||||
[[0.5,0.5], "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa"] call FUNC(renderSelector);
|
||||
|
113
addons/interact_menu/functions/fnc_renderActionPoints.sqf
Normal file
113
addons/interact_menu/functions/fnc_renderActionPoints.sqf
Normal file
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Author: NouberNou and esteldunedain
|
||||
* Render all action points
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
*
|
||||
* Return value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
GVAR(currentOptions) = [];
|
||||
|
||||
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_objectActions","_target","_player","_action","_actionData","_active"];
|
||||
_player = ACE_player;
|
||||
|
||||
|
||||
_fnc_renderNearbyActions = {
|
||||
// Render all nearby interaction menus
|
||||
#define MAXINTERACTOBJECTS 3
|
||||
|
||||
_numInteractObjects = 0;
|
||||
_nearestObjects = nearestObjects [(getPos ACE_player), ["All"], 15];
|
||||
{
|
||||
_target = _x;
|
||||
|
||||
_numInteractions = 0;
|
||||
// Prevent interacting with yourself or your own vehicle
|
||||
if (_target != ACE_player && {_target != vehicle ACE_player}) then {
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(Act_%1), typeOf _target];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(actions), []];
|
||||
{
|
||||
// Only render them directly if they are base level actions
|
||||
if (count (_x select 1) == 0) then {
|
||||
// Try to render the menu
|
||||
_action = [_x,[]];
|
||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||
_numInteractions = _numInteractions + 1;
|
||||
};
|
||||
};
|
||||
} forEach GVAR(objectActionList);
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
_classActions = missionNamespace getVariable [_actionsVarName, []];
|
||||
{
|
||||
_action = _x;
|
||||
// Try to render the menu
|
||||
if ([_target, _action] call FUNC(renderBaseMenu)) then {
|
||||
_numInteractions = _numInteractions + 1;
|
||||
};
|
||||
} forEach _classActions;
|
||||
|
||||
// Limit the amount of objects the player can interact with
|
||||
if (_numInteractions > 0) then {
|
||||
_numInteractObjects = _numInteractObjects + 1;
|
||||
};
|
||||
};
|
||||
if (_numInteractObjects >= MAXINTERACTOBJECTS) exitWith {};
|
||||
|
||||
} forEach _nearestObjects;
|
||||
};
|
||||
|
||||
|
||||
|
||||
_fnc_renderSelfActions = {
|
||||
_target = _this;
|
||||
|
||||
// Iterate through object actions, find base level actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
|
||||
GVAR(objectActionList) = _target getVariable [QGVAR(selfActions), []];
|
||||
/*
|
||||
{
|
||||
_action = _x;
|
||||
// Only render them directly if they are base level actions
|
||||
if (count (_action select 7) == 1) then {
|
||||
[_target, _action, 0, [180, 360]] call FUNC(renderMenu);
|
||||
};
|
||||
} forEach GVAR(objectActionList);
|
||||
*/
|
||||
|
||||
// Iterate through base level class actions and render them if appropiate
|
||||
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
|
||||
_classActions = missionNamespace getVariable [_actionsVarName, []];
|
||||
{
|
||||
_action = _x;
|
||||
|
||||
_pos = if !(visibleMap) then {
|
||||
(((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition)
|
||||
} else {
|
||||
[0.5, 0.5]
|
||||
};
|
||||
[_target, _action, _pos] call FUNC(renderBaseMenu);
|
||||
} forEach _classActions;
|
||||
};
|
||||
|
||||
|
||||
// Render nearby actions, unit self actions or vehicle self actions as appropiate
|
||||
if (GVAR(openedMenuType) == 0) then {
|
||||
|
||||
if (vehicle ACE_player == ACE_player) then {
|
||||
call _fnc_renderNearbyActions;
|
||||
} else {
|
||||
(vehicle ACE_player) call _fnc_renderSelfActions;
|
||||
};
|
||||
|
||||
} else {
|
||||
ACE_player call _fnc_renderSelfActions;
|
||||
};
|
@ -44,7 +44,7 @@ if((count _this) > 2) then {
|
||||
};
|
||||
|
||||
// For non-self actions, exit if the action is too far away
|
||||
if (GVAR(keyDown) &&
|
||||
if (GVAR(openedMenuType) == 0 && vehicle ACE_player == ACE_player &&
|
||||
{(ACE_player modelToWorld (ACE_player selectionPosition "pilot")) distance _pos >= _distance}) exitWith {false};
|
||||
|
||||
// Exit if the action is behind you
|
||||
|
Loading…
Reference in New Issue
Block a user