2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-02-21 20:11:03 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: NouberNou and esteldunedain
|
2015-02-27 04:55:16 +00:00
|
|
|
* Compile the action menu from config for an object's class
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-11 19:26:58 +00:00
|
|
|
* 0: Object or class name <OBJECT> or <STRING>
|
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
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [bob] call ACE_interact_menu_fnc_compileMenu
|
|
|
|
*
|
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 ["_target"];
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _objectType = _target;
|
2015-11-20 17:40:31 +00:00
|
|
|
if (_target isEqualType objNull) then {
|
2015-03-11 19:26:58 +00:00
|
|
|
_objectType = typeOf _target;
|
|
|
|
};
|
2016-03-06 05:22:38 +00:00
|
|
|
private _namespace = GVAR(ActNamespace);
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
// Exit if the action menu is already compiled for this class
|
2020-02-11 22:43:08 +00:00
|
|
|
if (!isNil {_namespace getVariable _objectType}) exitWith {};
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2019-12-07 20:58:44 +00:00
|
|
|
if (_objectType isKindOf "VirtualMan_F") exitWith { // these have config: isPlayableLogic = 1
|
2019-02-23 00:54:07 +00:00
|
|
|
TRACE_1("skipping playable logic",_objectType);
|
|
|
|
_namespace setVariable [_objectType, []];
|
|
|
|
};
|
|
|
|
|
2019-12-07 20:58:44 +00:00
|
|
|
if ((_objectType isKindOf "CAManBase") && {!isNil QGVAR(cacheManActions)}) exitWith {
|
|
|
|
_namespace setVariable [_objectType, +GVAR(cacheManActions)]; // copy
|
|
|
|
};
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _recurseFnc = {
|
|
|
|
params ["_actionsCfg", "_parentDistance"];
|
|
|
|
private _actions = [];
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-05-17 18:51:59 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _entryCfg = _x;
|
2020-02-11 22:43:08 +00:00
|
|
|
if (isClass _entryCfg) then {
|
2016-01-08 04:43:37 +00:00
|
|
|
private _displayName = getText (_entryCfg >> "displayName");
|
|
|
|
private _distance = _parentDistance;
|
|
|
|
if (isNumber (_entryCfg >> "distance")) then {_distance = getNumber (_entryCfg >> "distance");};
|
2016-10-02 10:55:31 +00:00
|
|
|
// if (_distance < _parentDistance) then {WARNING_3("[%1] distance %2 less than parent %3", configName _entryCfg, _distance, _parentDistance);};
|
2018-05-31 15:57:46 +00:00
|
|
|
private _icon = if (isArray (_entryCfg >> "icon")) then {
|
|
|
|
getArray (_entryCfg >> "icon");
|
|
|
|
} else {
|
|
|
|
[getText (_entryCfg >> "icon"), "#FFFFFF"];
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
private _statement = compile (getText (_entryCfg >> "statement"));
|
2015-04-14 23:21:11 +00:00
|
|
|
|
2015-05-01 04:56:39 +00:00
|
|
|
// If the position entry is present, compile it
|
2016-01-08 04:43:37 +00:00
|
|
|
private _position = getText (_entryCfg >> "position");
|
2015-05-01 04:56:39 +00:00
|
|
|
if (_position != "") then {
|
|
|
|
_position = compile _position;
|
2015-04-14 23:21:11 +00:00
|
|
|
} else {
|
2015-05-01 04:56:39 +00:00
|
|
|
// If the not, but the selection entry is present use that
|
|
|
|
_position = getText (_entryCfg >> "selection");
|
|
|
|
if (_position != "") then {
|
|
|
|
_position = compile format ["_target selectionPosition '%1'", _position];
|
|
|
|
} else {
|
|
|
|
// Otherwise, just use the origin
|
|
|
|
_position = {[0,0,0]};
|
2015-04-14 23:21:11 +00:00
|
|
|
};
|
2015-02-19 18:36:27 +00:00
|
|
|
};
|
2015-04-14 23:21:11 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _condition = getText (_entryCfg >> "condition");
|
2015-01-20 05:41:04 +00:00
|
|
|
|
2020-12-17 20:28:54 +00:00
|
|
|
if (configName _entryCfg == "ACE_MainActions") then {
|
|
|
|
if (_condition isEqualTo "") then {_condition = "true"};
|
|
|
|
} else {
|
|
|
|
// Add canInteract (including exceptions) and canInteractWith to condition
|
|
|
|
private _canInteractCondition = format [QUOTE([ARR_3(ACE_player,_target,%1)] call EFUNC(common,canInteractWith)), getArray (_entryCfg >> "exceptions")];
|
|
|
|
private _conditionFormatPattern = ["%1 && {%2}", "%2"] select (_condition isEqualTo "" || {_condition == "true"});
|
|
|
|
_condition = format [_conditionFormatPattern, _condition, _canInteractCondition];
|
2015-04-25 21:02:59 +00:00
|
|
|
};
|
2015-03-19 16:00:10 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _insertChildren = compile (getText (_entryCfg >> "insertChildren"));
|
|
|
|
private _modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
|
2015-01-20 05:41:04 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
|
|
|
private _enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
|
|
|
private _canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
|
|
|
private _runOnHover = false;
|
2015-05-28 16:02:31 +00:00
|
|
|
if (isText (_entryCfg >> "runOnHover")) then {
|
|
|
|
_runOnHover = compile getText (_entryCfg >> "runOnHover");
|
|
|
|
} else {
|
|
|
|
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
|
|
|
};
|
2022-10-22 00:28:51 +00:00
|
|
|
private _doNotCheckLOS = getNumber (_entryCfg >> "doNotCheckLOS") > 0;
|
2015-01-20 05:41:04 +00:00
|
|
|
|
2015-01-18 18:38:27 +00:00
|
|
|
_condition = compile _condition;
|
2016-01-08 04:43:37 +00:00
|
|
|
private _children = [_entryCfg, _distance] call _recurseFnc;
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _entry = [
|
2015-03-03 02:29:57 +00:00
|
|
|
[
|
2015-03-20 02:32:44 +00:00
|
|
|
configName _entryCfg,
|
2015-03-03 02:29:57 +00:00
|
|
|
_displayName,
|
|
|
|
_icon,
|
|
|
|
_statement,
|
|
|
|
_condition,
|
2015-03-19 16:00:10 +00:00
|
|
|
_insertChildren,
|
2015-03-20 02:32:44 +00:00
|
|
|
[],
|
2015-05-01 04:56:39 +00:00
|
|
|
_position,
|
2015-03-20 02:32:44 +00:00
|
|
|
_distance,
|
2022-10-22 00:28:51 +00:00
|
|
|
[_showDisabled, _enableInside, _canCollapse, _runOnHover, _doNotCheckLOS],
|
2015-04-17 02:53:54 +00:00
|
|
|
_modifierFunction
|
2015-03-03 02:29:57 +00:00
|
|
|
],
|
|
|
|
_children
|
2015-01-18 18:38:27 +00:00
|
|
|
];
|
|
|
|
_actions pushBack _entry;
|
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
nil
|
|
|
|
} count (configProperties [_actionsCfg, "isClass _x", true]);
|
2015-01-18 18:38:27 +00:00
|
|
|
_actions
|
|
|
|
};
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2016-01-10 04:05:40 +00:00
|
|
|
TRACE_1("Building ACE_Actions",_objectType);
|
|
|
|
private _actions = [_actionsCfg, 0] call _recurseFnc;
|
|
|
|
|
2017-02-10 18:49:10 +00:00
|
|
|
// ace_interaction_fnc_addPassengerAction expects ACE_MainActions to be first
|
|
|
|
// Other mods can change the order that configs are added, so we should verify this now and resort if needed
|
2019-08-02 01:52:20 +00:00
|
|
|
if (_objectType isKindOf "CAManBase") then {
|
2017-02-10 18:49:10 +00:00
|
|
|
if ((((_actions select 0) select 0) select 0) != "ACE_MainActions") then {
|
|
|
|
INFO_1("ACE_MainActions not first for man [%1]",_objectType);
|
|
|
|
private _mainActions = [];
|
|
|
|
{
|
|
|
|
if (((_x select 0) select 0) == "ACE_MainActions") then {
|
|
|
|
_mainActions = _actions deleteAt _forEachIndex;
|
|
|
|
};
|
|
|
|
} forEach _actions;
|
|
|
|
if (_mainActions isEqualTo []) exitWith {ERROR_1("ACE_MainActions not found on man [%1]",_objectType);};
|
|
|
|
_actions = [_mainActions] + _actions; // resort array with ACE_MainActions first
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-03-06 05:22:38 +00:00
|
|
|
_namespace setVariable [_objectType, _actions];
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
/*
|
|
|
|
[
|
|
|
|
[
|
2015-03-03 02:29:57 +00:00
|
|
|
[
|
2015-03-20 02:32:44 +00:00
|
|
|
"MyAction",
|
2015-03-03 02:29:57 +00:00
|
|
|
"My Action",
|
|
|
|
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
|
|
|
|
{ (_this select 0) setVelocity [0,0,10]; },
|
|
|
|
{ true },
|
2015-03-20 02:32:44 +00:00
|
|
|
{},
|
|
|
|
[],
|
2015-05-01 04:56:39 +00:00
|
|
|
{[0,0,0]},
|
2015-03-03 02:29:57 +00:00
|
|
|
1,
|
2016-01-08 04:43:37 +00:00
|
|
|
[false,false,false,false,false]
|
2015-03-03 02:29:57 +00:00
|
|
|
],
|
|
|
|
[children actions]
|
2015-02-27 04:55:16 +00:00
|
|
|
]
|
|
|
|
]
|
|
|
|
*/
|