Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed interaction to only one interaction point #406

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion addons/flashdrive/functions/fnc_compileDevice.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ private _config = missionNamespace getVariable _class_name;

if(_config isEqualType "") exitWith {};

[_entity, _config] call AE3_flashdrive_fnc_initInterface;

// Workaround, because the compiled config for USB interfaces does not contain a device name
private _tmpDeviceCfg = configFile >> "CfgVehicles" >> _class >> "AE3_Device";
private _parentActionName = getText (_tmpDeviceCfg >> "displayName");

[_entity, _config, _parentActionName] call AE3_flashdrive_fnc_initInterface;
109 changes: 57 additions & 52 deletions addons/flashdrive/functions/fnc_initInterface.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,84 @@
* Arguments:
* 0: Device <OBJECT>
* 1: Interface config <ARRAY>
* 2: Parent Action Name <STRING>
*
* Results:
* None
*/

params ["_device", "_config"];
params ["_device", "_config", "_parentActionName"];

private _flash_drives = {
params ["_target", "_player", "_params"];
_params params ["_config"];

private _actions = [];
private _class = configFile >> "CfgWeapons" >> "Item_FlashDisk_AE3";

private _add = {
if(!isDedicated) then
{
private _parentActionPath = [_device, _parentActionName] call AE3_main_fnc_interaction_addParentAction;

private _flash_drives =
{
params ["_target", "_player", "_params"];
([_target, _player] + _params) remoteExec ["AE3_flashdrive_fnc_connectFlashDrive", 2];
};
_params params ["_config"];

_config params ['_index', '_name', '_rel_pos', '_rot_yaw', '_rot_pitch', '_rot_roll'];
{
private _action = [_name, (getText (configFile >> "CfgWeapons" >> _x >> "displayName")), "", _add, {true}, {}, [_x, _config]] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} forEach (items _player select {inheritsFrom (configFile >> "CfgWeapons" >> _x) == _class});
private _actions = [];
private _class = configFile >> "CfgWeapons" >> "Item_FlashDisk_AE3";

_actions;
};
private _add = {
params ["_target", "_player", "_params"];
([_target, _player] + _params) remoteExec ["AE3_flashdrive_fnc_connectFlashDrive", 2];
};

private _children = {
params ["_target", "_player", "_params"];
_params params ['_flash_drives'];
_config params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
{
private _action = [_name, (getText (configFile >> "CfgWeapons" >> _x >> "displayName")), "", _add, {true}, {}, [_x, _config]] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
} forEach (items _player select {inheritsFrom (configFile >> "CfgWeapons" >> _x) == _class});

private _interfaces = _target getVariable "AE3_USB_Interfaces";
private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";
_actions;
};

private _actions = [];

private _condition =
private _children =
{
params ["_target", "_player", "_params"];
(_params select 0) params ['_index', '_name', '_rel_pos', '_rot_yaw', '_rot_pitch', '_rot_roll'];
_params params ["_flash_drives"];

private _interfaces = _target getVariable "AE3_USB_Interfaces";
private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

isNull (_occupiedList select _index);
};

{
_y params ['_index', '_name', '_rel_pos', '_rot_yaw', '_rot_pitch', '_rot_roll'];
private _actions = [];

if (isNull (_occupiedList select _index)) then
private _condition =
{
private _action = [_name, _name, "", {}, _condition, _flash_drives, [_y]] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
};
} forEach _interfaces;

_actions;
};
params ["_target", "_player", "_params"];
(_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
private _driveInfo = _params select 0;
if !(_driveInfo isEqualType []) then {
_driveInfo = _params select 1;
};
_driveInfo params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];

This change fixes #414, details here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to Dystopian's acemod/ACE3#9946, this rough fix won't be necessary, the next ACE3 Patch version will resolve the issue.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been fixed publicly by ACE v3.17.1.

private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

private _connect = ["AE3_USBInterfaceConnectAction", (localize "STR_AE3_Flashdrive_Interaction_Connect"), "",
{},
isNull (_occupiedList select _index);
};

{
_y params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];

if (isNull (_occupiedList select _index)) then
{
params ["_target", "_player", "_params"];
private _class = configFile >> "CfgWeapons" >> "Item_FlashDisk_AE3";
(0 < count (items _player select {inheritsFrom (configFile >> "CfgWeapons" >> _x) == _class})) and (alive _target)
},
_children,
[_flash_drives]
] call ace_interact_menu_fnc_createAction;
private _action = [_name, _name, "", {}, _condition, _flash_drives, [_y]] call ace_interact_menu_fnc_createAction;
_actions pushBack [_action, [], _target];
};
} forEach _interfaces;

if(!isDedicated) then
{
[_device, 0, ["ACE_MainActions"], _connect] call ace_interact_menu_fnc_addActionToObject;
_actions;
};

private _connect = ["AE3_USBInterfaceConnectAction", (localize "STR_AE3_Flashdrive_Interaction_Connect"), "",
{},
{
params ["_target", "_player", "_params"];
private _class = configFile >> "CfgWeapons" >> "Item_FlashDisk_AE3";
(0 < count (items _player select {inheritsFrom (configFile >> "CfgWeapons" >> _x) == _class})) and (alive _target)
},
_children,
[_flash_drives]
] call ace_interact_menu_fnc_createAction;

[_device, 0, _parentActionPath, _connect] call ace_interact_menu_fnc_addActionToObject;
};

if (isServer) then
Expand Down
24 changes: 11 additions & 13 deletions addons/interaction/functions/fnc_initInteraction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ params["_equipment", ["_name", "Equipment"], ["_closeState", 0], ["_initFnc", {}

private _openWrapper =
{
params['_target', ['_args', []]];
params["_target", ["_args", []]];

_openFnc = _target getVariable "AE3_interaction_fnc_open";
_result = [_target] + _args call _openFnc;
if(isNil '_result') then {_result = false};
if(isNil "_result") then {_result = false};

if(_result) then
{
_target setVariable ['AE3_interaction_closeState', 0, true];
_target setVariable ["AE3_interaction_closeState", 0, true];
};
};

/* ---------------------------------------- */

private _closeWrapper =
{
params['_target', ['_args', []]];
params["_target", ["_args", []]];

_closeFnc = _target getVariable "AE3_interaction_fnc_close";
_result = [_target] + _args call _closeFnc;
if(isNil '_result') then {_result = false};
if(isNil "_result") then {_result = false};

if(_result) then
{
_target setVariable ['AE3_interaction_closeState', 1, true];
_target setVariable ["AE3_interaction_closeState", 1, true];
};
};

Expand Down Expand Up @@ -89,9 +89,7 @@ if (!isDedicated) then

/* ---------------------------------------- */

private _parentAction = ["AE3_EquipmentAction", _name, "", {}, {true}] call ace_interact_menu_fnc_createAction;

[_equipment, 0, ["ACE_MainActions"], _parentAction] call ace_interact_menu_fnc_addActionToObject;
private _parentActionPath = [_equipment, _name] call AE3_main_fnc_interaction_addParentAction;

// Add open/close action
if (!((_openFnc isEqualTo {}) || (_closeFnc isEqualTo {}))) then
Expand All @@ -104,7 +102,7 @@ if (!isDedicated) then
params["_target"];
[_target] call (_target getVariable "AE3_interaction_fnc_openWrapper");

if (_target getVariable 'AE3_power_powerState' == 2) then
if (_target getVariable "AE3_power_powerState" == 2) then
{
[_target] call (_target getVariable "AE3_power_fnc_turnOnWrapper");
};
Expand All @@ -122,7 +120,7 @@ if (!isDedicated) then
params ["_target"];
[_target] call (_target getVariable "AE3_interaction_fnc_closeWrapper");

if (_target getVariable 'AE3_power_powerState' == 1) then
if (_target getVariable "AE3_power_powerState" == 1) then
{
[_target] call (_target getVariable "AE3_power_fnc_standbyWrapper");
};
Expand All @@ -131,8 +129,8 @@ if (!isDedicated) then
{(_target call (_target getVariable ["AE3_interaction_fnc_closeActionCondition", {true}])) and (alive _target) and (_target getVariable "AE3_interaction_closeState" == 0) },
{}] call ace_interact_menu_fnc_createAction;

[_equipment, 0, ["ACE_MainActions", "AE3_EquipmentAction"], _open] call ace_interact_menu_fnc_addActionToObject;
[_equipment, 0, ["ACE_MainActions", "AE3_EquipmentAction"], _close] call ace_interact_menu_fnc_addActionToObject;
[_equipment, 0, _parentActionPath, _open] call ace_interact_menu_fnc_addActionToObject;
[_equipment, 0, _parentActionPath, _close] call ace_interact_menu_fnc_addActionToObject;
};
};

Expand Down
10 changes: 4 additions & 6 deletions addons/interaction/functions/fnc_initLaptop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ else

if(!isDedicated) then
{
// add the armaOS Menu to ACE3 Interaction Menu
private _armaOSAction = ["AE3_ArmaOSAction", localize "STR_AE3_ArmaOS_Config_ArmaOSDisplayName", "", {}, {true}] call ace_interact_menu_fnc_createAction;
[_laptop, 0, ["ACE_MainActions"], _armaOSAction] call ace_interact_menu_fnc_addActionToObject;
private _parentActionPath = _equipment getVariable ["AE3_parentActionPath", []];
y0014984 marked this conversation as resolved.
Show resolved Hide resolved

// add the 'use' interaction to the armaOS Menu
// add the "use" interaction to the armaOS Menu
private _useAction =
[
"AE3_UseAction", // internal name
localize "STR_AE3_ArmaOS_Config_UseDisplayName", // visible name
localize "STR_AE3_ArmaOS_Config_UseDisplayName" + " " + localize "STR_AE3_ArmaOS_Config_ArmaOSDisplayName", // visible name
"", // icon
{
// statement
Expand All @@ -47,5 +45,5 @@ if(!isDedicated) then
(isNull (_target getVariable ["AE3_computer_mutex", objNull]))
}
] call ace_interact_menu_fnc_createAction;
[_laptop, 0, ["ACE_MainActions", "AE3_ArmaOSAction"], _useAction] call ace_interact_menu_fnc_addActionToObject; // 0 = action; 1 = self-action
[_laptop, 0, _parentActionPath, _useAction] call ace_interact_menu_fnc_addActionToObject; // 0 = action; 1 = self-action
};
5 changes: 4 additions & 1 deletion addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ PREP(zeus_module_addConnection);

PREP(zeus_checkForComputer);

PREP(zeus_isConnectionAllowed);
PREP(zeus_isConnectionAllowed);

/* Interaction */
PREP(interaction_addParentAction);
24 changes: 24 additions & 0 deletions addons/main/functions/fnc_interaction_addParentAction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Creates the parent iteraction for every device and returns the action path.
*
* Arguments:
* 0: Entity <OBJECT>
* 1: Action Name <STRING>
*
* Return:
* Action Path <ARRAY>
*
*/

params["_entity", "_name"];

// get or add parent action
private _parentActionPath = _entity getVariable ["AE3_parentActionPath", []];
if (_parentActionPath isEqualTo []) then
{
private _parentAction = ["AE3_ParentAction", _name, "", {}, {true}] call ace_interact_menu_fnc_createAction;
_parentActionPath = [_entity, 0, ["ACE_MainActions"], _parentAction] call ace_interact_menu_fnc_addActionToObject;
_entity setVariable ["AE3_parentActionPath", _parentActionPath];
};

_parentActionPath;
48 changes: 25 additions & 23 deletions addons/network/functions/fnc_initNetworkDevice.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,38 @@ private _childs =
_actions
};

private _connect = ["AE3_Network_ConnectAction", localize "STR_AE3_Network_Interaction_ConnectToRouter", "",
{},
{
params ["_target", "_player", "_params"];
_params params ["_device"];
(alive _target) and (isNull (_device getVariable ["AE3_network_parent", objNull]))
},
_childs,
[_entity]
] call ace_interact_menu_fnc_createAction;

private _disconnect = ["AE3_Network_DisconnectAction", localize "STR_AE3_Network_Interaction_DisconnectFromRouter", "",
if (!isDedicated) then
{
private _connect = ["AE3_Network_ConnectAction", localize "STR_AE3_Network_Interaction_ConnectToRouter", "",
{},
{
params ["_target", "_player", "_params"];
_params params ["_device"];
[_device] call AE3_network_fnc_disconnect;
},
{
params ["_target", "_player", "_params"];
_params params ["_device"];
(alive _target) and (!isNull (_device getVariable ["AE3_network_parent", objNull]))
(alive _target) and (isNull (_device getVariable ["AE3_network_parent", objNull]))
},
{},
_childs,
[_entity]
] call ace_interact_menu_fnc_createAction;

if (!isDedicated) then
{
[_entity, 0, ["ACE_MainActions", "AE3_DeviceAction"], _connect] call ace_interact_menu_fnc_addActionToObject;
[_entity, 0, ["ACE_MainActions", "AE3_DeviceAction"], _disconnect] call ace_interact_menu_fnc_addActionToObject;
private _disconnect = ["AE3_Network_DisconnectAction", localize "STR_AE3_Network_Interaction_DisconnectFromRouter", "",
{
params ["_target", "_player", "_params"];
_params params ["_device"];
[_device] call AE3_network_fnc_disconnect;
},
{
params ["_target", "_player", "_params"];
_params params ["_device"];
(alive _target) and (!isNull (_device getVariable ["AE3_network_parent", objNull]))
},
{},
[_entity]
] call ace_interact_menu_fnc_createAction;

private _parentActionPath = _entity getVariable ["AE3_parentActionPath", ""];
y0014984 marked this conversation as resolved.
Show resolved Hide resolved

[_entity, 0, _parentActionPath, _connect] call ace_interact_menu_fnc_addActionToObject;
[_entity, 0, _parentActionPath, _disconnect] call ace_interact_menu_fnc_addActionToObject;
};


Expand Down
Loading