mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
basic self actions
This commit is contained in:
parent
25645c2ae9
commit
043987fc93
@ -13,7 +13,7 @@ class Extended_PostInit_EventHandlers {
|
|||||||
class Extended_InitPost_EventHandlers {
|
class Extended_InitPost_EventHandlers {
|
||||||
class All {
|
class All {
|
||||||
class GVAR(compileMenu) {
|
class GVAR(compileMenu) {
|
||||||
init = QUOTE(_this call FUNC(compileMenu));
|
init = QUOTE(_this call FUNC(compileMenu);_this call FUNC(compileMenuSelfAction));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
@ -15,13 +15,27 @@ _fnc = {
|
|||||||
["ACE3",
|
["ACE3",
|
||||||
"Interact Key",
|
"Interact Key",
|
||||||
{_this call FUNC(keyDown)},
|
{_this call FUNC(keyDown)},
|
||||||
[15, [false, false, false]],
|
[219, [false, false, false]],
|
||||||
false,
|
false,
|
||||||
"keydown"] call cba_fnc_registerKeybind;
|
"keydown"] call cba_fnc_registerKeybind;
|
||||||
|
|
||||||
["ACE3",
|
["ACE3",
|
||||||
"Interact Key",
|
"Interact Key",
|
||||||
{_this call FUNC(keyUp)},
|
{_this call FUNC(keyUp)},
|
||||||
[15, [false, false, false]],
|
[219, [false, false, false]],
|
||||||
|
false,
|
||||||
|
"keyUp"] call cba_fnc_registerKeybind;
|
||||||
|
|
||||||
|
["ACE3",
|
||||||
|
"Self Actions Key",
|
||||||
|
{_this call FUNC(keyDownSelfAction)},
|
||||||
|
[219, [false, true, false]],
|
||||||
|
false,
|
||||||
|
"keydown"] call cba_fnc_registerKeybind;
|
||||||
|
|
||||||
|
["ACE3",
|
||||||
|
"Self Actions Key",
|
||||||
|
{_this call FUNC(keyUpSelfAction)},
|
||||||
|
[219, [false, true, false]],
|
||||||
false,
|
false,
|
||||||
"keyUp"] call cba_fnc_registerKeybind;
|
"keyUp"] call cba_fnc_registerKeybind;
|
@ -10,14 +10,18 @@ PREP(probe);
|
|||||||
PREP(rotateVectLineGetMap);
|
PREP(rotateVectLineGetMap);
|
||||||
PREP(rotateVectLine);
|
PREP(rotateVectLine);
|
||||||
PREP(keyDown);
|
PREP(keyDown);
|
||||||
|
PREP(keyDownSelfAction);
|
||||||
PREP(keyUp);
|
PREP(keyUp);
|
||||||
|
PREP(keyUpSelfAction);
|
||||||
PREP(compileMenu);
|
PREP(compileMenu);
|
||||||
|
PREP(compileMenuSelfAction);
|
||||||
PREP(addAction);
|
PREP(addAction);
|
||||||
PREP(removeAction);
|
PREP(removeAction);
|
||||||
|
|
||||||
GVAR(toRender) = [];
|
GVAR(toRender) = [];
|
||||||
|
|
||||||
GVAR(keyDown) = false;
|
GVAR(keyDown) = false;
|
||||||
|
GVAR(keyDownSelfAction) = false;
|
||||||
GVAR(keyDownTime) = 0;
|
GVAR(keyDownTime) = 0;
|
||||||
|
|
||||||
GVAR(lastTime) = diag_tickTime;
|
GVAR(lastTime) = diag_tickTime;
|
||||||
|
99
addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf
Normal file
99
addons/interact_menu/functions/fnc_compileMenuSelfAction.sqf
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
//fnc_compileMenuSelfAction.sqf
|
||||||
|
#include "script_component.hpp";
|
||||||
|
// diag_log text format["COMPILE ACTIONS: %1", _this];
|
||||||
|
|
||||||
|
_object = _this select 0;
|
||||||
|
_objectType = typeOf _object;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
displayName = "$STR_ACE_Hearing_Earbuds_On";
|
||||||
|
condition = QUOTE( !([_player] call FUNC(hasEarPlugsIn)) && {'ACE_EarBuds' in items _player} );
|
||||||
|
statement = QUOTE( [_player] call FUNC(putInEarPlugs) );
|
||||||
|
showDisabled = 0;
|
||||||
|
priority = 2.5;
|
||||||
|
icon = PATHTOF(UI\ACE_earplugs_x_ca.paa);
|
||||||
|
hotkey = "E";
|
||||||
|
enableInside = 1;
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"Launch",
|
||||||
|
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
||||||
|
[0,0,0],
|
||||||
|
{ (_this select 0) setVelocity [0,0,10]; },
|
||||||
|
{ true },
|
||||||
|
1,
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
*/
|
||||||
|
|
||||||
|
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
|
||||||
|
|
||||||
|
|
||||||
|
_recurseFnc = {
|
||||||
|
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_condition", "_showDisabled",
|
||||||
|
"_enableInside", "_children", "_entry", "_actionsCfg"];
|
||||||
|
_actions = [];
|
||||||
|
_actionsCfg = _this select 0;
|
||||||
|
for "_i" from 0 to (count _actionsCfg)-1 do {
|
||||||
|
_entryCfg = _actionsCfg select _i;
|
||||||
|
if(isClass _entryCfg) then {
|
||||||
|
_displayName = getText (_entryCfg >> "displayName");
|
||||||
|
_icon = getText (_entryCfg >> "icon");
|
||||||
|
_statement = compile (getText (_entryCfg >> "statement"));
|
||||||
|
|
||||||
|
_condition = getText (_entryCfg >> "condition");
|
||||||
|
if (_condition == "") then {_condition = "true"};
|
||||||
|
|
||||||
|
// Add canInteract (including exceptions) and canInteractWith to condition
|
||||||
|
_condition = _condition + format [QUOTE( && {%1 call EGVAR(common,canInteract)} && {[ARR_2(ACE_player, _target)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
||||||
|
|
||||||
|
_showDisabled = getNumber (_entryCfg >> "showDisabled");
|
||||||
|
_enableInside = getNumber (_entryCfg >> "enableInside");
|
||||||
|
|
||||||
|
_condition = compile _condition;
|
||||||
|
// diag_log text format["_condition: %1", _condition];
|
||||||
|
_children = [];
|
||||||
|
if(isArray (_entryCfg >> "subMenu")) then {
|
||||||
|
_subMenuDef = getArray (_entryCfg >> "subMenu");
|
||||||
|
_childMenuName = _subMenuDef select 0;
|
||||||
|
_childMenuCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions" >> _childMenuName;
|
||||||
|
_children = [_childMenuCfg] call _recurseFnc;
|
||||||
|
};
|
||||||
|
_entry = [
|
||||||
|
_displayName,
|
||||||
|
_icon,
|
||||||
|
[0,0,0],
|
||||||
|
_statement,
|
||||||
|
_condition,
|
||||||
|
3, //distace
|
||||||
|
_children,
|
||||||
|
GVAR(uidCounter)
|
||||||
|
];
|
||||||
|
GVAR(uidCounter) = GVAR(uidCounter) + 1;
|
||||||
|
_actions pushBack _entry;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
_actions
|
||||||
|
};
|
||||||
|
|
||||||
|
_actions = [_actionsCfg] call _recurseFnc;
|
||||||
|
|
||||||
|
_actions = [[
|
||||||
|
"Self Actions",
|
||||||
|
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
||||||
|
"Spine3",
|
||||||
|
{ true },
|
||||||
|
{ true },
|
||||||
|
5,
|
||||||
|
_actions,
|
||||||
|
GVAR(uidCounter)
|
||||||
|
]
|
||||||
|
];
|
||||||
|
GVAR(uidCounter) = GVAR(uidCounter) + 1;
|
||||||
|
|
||||||
|
_object setVariable [QUOTE(GVAR(selfActionData)), _actions];
|
11
addons/interact_menu/functions/fnc_keyDownSelfAction.sqf
Normal file
11
addons/interact_menu/functions/fnc_keyDownSelfAction.sqf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//fnc_keyDownSelfAction.sqf
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
if(!GVAR(keyDownSelfAction)) then {
|
||||||
|
GVAR(keyDownSelfAction) = true;
|
||||||
|
GVAR(keyDown) = false;
|
||||||
|
GVAR(keyDownTime) = diag_tickTime;
|
||||||
|
|
||||||
|
GVAR(selfMenuOffset) = [sin getDir ACE_player, cos getDir ACE_player, 0] vectorMultiply 2;
|
||||||
|
};
|
||||||
|
true
|
15
addons/interact_menu/functions/fnc_keyUpSelfAction.sqf
Normal file
15
addons/interact_menu/functions/fnc_keyUpSelfAction.sqf
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
//fnc_keyUp.sqf
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
GVAR(keyDownSelfAction) = false;
|
||||||
|
if(GVAR(actionSelected)) then {
|
||||||
|
this = GVAR(selectedTarget);
|
||||||
|
_player = ACE_Player;
|
||||||
|
_target = GVAR(selectedTarget);
|
||||||
|
[GVAR(selectedTarget), player] call GVAR(selectedAction);
|
||||||
|
};
|
||||||
|
GVAR(expanded) = false;
|
||||||
|
GVAR(lastPath) = [];
|
||||||
|
GVAR(menuDepthPath) = [];
|
||||||
|
GVAR(vecLineMap) = [];
|
||||||
|
true
|
@ -6,7 +6,7 @@ _foundTarget = false;
|
|||||||
_cursorPos1 = positionCameraToWorld [0, 0, 0];
|
_cursorPos1 = positionCameraToWorld [0, 0, 0];
|
||||||
_cursorPos2 = positionCameraToWorld [0, 0, 2];
|
_cursorPos2 = positionCameraToWorld [0, 0, 2];
|
||||||
GVAR(currentOptions) = [];
|
GVAR(currentOptions) = [];
|
||||||
if((count GVAR(toRender)) > 0 && GVAR(keyDown)) then {
|
if((count GVAR(toRender)) > 0 && (GVAR(keyDown) || GVAR(keyDownSelfAction))) then {
|
||||||
if((count GVAR(vecLineMap)) == 0 || ((count GVAR(menuDepthPath)) > 0 && (getPosASL player) distance GVAR(lastPos) > 0.01)) then {
|
if((count GVAR(vecLineMap)) == 0 || ((count GVAR(menuDepthPath)) > 0 && (getPosASL player) distance GVAR(lastPos) > 0.01)) then {
|
||||||
GVAR(lastPos) = getPosASL player;
|
GVAR(lastPos) = getPosASL player;
|
||||||
_cursorVec = [_cursorPos2, _cursorPos1] call BIS_fnc_vectorFromXtoY;
|
_cursorVec = [_cursorPos2, _cursorPos1] call BIS_fnc_vectorFromXtoY;
|
||||||
@ -18,6 +18,8 @@ if((count GVAR(toRender)) > 0 && GVAR(keyDown)) then {
|
|||||||
|
|
||||||
GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap);
|
GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap);
|
||||||
};
|
};
|
||||||
|
if (GVAR(keyDown)) then {
|
||||||
|
// Render all nearby interaction menus
|
||||||
{
|
{
|
||||||
if(!(_forEachIndex in GVAR(filter))) then {
|
if(!(_forEachIndex in GVAR(filter))) then {
|
||||||
GVAR(renderDepth) = 0;
|
GVAR(renderDepth) = 0;
|
||||||
@ -27,10 +29,17 @@ if((count GVAR(toRender)) > 0 && GVAR(keyDown)) then {
|
|||||||
} forEach (_renderTargets select 1);
|
} forEach (_renderTargets select 1);
|
||||||
};
|
};
|
||||||
} forEach GVAR(toRender);
|
} forEach GVAR(toRender);
|
||||||
|
} else {
|
||||||
|
// Render only the self action menu
|
||||||
|
_actions = (ACE_player getVariable QGVAR(selfActionData)) select 0;
|
||||||
|
_pos = (ACE_player modelToWorld (ACE_player selectionPosition "spine3")) vectorAdd GVAR(selfMenuOffset);
|
||||||
|
[ACE_player, _actions, 0, _pos] call FUNC(renderMenu);
|
||||||
|
};
|
||||||
|
|
||||||
// player sideChat format["c: %1", count GVAR(toRender)];
|
// player sideChat format["c: %1", count GVAR(toRender)];
|
||||||
};
|
};
|
||||||
|
|
||||||
if(GVAR(keyDown)) then {
|
if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
|
||||||
|
|
||||||
_cursorScreenPos = worldToScreen _cursorPos2;
|
_cursorScreenPos = worldToScreen _cursorPos2;
|
||||||
_closestDistance = 1000000;
|
_closestDistance = 1000000;
|
||||||
|
@ -16,78 +16,6 @@ GVAR(isOpeningDoor) = false;
|
|||||||
|
|
||||||
|
|
||||||
// Add keybinds
|
// Add keybinds
|
||||||
["ACE3",
|
|
||||||
localize "STR_ACE_Interaction_InteractionMenu",
|
|
||||||
{
|
|
||||||
// Conditions: canInteract
|
|
||||||
_exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"];
|
|
||||||
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
|
|
||||||
// Conditions: specific
|
|
||||||
if !(isNull (findDisplay 1713999)) exitWith {false};
|
|
||||||
|
|
||||||
// Statement
|
|
||||||
call FUNC(onButtonDown);
|
|
||||||
true
|
|
||||||
},
|
|
||||||
[219, [false, false, false]],
|
|
||||||
false,
|
|
||||||
"keydown"
|
|
||||||
] call cba_fnc_registerKeybind;
|
|
||||||
|
|
||||||
["ACE3",
|
|
||||||
localize "STR_ACE_Interaction_InteractionMenu",
|
|
||||||
{
|
|
||||||
// Conditions: canInteract
|
|
||||||
_exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), "ACE_Interaction_isNotSwimming"];
|
|
||||||
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
|
|
||||||
// Conditions: specific
|
|
||||||
if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false};
|
|
||||||
|
|
||||||
// Statement
|
|
||||||
if (GVAR(MenuType) mod 2 == 0) then {call FUNC(onButtonUp)};
|
|
||||||
true
|
|
||||||
},
|
|
||||||
[219, [false, false, false]],
|
|
||||||
false,
|
|
||||||
"keyup"
|
|
||||||
] call cba_fnc_registerKeybind;
|
|
||||||
|
|
||||||
["ACE3",
|
|
||||||
localize "STR_ACE_Interaction_InteractionMenuSelf",
|
|
||||||
{
|
|
||||||
// Conditions: canInteract
|
|
||||||
_exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming", "ACE_Common_notOnMap"];
|
|
||||||
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
|
|
||||||
// Conditions: specific
|
|
||||||
if !(isNull (findDisplay 1713999)) exitWith {false};
|
|
||||||
|
|
||||||
// Statement
|
|
||||||
call FUNC(onButtonDownSelf);
|
|
||||||
true
|
|
||||||
},
|
|
||||||
[219, [false, true, false]],
|
|
||||||
false,
|
|
||||||
"keydown"
|
|
||||||
] call cba_fnc_registerKeybind;
|
|
||||||
|
|
||||||
["ACE3",
|
|
||||||
localize "STR_ACE_Interaction_InteractionMenuSelf",
|
|
||||||
{
|
|
||||||
// Conditions: canInteract
|
|
||||||
_exceptions = ["ACE_Drag_isNotDragging", "ACE_Medical_canTreat", QEGVAR(captives,isNotEscorting), QEGVAR(captives,isNotSurrendering), "ACE_Interaction_isNotSwimming"];
|
|
||||||
if !(_exceptions call EGVAR(common,canInteract)) exitWith {false};
|
|
||||||
// Conditions: specific
|
|
||||||
if !(!isNull (findDisplay 1713999) && {QGVAR(AutoCloseMenu)}) exitWith {false};
|
|
||||||
|
|
||||||
// Statement
|
|
||||||
if (GVAR(MenuType) mod 2 == 1) then {call FUNC(onButtonUp)};
|
|
||||||
true
|
|
||||||
},
|
|
||||||
[219, [false, true, false]],
|
|
||||||
false,
|
|
||||||
"keyup"
|
|
||||||
] call cba_fnc_registerKeybind;
|
|
||||||
|
|
||||||
["ACE3",
|
["ACE3",
|
||||||
localize "STR_ACE_Interaction_OpenDoor",
|
localize "STR_ACE_Interaction_OpenDoor",
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user