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 self action menu from config for an object's class
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
|
|
|
* Argument:
|
2015-03-11 19:26:58 +00:00
|
|
|
* 0: Object or class name <OBJECT> or <STRING>
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-02-18 21:58:06 +00:00
|
|
|
#include "script_component.hpp";
|
|
|
|
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_target"];
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-05-18 18:37:05 +00:00
|
|
|
private ["_objectType","_actionsVarName","_isMan"];
|
2015-03-11 19:26:58 +00:00
|
|
|
_objectType = _target;
|
2015-05-18 18:37:05 +00:00
|
|
|
_isMan = false;
|
2015-03-11 19:26:58 +00:00
|
|
|
if (typeName _target == "OBJECT") then {
|
|
|
|
_objectType = typeOf _target;
|
2015-05-18 18:37:05 +00:00
|
|
|
_isMan = _target isKindOf "CAManBase";
|
2015-03-11 19:26:58 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
_actionsVarName = format [QGVAR(SelfAct_%1), _objectType];
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
// Exit if the action menu is already compiled for this class
|
|
|
|
if !(isNil {missionNamespace getVariable [_actionsVarName, nil]}) exitWith {};
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
private "_recurseFnc";
|
2015-02-18 21:58:06 +00:00
|
|
|
_recurseFnc = {
|
2015-04-29 06:26:13 +00:00
|
|
|
private ["_actions", "_displayName", "_icon", "_statement", "_condition", "_showDisabled",
|
2015-04-17 02:53:54 +00:00
|
|
|
"_enableInside", "_canCollapse", "_runOnHover", "_children", "_entry", "_entryCfg", "_insertChildren", "_modifierFunction"];
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_actionsCfg"];
|
2015-02-18 21:58:06 +00:00
|
|
|
_actions = [];
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-05-17 18:51:59 +00:00
|
|
|
{
|
|
|
|
_entryCfg = _x;
|
2015-02-18 21:58:06 +00:00
|
|
|
if(isClass _entryCfg) then {
|
|
|
|
_displayName = getText (_entryCfg >> "displayName");
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-02-18 21:58:06 +00:00
|
|
|
_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
|
2015-03-31 21:06:04 +00:00
|
|
|
_condition = _condition + format [QUOTE( && {[ARR_3(ACE_player, _target, %1)] call EFUNC(common,canInteractWith)} ), getArray (_entryCfg >> "exceptions")];
|
2015-03-19 16:00:10 +00:00
|
|
|
|
|
|
|
_insertChildren = compile (getText (_entryCfg >> "insertChildren"));
|
2015-04-17 02:53:54 +00:00
|
|
|
_modifierFunction = compile (getText (_entryCfg >> "modifierFunction"));
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-03-03 02:29:57 +00:00
|
|
|
_showDisabled = (getNumber (_entryCfg >> "showDisabled")) > 0;
|
|
|
|
_enableInside = (getNumber (_entryCfg >> "enableInside")) > 0;
|
|
|
|
_canCollapse = (getNumber (_entryCfg >> "canCollapse")) > 0;
|
2015-05-28 16:02:31 +00:00
|
|
|
_runOnHover = true;
|
|
|
|
if (isText (_entryCfg >> "runOnHover")) then {
|
|
|
|
_runOnHover = compile getText (_entryCfg >> "runOnHover");
|
|
|
|
} else {
|
|
|
|
_runOnHover = (getNumber (_entryCfg >> "runOnHover")) > 0;
|
|
|
|
};
|
2015-02-18 21:58:06 +00:00
|
|
|
|
|
|
|
_condition = compile _condition;
|
2015-03-20 02:32:44 +00:00
|
|
|
_children = [_entryCfg] call _recurseFnc;
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-02-18 21:58:06 +00:00
|
|
|
_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-08-23 05:16:01 +00:00
|
|
|
[],
|
2015-03-20 02:32:44 +00:00
|
|
|
[0,0,0],
|
|
|
|
10, //distace
|
2015-05-02 05:13:09 +00:00
|
|
|
[_showDisabled,_enableInside,_canCollapse,_runOnHover, true],
|
2015-04-17 02:53:54 +00:00
|
|
|
_modifierFunction
|
2015-03-03 02:29:57 +00:00
|
|
|
],
|
|
|
|
_children
|
2015-02-18 21:58:06 +00:00
|
|
|
];
|
|
|
|
_actions pushBack _entry;
|
|
|
|
};
|
2015-05-17 18:51:59 +00:00
|
|
|
} forEach (configProperties [_actionsCfg, "isClass _x", true]);
|
2015-02-18 21:58:06 +00:00
|
|
|
_actions
|
|
|
|
};
|
|
|
|
|
2015-05-18 18:37:05 +00:00
|
|
|
private ["_actionsCfg","_actions"];
|
2015-02-27 04:55:16 +00:00
|
|
|
_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_SelfActions";
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-04-01 04:56:41 +00:00
|
|
|
private ["_baseDisplayName", "_baseIcon"];
|
|
|
|
_baseDisplayName = "";
|
|
|
|
_baseIcon = "";
|
|
|
|
if (_objectType isKindOf "CAManBase") then {
|
2015-05-28 19:59:04 +00:00
|
|
|
_baseDisplayName = localize LSTRING(SelfActionsRoot);
|
2015-04-01 04:56:41 +00:00
|
|
|
_baseIcon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
|
|
|
|
} else {
|
|
|
|
_baseDisplayName = getText (configFile >> "CfgVehicles" >> _objectType >> "displayName");
|
2015-04-03 05:42:25 +00:00
|
|
|
//Alt would be to just use a static text, if veh names end up being too long:
|
2015-05-28 19:59:04 +00:00
|
|
|
// _baseDisplayName = localize LSTRING(VehicleActionsRoot);
|
2015-04-03 05:42:25 +00:00
|
|
|
|
|
|
|
//Pull the icon from the vehicle's config:
|
2015-04-01 04:56:41 +00:00
|
|
|
_baseIcon = getText (configFile >> "CfgVehicles" >> _objectType >> "Icon");
|
2015-04-03 05:42:25 +00:00
|
|
|
//icon could be a CfgVehicleIcons
|
|
|
|
if isText (configFile >> "CfgVehicleIcons" >> _baseIcon) then {
|
|
|
|
_baseIcon = getText (configFile >> "CfgVehicleIcons" >> _baseIcon);
|
|
|
|
};
|
2015-04-01 04:56:41 +00:00
|
|
|
};
|
|
|
|
|
2015-05-18 18:37:05 +00:00
|
|
|
// If the classname inherits from CAManBase, just copy it's menu without recompiling a new one
|
|
|
|
_actions = if (_isMan) then {
|
|
|
|
+ (missionNamespace getVariable QGVAR(SelfAct_CAManBase))
|
|
|
|
} else {
|
|
|
|
// Create a master action to base on self action
|
2015-03-03 02:29:57 +00:00
|
|
|
[
|
|
|
|
[
|
2015-05-18 18:37:05 +00:00
|
|
|
[
|
|
|
|
"ACE_SelfActions",
|
|
|
|
_baseDisplayName,
|
|
|
|
_baseIcon,
|
|
|
|
{
|
|
|
|
// Dummy statement so it's not collapsed when there's no available actions
|
|
|
|
true
|
|
|
|
},
|
2015-08-30 20:03:45 +00:00
|
|
|
{[ACE_player, _target, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering", "isNotSitting", "isNotOnLadder"]] call EFUNC(common,canInteractWith)},
|
2015-05-18 18:37:05 +00:00
|
|
|
{},
|
|
|
|
{},
|
|
|
|
"Spine3",
|
|
|
|
10,
|
|
|
|
[false,true,false]
|
|
|
|
],
|
|
|
|
[_actionsCfg] call _recurseFnc
|
|
|
|
]
|
2015-03-03 02:29:57 +00:00
|
|
|
]
|
2015-05-18 18:37:05 +00:00
|
|
|
};
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
missionNamespace setVariable [_actionsVarName, _actions];
|