ACE3/addons/interact_menu/functions/fnc_compileMenu.sqf

96 lines
3.0 KiB
Plaintext
Raw Normal View History

2015-02-21 20:11:03 +00:00
/*
* Author: NouberNou and CAA-Picard
* Compile the action menu from config for an object's class
2015-02-21 20:11:03 +00:00
*
* Argument:
* 0: Object <OBJECT>
*
* Return value:
* None
*
* Public: No
*/
2015-01-18 18:38:27 +00:00
#include "script_component.hpp";
2015-02-21 20:11:03 +00:00
EXPLODE_1_PVT(_this,_object);
2015-01-18 18:38:27 +00:00
private ["_objectType","_actionsVarName"];
2015-02-21 20:11:03 +00:00
_objectType = typeOf _object;
_actionsVarName = format [QGVAR(Act_%1), _objectType];
2015-01-18 18:38:27 +00:00
// Exit if the action menu is already compiled for this class
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
2015-01-18 18:38:27 +00:00
private "_recurseFnc";
2015-01-18 18:38:27 +00:00
_recurseFnc = {
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
"_enableInside", "_children", "_entry", "_entryCfg", "_fullPath"];
EXPLODE_2_PVT(_this,_actionsCfg,_parentPath);
2015-01-18 18:38:27 +00:00
_actions = [];
for "_i" from 0 to (count _actionsCfg) - 1 do {
2015-01-18 18:38:27 +00:00
_entryCfg = _actionsCfg select _i;
if(isClass _entryCfg) then {
_displayName = getText (_entryCfg >> "displayName");
_distance = getNumber (_entryCfg >> "distance");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
_selection = getText (_entryCfg >> "selection");
if (_selection == "") then {
_selection = [0,0,0];
};
2015-01-18 18:38:27 +00:00
_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")];
2015-01-18 18:38:27 +00:00
_showDisabled = getNumber (_entryCfg >> "showDisabled");
_enableInside = getNumber (_entryCfg >> "enableInside");
_fullPath = (+ _parentPath);
_fullPath pushBack (configName _entryCfg);
2015-01-18 18:38:27 +00:00
_condition = compile _condition;
_children = [_entryCfg, _fullPath] call _recurseFnc;
2015-01-18 18:38:27 +00:00
_entry = [
_displayName,
_icon,
_selection,
2015-01-18 18:38:27 +00:00
_statement,
_condition,
_distance,
_children,
GVAR(uidCounter),
_fullPath
2015-01-18 18:38:27 +00:00
];
2015-02-19 13:49:36 +00:00
GVAR(uidCounter) = GVAR(uidCounter) + 1;
2015-01-18 18:38:27 +00:00
_actions pushBack _entry;
};
};
_actions
};
private "_actionsCfg";
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
missionNamespace setVariable [_actionsVarName, [_actionsCfg, []] call _recurseFnc];
2015-01-18 18:38:27 +00:00
/*
[
[
"My Action",
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
[0,0,0],
{ (_this select 0) setVelocity [0,0,10]; },
{ true },
1,
[],
uid,
["ACE_MainActions","TeamManagement","MyAction"]
]
]
*/