From 15f7225a5f9eec1bf1e9abc09d4413191734fd6d Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Fri, 29 Dec 2023 21:21:19 -0800 Subject: [PATCH] define parent classes to apply handler to --- functions/client/fn_initVehicleFlags.sqf | 203 ++++++++++++----------- 1 file changed, 105 insertions(+), 98 deletions(-) diff --git a/functions/client/fn_initVehicleFlags.sqf b/functions/client/fn_initVehicleFlags.sqf index e6b06bc..21409b2 100644 --- a/functions/client/fn_initVehicleFlags.sqf +++ b/functions/client/fn_initVehicleFlags.sqf @@ -80,111 +80,118 @@ milsim_vehicleflag_options = [ ]; +private _appliedParentClasses = [ + "LandVehicle", + "Helicopter" +]; -["AllVehicles", "InitPost", { - private _flagActionID = "SetVehicleFlag"; - private _flagMasterAction = [ - _flagActionID, // id - "Set Vehicle Flag", // displayed title - "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon - {true}, // statement - {true}, // condition - { - params ["_target", "_player", "_params"]; - private _flagActionID = _params#0; - private _actions = []; +{ + private _parentClass = _x; + [_parentClass, "InitPost", { + private _flagActionID = "SetVehicleFlag"; + private _flagMasterAction = [ + _flagActionID, // id + "Set Vehicle Flag", // displayed title + "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon + {true}, // statement + {true}, // condition { - _x params ["_flagCategory", "_flagOptions"]; - // diag_log format ["NewFlagCategory: %1 %2", _flagCategory, _flagOptions]; + params ["_target", "_player", "_params"]; + private _flagActionID = _params#0; + private _actions = []; + { + _x params ["_flagCategory", "_flagOptions"]; + // diag_log format ["NewFlagCategory: %1 %2", _flagCategory, _flagOptions]; - private _flagCategoryOption = [ - _flagActionID + "_" + _flagCategory, // id - _flagCategory, // displayed title - (_flagOptions#0#1) get "Texture", // flag icon - {true}, // statement - { - params ["_target", "_player", "_params"]; - alive _target; - // true; - }, // condition - { - params ["_target", "_player", "_params"]; - _params params ["_flagActionID", "_flagCategoryID", "_flagOptions"]; - private _categoryOptions = []; + private _flagCategoryOption = [ + _flagActionID + "_" + _flagCategory, // id + _flagCategory, // displayed title + (_flagOptions#0#1) get "Texture", // flag icon + {true}, // statement { - _x params ["_flagOptionID", "_flagOptionData"]; - // diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData]; - private _newFlagOption = [ - _flagActionID + "_" + _flagCategory + "_" + _flagOptionID, // id - _flagOptionData get "Title", // displayed title - _flagOptionData get "Texture", // flag icon - { - params ["_target", "_player", "_params"]; - _target forceFlagTexture (_params select 2); - }, // statement - { - params ["_target", "_player", "_params"]; - alive _target; - // true; - }, // condition - nil, // child code - [_flagActionID, _flagCategoryID, getMissionPath (_flagOptionData get "Texture")], // params - nil, // position - 4, // distance - [false, false, false, false, false] // other params - ] call ace_interact_menu_fnc_createAction; - _categoryOptions pushBack [_newFlagOption, [], _target]; - } forEach _flagOptions; - _categoryOptions; - }, // child code - [_flagActionID, _flagCategoryID, _flagOptions], // params - nil, // position - 4, // distance - [false, false, false, false, false], // other params - nil // modifier function code - ] call ace_interact_menu_fnc_createAction; + params ["_target", "_player", "_params"]; + alive _target; + // true; + }, // condition + { + params ["_target", "_player", "_params"]; + _params params ["_flagActionID", "_flagCategoryID", "_flagOptions"]; + private _categoryOptions = []; + { + _x params ["_flagOptionID", "_flagOptionData"]; + // diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData]; + private _newFlagOption = [ + _flagActionID + "_" + _flagCategory + "_" + _flagOptionID, // id + _flagOptionData get "Title", // displayed title + _flagOptionData get "Texture", // flag icon + { + params ["_target", "_player", "_params"]; + _target forceFlagTexture (_params select 2); + }, // statement + { + params ["_target", "_player", "_params"]; + alive _target; + // true; + }, // condition + nil, // child code + [_flagActionID, _flagCategoryID, getMissionPath (_flagOptionData get "Texture")], // params + nil, // position + 4, // distance + [false, false, false, false, false] // other params + ] call ace_interact_menu_fnc_createAction; + _categoryOptions pushBack [_newFlagOption, [], _target]; + } forEach _flagOptions; + _categoryOptions; + }, // child code + [_flagActionID, _flagCategoryID, _flagOptions], // params + nil, // position + 4, // distance + [false, false, false, false, false], // other params + nil // modifier function code + ] call ace_interact_menu_fnc_createAction; - _actions pushBack [_flagCategoryOption, [], _target]; - } forEach milsim_vehicleflag_options; + _actions pushBack [_flagCategoryOption, [], _target]; + } forEach milsim_vehicleflag_options; - _actions; - }, // child code - [_flagActionID], // params - nil, // position - 4, // distance - [false, false, false, false, false], // other params - nil // modifier function code - ] call ace_interact_menu_fnc_createAction; + _actions; + }, // child code + [_flagActionID], // params + nil, // position + 4, // distance + [false, false, false, false, false], // other params + nil // modifier function code + ] call ace_interact_menu_fnc_createAction; - // add action to add flag - [ - (_this select 0), // object - 0, // action 0 or self-action 1 - ["ACE_MainActions"], // parent - _flagMasterAction // action - ] call ace_interact_menu_fnc_addActionToObject; - - - // add action to remove flag - private _removeFlagAction = [ - _flagActionID + "_removeflag", // id - "Remove Flag", // displayed title - "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon - { - params ["_target", "_player", "_params"]; - _target forceFlagTexture ""; - }, // statement - {true}, // condition - nil // child code - ] call ace_interact_menu_fnc_createAction; - - [ - (_this select 0), // object - 0, // action 0 or self-action 1 - ["ACE_MainActions", _flagActionID], // parent - _removeFlagAction // action - ] call ace_interact_menu_fnc_addActionToObject; + // add action to add flag + [ + (_this select 0), // object + 0, // action 0 or self-action 1 + ["ACE_MainActions"], // parent + _flagMasterAction // action + ] call ace_interact_menu_fnc_addActionToObject; -}, true, [], true] call CBA_fnc_addClassEventHandler; + + // add action to remove flag + private _removeFlagAction = [ + _flagActionID + "_removeflag", // id + "Remove Flag", // displayed title + "\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon + { + params ["_target", "_player", "_params"]; + _target forceFlagTexture ""; + }, // statement + {true}, // condition + nil // child code + ] call ace_interact_menu_fnc_createAction; + + [ + (_this select 0), // object + 0, // action 0 or self-action 1 + ["ACE_MainActions", _flagActionID], // parent + _removeFlagAction // action + ] call ace_interact_menu_fnc_addActionToObject; + + }, true, [], true] call CBA_fnc_addClassEventHandler; +} forEach _appliedParentClasses; nil; \ No newline at end of file -- 2.37.3.windows.1