From 4b536425b19d496a8873faf632cda0ac3b86fa20 Mon Sep 17 00:00:00 2001 From: commy2 Date: Mon, 28 Sep 2015 14:35:05 +0200 Subject: [PATCH] Code Cleanup Interaction --- addons/common/XEH_postInit.sqf | 2 + addons/interaction/ACE_Settings.hpp | 1 + addons/interaction/ACE_ZeusActions.hpp | 11 ++- addons/interaction/CfgEventHandlers.hpp | 3 +- addons/interaction/CfgVehicles.hpp | 94 +++++++++++-------- .../{Menu_Config.hpp => RscTitles.hpp} | 10 +- addons/interaction/XEH_postInit.sqf | 43 +++------ addons/interaction/config.cpp | 2 +- .../functions/fnc_addPassengerActions.sqf | 18 ++-- .../functions/fnc_addPassengersActions.sqf | 52 +++++----- .../functions/fnc_doBecomeLeader.sqf | 6 +- addons/interaction/functions/fnc_push.sqf | 14 +-- 12 files changed, 137 insertions(+), 119 deletions(-) rename addons/interaction/{Menu_Config.hpp => RscTitles.hpp} (98%) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index e374a7a716..72c5b9fa7a 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -83,6 +83,8 @@ ["setDir", {(_this select 0) setDir (_this select 1)}] call FUNC(addEventhandler); ["setFuel", {(_this select 0) setFuel (_this select 1)}] call FUNC(addEventhandler); ["setSpeaker", {(_this select 0) setSpeaker (_this select 1)}] call FUNC(addEventhandler); +["selectLeader", {(_this select 0) selectLeader (_this select 1)}] call FUNC(addEventHandler); +["setVelocity", {(_this select 0) setVelocity (_this select 1)}] call FUNC(addEventHandler); if (isServer) then { ["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler); diff --git a/addons/interaction/ACE_Settings.hpp b/addons/interaction/ACE_Settings.hpp index 6c97109a37..075c1f056d 100644 --- a/addons/interaction/ACE_Settings.hpp +++ b/addons/interaction/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(EnableTeamManagement) { value = 1; diff --git a/addons/interaction/ACE_ZeusActions.hpp b/addons/interaction/ACE_ZeusActions.hpp index 50f203a092..5a7ea9d631 100644 --- a/addons/interaction/ACE_ZeusActions.hpp +++ b/addons/interaction/ACE_ZeusActions.hpp @@ -1,6 +1,5 @@ + class ACE_ZeusActions { - // _target = curatorLogic - // curatorSelected = [objects,groups,waypoints,markers] class ZeusUnits { displayName = "$STR_A3_RscDisplayCurator_ModeUnits_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeUnits_ca.paa"; @@ -29,12 +28,14 @@ class ACE_ZeusActions { statement = "{_x setUnitPos 'AUTO';} forEach (curatorSelected select 0);"; }; }; + class remoteControl { displayName = "$STR_A3_CfgVehicles_ModuleRemoteControl_F"; icon = "\A3\Modules_F_Curator\Data\portraitRemoteControl_ca.paa"; statement = "_unit = objNull; { if ((side _x in [east,west,resistance,civilian]) && !(isPlayer _x)) exitWith { _unit = _x; }; } forEach (curatorSelected select 0); bis_fnc_curatorObjectPlaced_mouseOver = ['OBJECT',_unit]; (group _target) createUnit ['ModuleRemoteControl_F',[0,0,0],[],0,''];"; }; }; + class ZeusGroups { displayName = "$STR_A3_RscDisplayCurator_ModeGroups_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa"; @@ -67,6 +68,7 @@ class ACE_ZeusActions { statement = "{ _x setBehaviour 'STEALTH'; } forEach (curatorSelected select 1);"; }; }; + class speed { displayName = "$STR_HC_Menu_Speed"; @@ -86,6 +88,7 @@ class ACE_ZeusActions { statement = "{_x setSpeedMode 'FULL';} forEach (curatorSelected select 1);"; }; }; + class formation { displayName = "$STR_Formation"; @@ -136,6 +139,7 @@ class ACE_ZeusActions { }; }; }; + class ZeusWaypoints { displayName = "Waypoints"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeRecent_ca.paa"; @@ -168,6 +172,7 @@ class ACE_ZeusActions { statement = "{ _x setWaypointBehaviour 'STEALTH'; } forEach (curatorSelected select 2);"; }; }; + class speed { displayName = "$STR_HC_Menu_Speed"; @@ -187,6 +192,7 @@ class ACE_ZeusActions { statement = "{ _x setWaypointSpeed 'FULL'; } forEach (curatorSelected select 2);"; }; }; + class formation { displayName = "$STR_Formation"; @@ -237,6 +243,7 @@ class ACE_ZeusActions { }; }; }; + class ZeusMarkers { displayName = "$STR_A3_RscDisplayCurator_ModeMarkers_tooltip"; icon = "\A3\UI_F_Curator\Data\Displays\RscDisplayCurator\modeMarkers_ca.paa"; diff --git a/addons/interaction/CfgEventHandlers.hpp b/addons/interaction/CfgEventHandlers.hpp index 7b003bbe8c..0cd959a047 100644 --- a/addons/interaction/CfgEventHandlers.hpp +++ b/addons/interaction/CfgEventHandlers.hpp @@ -1,6 +1,7 @@ + class Extended_PreInit_EventHandlers { class ADDON { - init = QUOTE( call COMPILE_FILE(XEH_preInit) ); + init = QUOTE(call COMPILE_FILE(XEH_preInit)); }; }; diff --git a/addons/interaction/CfgVehicles.hpp b/addons/interaction/CfgVehicles.hpp index abfdb976ab..9372d3410c 100644 --- a/addons/interaction/CfgVehicles.hpp +++ b/addons/interaction/CfgVehicles.hpp @@ -1,25 +1,28 @@ + class CfgVehicles { - class ACE_Module; - class ACE_ModuleInteraction: ACE_Module { - author = ECSTRING(common,ACETeam); - category = "ACE"; - displayName = CSTRING(Module_DisplayName); - function = "ACE_Interaction_fnc_moduleInteraction"; - scope = 2; - isGlobal = 1; - icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); - class Arguments { - class EnableTeamManagement { - displayName = CSTRING(EnableTeamManagement_DisplayName); - description = CSTRING(EnableTeamManagement_Description); - typeName = "BOOL"; - defaultValue = 1; - }; + class ACE_Module; + class ACE_ModuleInteraction: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Module_DisplayName); + function = "ACE_Interaction_fnc_moduleInteraction"; + scope = 2; + isGlobal = 1; + icon = PATHTOF(UI\Icon_Module_Interaction_ca.paa); + + class Arguments { + class EnableTeamManagement { + displayName = CSTRING(EnableTeamManagement_DisplayName); + description = CSTRING(EnableTeamManagement_Description); + typeName = "BOOL"; + defaultValue = 1; + }; + }; + + class ModuleDescription { + description = CSTRING(Module_Description); + }; }; - class ModuleDescription { - description = CSTRING(Module_Description); - }; - }; class Man; class CAManBase: Man { @@ -77,7 +80,6 @@ class CfgVehicles { priority = 2.1; hotkey = "Y"; }; - class ACE_UnassignTeam { displayName = CSTRING(LeaveTeam); condition = QUOTE([ARR_2(_player,_target)] call DFUNC(canJoinTeam) && {assignedTeam _target != 'MAIN'}); @@ -98,7 +100,6 @@ class CfgVehicles { icon = PATHTOF(UI\team\team_management_ca.paa); hotkey = "J"; }; - class ACE_GetDown { displayName = CSTRING(GetDown); condition = QUOTE([_target] call DFUNC(canInteractWithCivilian)); @@ -121,6 +122,7 @@ class CfgVehicles { priority = 2.5; }; }; + class ACE_Torso { displayName = CSTRING(Torso); selection = "spine3"; @@ -170,7 +172,6 @@ class CfgVehicles { condition = ""; statement = ""; }; - class ACE_TapShoulderRight { displayName = CSTRING(TapShoulder); selection = "rightshoulder"; @@ -238,7 +239,6 @@ class CfgVehicles { icon = PATHTOF(UI\team\team_yellow_ca.paa); hotkey = "Y"; }; - class ACE_LeaveTeam { displayName = CSTRING(LeaveTeam); condition = QUOTE(assignedTeam _player != 'MAIN'); @@ -405,6 +405,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -414,6 +415,7 @@ class CfgVehicles { }; }; }; + class Tank: LandVehicle { class ACE_Actions { class ACE_MainActions { @@ -429,6 +431,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -455,6 +458,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -464,6 +468,7 @@ class CfgVehicles { }; }; }; + class Plane: Air { class ACE_Actions { class ACE_MainActions { @@ -479,6 +484,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -501,7 +507,7 @@ class CfgVehicles { class ACE_Push { displayName = CSTRING(Push); distance = 6; - condition = QUOTE(((getMass _target) <= 2600) && {alive _target} && {(vectorMagnitude (velocity _target)) < 3}); + condition = QUOTE(getMass _target <= 2600 && {alive _target} && {vectorMagnitude velocity _target < 3}); statement = QUOTE(_this call FUNC(push)); showDisabled = 0; priority = -1; @@ -514,6 +520,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -539,6 +546,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions { class ACE_Passengers { displayName = CSTRING(Passengers); @@ -551,26 +559,29 @@ class CfgVehicles { class StaticMGWeapon: StaticWeapon {}; class HMG_01_base_F: StaticMGWeapon {}; + class HMG_01_high_base_F: HMG_01_base_F { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[-0.172852,0.164063,-0.476091]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[-0.172852,0.164063,-0.476091]"; + }; + }; }; + class AA_01_base_F: StaticMGWeapon { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[0,0.515869,-0.200671]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[0,0.515869,-0.200671]"; + }; + }; }; + class AT_01_base_F: StaticMGWeapon { - class ACE_Actions: ACE_Actions { - class ACE_MainActions: ACE_MainActions { - position = "[0,0.515869,-0.200671]"; - }; - }; + class ACE_Actions: ACE_Actions { + class ACE_MainActions: ACE_MainActions { + position = "[0,0.515869,-0.200671]"; + }; + }; }; class thingX; @@ -581,6 +592,7 @@ class CfgVehicles { selection = ""; distance = 2; condition = "true"; + class ACE_OpenBox { displayName = CSTRING(OpenBox); condition = QUOTE(alive _target); @@ -590,6 +602,7 @@ class CfgVehicles { }; }; }; + class ACE_SelfActions {}; }; @@ -602,6 +615,7 @@ class CfgVehicles { condition = "true"; }; }; + class ACE_SelfActions {}; }; }; diff --git a/addons/interaction/Menu_Config.hpp b/addons/interaction/RscTitles.hpp similarity index 98% rename from addons/interaction/Menu_Config.hpp rename to addons/interaction/RscTitles.hpp index 8359ee560a..7e1b07432f 100644 --- a/addons/interaction/Menu_Config.hpp +++ b/addons/interaction/RscTitles.hpp @@ -1,3 +1,4 @@ + #define HSPACE 0.5-2.0/16/2 #define VSPACE 0.5-0.3/9/2 @@ -44,13 +45,15 @@ class ACE_Interaction_Button_Base { class RscListbox; class IGUIBack; class RscText; + #define X_OFFSET 0.2 class RscACE_SelectAnItem { idd = 8854; movingEnable = 0; + class controls { - class back:IGUIBack { + class back: IGUIBack { x = X_OFFSET; y = 0; w = 0.6; @@ -66,7 +69,7 @@ class RscACE_SelectAnItem { style = 0x02; text = ""; }; - class itemList:RscListBox { + class itemList: RscListBox { onMouseButtonDblClick = "_this call ACE_Interaction_fnc_onSelectMenuDblClick"; idc = 8866; x = X_OFFSET + 0.005; @@ -139,18 +142,21 @@ class RscInteractionIcon: RscPicture { w = 2*GUI_GRID_H; h = 2*GUI_GRID_H; }; + class RscInteractionHelperIcon: RscInteractionIcon { x = 20 * GUI_GRID_W; y = 16 * GUI_GRID_H; w = GUI_GRID_H; h = GUI_GRID_H; }; + class RscInteractionText: RscText{ x = 21 * GUI_GRID_W; y = 16 * GUI_GRID_H; w = 8 * GUI_GRID_W; h = 1.5 * GUI_GRID_H; }; + class RscTitles { class GVAR(InteractionHelper) { idd = 9930; diff --git a/addons/interaction/XEH_postInit.sqf b/addons/interaction/XEH_postInit.sqf index 8d97803b1d..7b264db3c9 100644 --- a/addons/interaction/XEH_postInit.sqf +++ b/addons/interaction/XEH_postInit.sqf @@ -1,37 +1,22 @@ // by commy2 and esteldunedain - #include "script_component.hpp" ACE_Modifier = 0; -//SelectLeader Event Handler for BecomeLeader action: -[QGVAR(selectLeader), { - PARAMS_2(_group,_leader); - _group selectLeader _leader; -}] call EFUNC(common,addEventHandler); - -//Pushing boats from FUNC(push) -[QGVAR(pushBoat), { - params ["_boat", "_newVelocity"]; - _boat setVelocity _newVelocity; -}] call EFUNC(common,addEventHandler); - - if (!hasInterface) exitWith {}; GVAR(isOpeningDoor) = false; // restore global fire teams for JIP -private ["_team"]; +private "_team"; { _team = _x getVariable [QGVAR(assignedFireTeam), ""]; if (_team != "") then {_x assignTeam _team}; -} forEach allUnits; + false +} count allUnits; - -// Add keybinds -["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), -{ +// add keybinds +["ACE3 Common", QGVAR(openDoor), localize LSTRING(OpenDoor), { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -40,18 +25,16 @@ private ["_team"]; // Statement call EFUNC(interaction,openDoor); true -}, -{ +}, { //Probably don't want any condidtions here, so variable never gets locked down // Statement GVAR(isOpeningDoor) = false; true }, -[57, [false, true, false]], false] call cba_fnc_addKeybind; //Key CTRL+Space +[57, [false, true, false]], false] call CBA_fnc_addKeybind; //Key CTRL+Space -["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), -{ +["ACE3 Common", QGVAR(tapShoulder), localize LSTRING(TapShoulder), { // Conditions: canInteract if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {false}; // Conditions: specific @@ -62,10 +45,9 @@ private ["_team"]; true }, {false}, -[20, [true, false, false]], false] call cba_fnc_addKeybind; +[20, [true, false, false]], false] call CBA_fnc_addKeybind; -["ACE3 Common", QGVAR(modifierKey), localize LSTRING(ModifierKey), -{ +["ACE3 Common", QGVAR(modifierKey), localize LSTRING(ModifierKey), { // Conditions: canInteract //if !([ACE_player, objNull, ["isNotDragging"]] call EFUNC(common,canInteractWith)) exitWith {false}; // not needed @@ -73,13 +55,12 @@ private ["_team"]; ACE_Modifier = 1; // Return false so it doesn't block other actions false -}, -{ +}, { //Probably don't want any condidtions here, so variable never gets locked down ACE_Modifier = 0; false; }, -[29, [false, false, false]], false] call cba_fnc_addKeybind; +[29, [false, false, false]], false] call CBA_fnc_addKeybind; ["isNotSwimming", {!underwater (_this select 0)}] call EFUNC(common,addCanInteractWithCondition); ["isNotOnLadder", {getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> animationState (_this select 0) >> "ACE_isLadder") != 1}] call EFUNC(common,addCanInteractWithCondition); diff --git a/addons/interaction/config.cpp b/addons/interaction/config.cpp index 0afb2fc0fe..9659565c3c 100644 --- a/addons/interaction/config.cpp +++ b/addons/interaction/config.cpp @@ -14,6 +14,6 @@ class CfgPatches { #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" -#include "Menu_Config.hpp" +#include "RscTitles.hpp" #include "ACE_Settings.hpp" #include "ACE_ZeusActions.hpp" diff --git a/addons/interaction/functions/fnc_addPassengerActions.sqf b/addons/interaction/functions/fnc_addPassengerActions.sqf index d7e21d4a7b..20de00e315 100644 --- a/addons/interaction/functions/fnc_addPassengerActions.sqf +++ b/addons/interaction/functions/fnc_addPassengerActions.sqf @@ -1,13 +1,13 @@ /* * Author: esteldunedain - * Mount unit actions inside passenger submenu + * Mount unit actions inside passenger submenu. * * Arguments: * 0: Vehicle * 1: Player * 3: Parameters * - * Return value: + * Return Value: * Children actions * * Example: @@ -17,8 +17,8 @@ */ #include "script_component.hpp" -EXPLODE_3_PVT(_this,_vehicle,_player,_parameters); -EXPLODE_1_PVT(_parameters,_unit); +params ["", "", "_parameters"]; +_parameters params ["_unit"]; private ["_varName", "_actionTrees", "_actions"]; @@ -26,11 +26,13 @@ _varName = format [QEGVAR(interact_menu,Act_%1), typeOf _unit]; _actionTrees = missionNamespace getVariable [_varName, []]; _actions = []; -// Mount unit MainActions menu +// Mount unit MainActions menu { - EXPLODE_2_PVT(_x,_actionData,_children); - _actions pushBack [_actionData, _children, _unit]; -} forEach ((_actionTrees select 0) select 1); + _x params ["_actionData", "_children"]; + + _actions pushBack [_actionData, _children, _unit]; + false +} count (_actionTrees select 0 select 1); _actions diff --git a/addons/interaction/functions/fnc_addPassengersActions.sqf b/addons/interaction/functions/fnc_addPassengersActions.sqf index fe557e7ada..eb96ca729e 100644 --- a/addons/interaction/functions/fnc_addPassengersActions.sqf +++ b/addons/interaction/functions/fnc_addPassengersActions.sqf @@ -1,6 +1,6 @@ /* * Author: esteldunedain - * Create one action per passenger + * Create one action per passenger. * * Arguments: * 0: Vehicle @@ -17,39 +17,43 @@ */ #include "script_component.hpp" -EXPLODE_3_PVT(_this,_vehicle,_player,_parameters); +params ["_vehicle", "_player"]; -private ["_actions"]; +private "_actions"; _actions = []; { private ["_unit", "_icon"]; + _unit = _x; - if ((_unit != _player) && {(getText (configFile >> "CfgVehicles" >> (typeOf _x) >> "simulation")) != "UAVPilot"}) then { - _icon = switch _unit do { - case (driver _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa) }; - case (gunner _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa) }; - case (commander _vehicle): { QUOTE(A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa) }; - default { "" }; - }; + + if (_unit != _player && {getText (configFile >> "CfgVehicles" >> typeOf _unit >> "simulation") != "UAVPilot"}) then { + _icon = [ + "", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_driver_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_gunner_ca.paa", + "A3\ui_f\data\IGUI\RscIngameUI\RscUnitInfo\role_commander_ca.paa" + ] select (([driver _vehicle, gunner _vehicle, commander _vehicle] find _unit) + 1); + if (_unit getVariable [QEGVAR(captives,isHandcuffed), false]) then { _icon = QUOTE(PATHTOEF(captives,UI\handcuff_ca.paa)); }; - _actions pushBack + + _actions pushBack [ [ - [ - str(_unit), - [_unit, true] call EFUNC(common,getName), - _icon, - {}, - {true}, - {_this call FUNC(addPassengerActions);}, - [_unit] - ] call EFUNC(interact_menu,createAction), - [], - _unit - ]; + format ["%1", _unit], + [_unit, true] call EFUNC(common,getName), + _icon, + {}, + {true}, + {_this call FUNC(addPassengerActions)}, + [_unit] + ] call EFUNC(interact_menu,createAction), + [], + _unit + ]; }; -} forEach crew _vehicle; + false +} count crew _vehicle; _actions diff --git a/addons/interaction/functions/fnc_doBecomeLeader.sqf b/addons/interaction/functions/fnc_doBecomeLeader.sqf index 0fd81cbc96..48ac68059b 100644 --- a/addons/interaction/functions/fnc_doBecomeLeader.sqf +++ b/addons/interaction/functions/fnc_doBecomeLeader.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Target - * 1: Player + * 1: Unit * * Return Value: * None @@ -16,6 +16,6 @@ */ #include "script_component.hpp" -PARAMS_2(_target,_player); +params ["_target", "_unit"]; -[QGVAR(selectLeader), (units group _player), [(group _player), _player]] call EFUNC(common,targetEvent); +["selectLeader", units group _unit, [group _unit, _unit]] call EFUNC(common,targetEvent); diff --git a/addons/interaction/functions/fnc_push.sqf b/addons/interaction/functions/fnc_push.sqf index 86ad673d9c..9a6c86a18e 100644 --- a/addons/interaction/functions/fnc_push.sqf +++ b/addons/interaction/functions/fnc_push.sqf @@ -4,7 +4,7 @@ * * Arguments: * 0: Boat - * 1: Player + * 1: Unit * * Return Value: * None @@ -14,13 +14,13 @@ * * Public: No */ - #include "script_component.hpp" -params ["_boat", "_player"]; +params ["_boat", "_unit"]; -private ["_newVelocity"]; +private "_newVelocity"; +_newVelocity = vectorDir _unit; +_newVelocity set [2, 0.25]; +_newVelocity = _newVelocity vectorMultiply 2; -_newVelocity = [2 * (vectorDir _player select 0), 2 * (vectorDir _player select 1), 0.5]; - -[QGVAR(pushBoat), [_boat], [_boat, _newVelocity]] call EFUNC(common,targetEvent); +["setVelocity", [_boat], [_boat, _newVelocity]] call EFUNC(common,targetEvent);