allow actions to be defined for different selections

This commit is contained in:
Nicolás Badano 2015-02-19 15:36:27 -03:00
parent 30943cbfd4
commit f7d5d615ee
12 changed files with 356 additions and 283 deletions

View File

@ -1,6 +1,10 @@
#define MACRO_ATTACHTOVEHICLE \
class ACE_Actions { \
class ACE_MainActions { \
selection = ""; \
distance = 5; \
condition = "true"; \
class GVAR(AttachVehicle) { \
displayName = "$STR_ACE_Attach_AttachDetach"; \
condition = QUOTE(([ARR_3(_player, _target, '')] call FUNC(canAttach))); \
@ -21,6 +25,7 @@
icon = PATHTOF(UI\detach_ca.paa); \
distance = 4; \
}; \
}; \
};
class CfgVehicles {

View File

@ -2,6 +2,11 @@ class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_Actions {
class ACE_RightHandActions {
selection = "righthand";
displayName = "Right hand";
distance = 5;
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(canApplyHandcuffs)) || ([ARR_2(_player, _target)] call FUNC(canRemoveHandcuffs)));
class ACE_ApplyHandcuffs {
displayName = "$STR_ACE_Captives_SetCaptive";
distance = 4;
@ -24,6 +29,8 @@ class CfgVehicles {
icon = QUOTE(PATHTOF(UI\handcuff_ca.paa));
hotkey = "R";
};
};
class ACE_MainActions {
class ACE_EscortCaptive {
displayName = "$STR_ACE_Captives_EscortCaptive";
distance = 4;
@ -68,6 +75,7 @@ class CfgVehicles {
hotkey = "F";
};
};
};
class ACE_SelfActions {
class ACE_StopEscortingSelf {
@ -100,6 +108,8 @@ class CfgVehicles {
#define MACRO_LOADUNLOADCAPTIVE \
class ACE_Actions { \
class ACE_MainActions { \
selection = ""; \
class ACE_LoadCaptive { \
displayName = "$STR_ACE_Captives_LoadCaptive"; \
distance = 4; \
@ -119,6 +129,7 @@ class CfgVehicles {
priority = 1.2; \
hotkey = "C"; \
}; \
}; \
};
class LandVehicle;

View File

@ -37,7 +37,7 @@ _actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions";
_recurseFnc = {
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_condition", "_showDisabled",
private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_selection", "_condition", "_showDisabled",
"_enableInside", "_children", "_entry", "_actionsCfg"];
_actions = [];
_actionsCfg = _this select 0;
@ -48,7 +48,10 @@ _recurseFnc = {
_distance = getNumber (_entryCfg >> "distance");
_icon = getText (_entryCfg >> "icon");
_statement = compile (getText (_entryCfg >> "statement"));
_selection = getText (_entryCfg >> "selection");
if (_selection == "") then {
_selection = [0,0,0];
};
_condition = getText (_entryCfg >> "condition");
if (_condition == "") then {_condition = "true"};
@ -59,24 +62,18 @@ _recurseFnc = {
_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_Actions" >> _childMenuName;
_children = [_childMenuCfg] call _recurseFnc;
};
_children = [_entryCfg] call _recurseFnc;
_entry = [
_displayName,
_icon,
[0,0,0],
_selection,
_statement,
_condition,
_distance,
_children,
GVAR(uidCounter)
];
diag_log _entry;
GVAR(uidCounter) = GVAR(uidCounter) + 1;
_actions pushBack _entry;
};
@ -85,9 +82,20 @@ _recurseFnc = {
};
_actions = [_actionsCfg] call _recurseFnc;
//diag_log _actions;
// Backward-compat, filter only base actions that have a selection
private ["_newActions","_oldActions","_selection"];
_filteredActions = [];
{
_selection = _x select 2;
if (typeName _selection == "STRING") then {
_filteredActions pushBack _x;
};
} forEach _actions;
/*
_actions = [[
"TEST!",
"Interactions",
"\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa",
"Spine3",
{ true },
@ -98,5 +106,5 @@ _actions = [[
]
];
GVAR(uidCounter) = GVAR(uidCounter) + 1;
_object setVariable [QUOTE(GVAR(actionData)), _actions];
*/
_object setVariable [QUOTE(GVAR(actionData)), _filteredActions];

View File

@ -18,6 +18,7 @@ if(!GVAR(keyDown)) then {
_target = _actionObject;
_player = ACE_player;
_active = [_target, ACE_player] call (_actionItem select 4);
systemChat format ["%1 %2 is active %3", _actionObject, _actionItem select 0, _active];
// player sideChat format["_active: %1 %2", _actionItem select 0, _active];
if(_active) then {
_renderItem = +_actionItem;

View File

@ -6,7 +6,7 @@ _text = _this select 0;
_color = _this select 1;
_pos = _this select 2;
_icon = _this select 6;
//systemChat format ["Drawing icon %1", _text];
_sPos = worldToScreen _pos;
// _sPos = _pos;
if(count _sPos > 0) then {

View File

@ -34,7 +34,6 @@ if(_cursorScreenPos distance _pos <= _distance) then {
_color = format ["#%1FFFFFF", [255 * (((GVAR(renderDepth)/_menuDepth)) max 0.25)] call EFUNC(common,toHex)];
};
_path set[(count _path), _index];
// player sideChat format["r: %1", _actionData select 2];
[_actionData select 0, _color, _pos, 1, 1, 0, _actionData select 1, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
GVAR(currentOptions) set[(count GVAR(currentOptions)), [_this, _pos, _path]];
_currentRenderDepth = -1;
@ -53,7 +52,7 @@ if(_cursorScreenPos distance _pos <= _distance) then {
_numActions = _numActions + 1;
};
} forEach (_actionData select 6);
systemChat format ["_numActions: %1", _numActions];
systemChat format ["Menu %1, _numActions: %2", _actionData select 0, _numActions];
private "_angleSpan";
_angleSpan = _maxAngleSpan min (35 * (_numActions - 1));
@ -67,7 +66,7 @@ if(_cursorScreenPos distance _pos <= _distance) then {
_active = [_object, ACE_player] call (_x select 4);
// diag_log text format["_active: %1: %2", (_x select 0), _active];
if(_active) then {
systemChat format ["_angle: %1", _angle];
//systemChat format ["_angle: %1", _angle];
_offset = [GVAR(vecLineMap), _angle] call FUNC(rotateVectLine);
_mod = 0.4 max (0.15 * (_cursorScreenPos distance _pos)); //0.5;//0.1*_distance;
_newPos = [

View File

@ -30,6 +30,14 @@ class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_Actions {
class ACE_MainActions {
displayName = "$STR_ACE_Interaction_MainAction";
distance = 4;
condition = QUOTE(true);
statement = "";
icon = "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa";
selection = "spine3";
class ACE_TeamManagement {
displayName = "$STR_ACE_Interaction_TeamManagement";
distance = 4;
@ -38,7 +46,6 @@ class CfgVehicles {
showDisabled = 0;
priority = 3.2;
icon = PATHTOF(UI\team\team_management_ca.paa);
subMenu[] = {"ACE_TeamManagement", 0};
hotkey = "M";
enableInside = 1;
@ -100,16 +107,6 @@ class CfgVehicles {
};
};
class ACE_TapShoulder {
displayName = "$STR_ACE_Interaction_TapShoulder";
distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder));
statement = QUOTE([ARR_2(_player, _target)] call DFUNC(tapShoulder));
showDisabled = 1;
priority = 2.8;
hotkey = "Q";
enableInside = 1;
};
class ACE_JoinGroup {
displayName = "$STR_ACE_Interaction_JoinGroup";
distance = 4;
@ -149,6 +146,19 @@ class CfgVehicles {
};
};
class ACE_TapShoulder {
displayName = "$STR_ACE_Interaction_TapShoulder";
selection = "rightshoulder";
distance = 4;
condition = QUOTE([ARR_2(_player, _target)] call DFUNC(canTapShoulder));
statement = QUOTE([ARR_2(_player, _target)] call DFUNC(tapShoulder));
showDisabled = 0;
priority = 2.8;
hotkey = "Q";
enableInside = 1;
};
};
class ACE_SelfActions {
class ACE_TeamManagement {
displayName = "$STR_ACE_Interaction_TeamManagement";

View File

@ -2,6 +2,9 @@
<!-- Edited with tabler - 2014-12-20 -->
<Project name="ACE">
<Package name="Interaction">
<Key ID="STR_ACE_Interaction_MainAction">
<English>Interactions &gt;&gt;</English>
</Key>
<Key ID="STR_ACE_Interaction_InteractionMenu">
<English>Interaction Menu</English>
<German>Interaktionsmenü</German>

View File

@ -2,6 +2,7 @@ class CfgVehicles {
class Helicopter_Base_F;
class UAV_01_base_F: Helicopter_Base_F {
class ACE_Actions {
class ACE_MainActions {
class GVAR(RefuelUAV) {
displayName = "$STR_ACE_logistics_uavbattery_Recharge";
distance = 4;
@ -13,6 +14,7 @@ class CfgVehicles {
};
};
};
};
// Misc box content
class Box_NATO_Support_F;

View File

@ -85,6 +85,7 @@ class CfgVehicles {
};
class ACE_Actions {
class ACE_MainActions {
class ACE_CopyMap {
displayName = "$STR_ACE_Map_CopyMap";
condition = QUOTE(([_target] call EFUNC(common,isPlayer) && {'ItemMap' in assigneditems _player} && {'ACE_MapTools' in items _player} && {'ItemMap' in assignedItems _target}));
@ -94,6 +95,7 @@ class CfgVehicles {
};
};
};
};
class NATO_Box_Base;
class EAST_Box_Base;

View File

@ -78,6 +78,10 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_nato_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
selection = "";
class ACE_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
@ -88,6 +92,7 @@ class CfgVehicles {
};
};
};
};
class ACE_Rallypoint_East : Flag_CSAT_F {
author = "$STR_ACE_Common_ACETeam";
@ -98,6 +103,10 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_CSAT_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
selection = "";
class ACE_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
@ -108,6 +117,7 @@ class CfgVehicles {
};
};
};
};
class ACE_Rallypoint_Independent : Flag_AAF_F {
author = "$STR_ACE_Common_ACETeam";
@ -118,6 +128,10 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_AAF_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
selection = "";
class ACE_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
@ -128,6 +142,7 @@ class CfgVehicles {
};
};
};
};
// moveable
class ACE_RallypointExit_West : Flag_NATO_F {
@ -139,6 +154,9 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_nato_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
class ACE_Teleport {
displayName = "Teleport to Base";
distance = 4;
@ -149,6 +167,7 @@ class CfgVehicles {
};
};
};
};
class ACE_RallypointExit_East : Flag_CSAT_F {
author = "$STR_ACE_Common_ACETeam";
@ -159,6 +178,9 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_CSAT_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
class ACE_Teleport {
displayName = "Teleport to Base";
distance = 4;
@ -169,6 +191,7 @@ class CfgVehicles {
};
};
};
};
class ACE_RallypointExit_Independent : Flag_AAF_F {
author = "$STR_ACE_Common_ACETeam";
@ -179,6 +202,9 @@ class CfgVehicles {
init = QUOTE((_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_AAF_CO.paa'; _this call FUNC(initRallypoint));
};
class ACE_Actions : ACE_Actions {
class ACE_MainActions {
distance = 5;
condition = "true";
class ACE_Teleport {
displayName = "Teleport to Base";
distance = 4;
@ -189,6 +215,7 @@ class CfgVehicles {
};
};
};
};
// team leader
class Man;

View File

@ -1,4 +1,8 @@
#define MACRO_LOCK_ACTIONS \
class ACE_MainActions { \
selection = ""; \
distance = 5; \
condition = "true"; \
class ACE_unlockVehicle { \
displayName = "$STR_ACE_Vehicle_Action_UnLock"; \
distance = 4; \
@ -24,6 +28,7 @@
statement = QUOTE([ARR_3(_player, _target, 'startLockpick')] call FUNC(lockpick)); \
showDisabled = 0; \
priority = 0.1; \
}; \
};
class CfgVehicles {