wip
This commit is contained in:
87
functions/vehicleFlags/fn_getActionsFlagCategories.sqf
Normal file
87
functions/vehicleFlags/fn_getActionsFlagCategories.sqf
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Used to generate flag category and nested flag child options for the ACE3 interaction menu.
|
||||
|
||||
Parameters:
|
||||
0: STRING - Parent action ID
|
||||
1: ARRAY - Flag category configs
|
||||
*/
|
||||
|
||||
params ["_rootActionID", "_flagCategoryCfgs"];
|
||||
|
||||
private _allCategoryActions = [];
|
||||
|
||||
{
|
||||
// diag_log format ["NewFlagCategory: %1 %2", _flagCategory, _flagOptions];
|
||||
|
||||
private _flagCategoryCfg = _x;
|
||||
private _flagCategoryActionID = getText(_flagCategoryCfg >> "actionID");
|
||||
private _flagCategoryTitle = getText(_flagCategoryCfg >> "actionTitle");
|
||||
|
||||
private _flagSubclassesCfgs = _flagCategoryCfg call BIS_fnc_returnChildren;
|
||||
|
||||
private _flagCategoryAction = [
|
||||
_rootActionID + "_" + _flagCategoryActionID, // id
|
||||
_flagCategoryTitle, // displayed title
|
||||
getText((_flagSubclassesCfgs#0) >> "texture"), // flag icon for category - use first flag option
|
||||
{true}, // statement
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
alive _target;
|
||||
// true;
|
||||
}, // condition
|
||||
{
|
||||
// generate child code under category
|
||||
// this is the level where actual flag options will be displayed
|
||||
params ["_target", "_player", "_params"];
|
||||
_params params ["_rootActionID", "_flagCategoryActionID", "_flagSubclassesCfgs"];
|
||||
|
||||
private _individualFlagActions = [];
|
||||
{ // forEach _flagSubclassesCfgs;
|
||||
private _flagOptionCfg = _x;
|
||||
private _flagOptionID = getText(_flagOptionCfg >> "actionID");
|
||||
private _flagOptionTitle = getText(_flagOptionCfg >> "actionTitle");
|
||||
private _flagOptionTexture = getText(_flagOptionCfg >> "texture");
|
||||
|
||||
// diag_log format ["NewFlagOption: %1 %2", _flagOptionID, _flagOptionData];
|
||||
|
||||
private _newFlagOption = [
|
||||
|
||||
_rootActionID + "_" + _flagCategoryActionID + "_" + _flagOptionID, // id
|
||||
_flagOptionTitle, // displayed title
|
||||
_flagOptionTexture, // flag icon
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
_params params ["_flagOptionTexture"];
|
||||
_target forceFlagTexture _flagOptionTexture;
|
||||
}, // statement
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
alive _target;
|
||||
// true;
|
||||
}, // condition
|
||||
nil, // child code
|
||||
[_flagOptionTexture], // params
|
||||
nil, // position
|
||||
4, // distance
|
||||
[false, false, false, false, false] // other params
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
|
||||
// add flag option to category subactions
|
||||
_individualFlagActions pushBack [_newFlagOption, [], _target];
|
||||
} forEach _flagSubclassesCfgs;
|
||||
|
||||
// return the generated flag options to the category as child actions
|
||||
_individualFlagActions;
|
||||
}, // child code
|
||||
[_rootActionID, _flagCategoryActionID, _flagSubclassesCfgs], // params
|
||||
nil, // position
|
||||
4, // distance
|
||||
[false, false, false, false, false], // other params
|
||||
nil // modifier function code
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
|
||||
// add category to all category actions array
|
||||
_allCategoryActions pushBack [_flagCategoryAction, [], _target];
|
||||
} forEach _flagCategoryCfgs;
|
||||
|
||||
_allCategoryActions;
|
||||
1
functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf
Normal file
1
functions/vehicleFlags/fn_getVehicleFlagsCfg.sqf
Normal file
@@ -0,0 +1 @@
|
||||
(missionConfigFile >> "VehicleFlags");
|
||||
113
functions/vehicleFlags/fn_initVehicleFlags.sqf
Normal file
113
functions/vehicleFlags/fn_initVehicleFlags.sqf
Normal file
@@ -0,0 +1,113 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg;
|
||||
|
||||
if (!isClass _vehicleFlagsCfg) exitWith {
|
||||
["WARNING: Vehicle Flags: Vehicle Flags config not found. Vehicle Flags will not be available."] call BIS_fnc_error;
|
||||
};
|
||||
|
||||
// get texture pbo class
|
||||
private _texturePboName = getText(_vehicleFlagsCfg >> "texturePBOName");
|
||||
if (_texturePboName == "") exitWith {
|
||||
["WARNING: Vehicle Flags: Texture PBO definition is missing or a blank string! Vehicle Flags will not be available."] call BIS_fnc_error;
|
||||
};
|
||||
if (!isClass (configFile >> "CfgPatches" >> _texturePboName)) exitWith {
|
||||
[
|
||||
"WARNING: Vehicle Flags: Texture PBO not found (%1). Vehicle Flags will not be available.",
|
||||
_texturePboName
|
||||
] call BIS_fnc_error;
|
||||
};
|
||||
|
||||
private _baseClassesToApplyActionsFor =
|
||||
(_vehicleFlagsCfg >> "baseClassesToApplyActionsFor") call BIS_fnc_getCfgDataArray;
|
||||
private _flagCategoryCfgs = (_vehicleFlagsCfg >> "FlagCategories") call BIS_fnc_returnChildren;
|
||||
|
||||
{ // forEach _baseClassesToApplyActionsFor
|
||||
private _parentClass = _x;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// add CBA class event handler to add actions to vehicles after they are initialized
|
||||
// all classes that inherit from the base classes will also have this applied
|
||||
// an exclusion function is present for manually excluding specific classes
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
[_parentClass, "InitPost", {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// create the root action
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
private _rootActionID = "SetVehicleFlag";
|
||||
private _flagRootAction = [
|
||||
_rootActionID, // id
|
||||
"Set Vehicle Flag", // displayed title
|
||||
"\A3\ui_f\data\map\markers\flags\nato_ca.paa", // flag icon
|
||||
{true}, // statement
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
// _params params ["_parentActionID", "_flagCategories"];
|
||||
|
||||
// check if vehicle is excluded
|
||||
private _excluded = [typeOf _target] call milsim_vehicleFlags_fnc_isClassExcluded;
|
||||
if (_excluded || !alive _target) exitWith {false};
|
||||
|
||||
true;
|
||||
}, // condition
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// create the flag category actions (with nested flag actions)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
params ["_target", "_player", "_params"];
|
||||
_params params ["_rootActionID", "_flagCategoryCfgs"];
|
||||
|
||||
// return category child actions with individual flag actions nested as children
|
||||
[_rootActionID, _flagCategoryCfgs] call milsim_vehicleFlags_fnc_getActionsFlagCategories;
|
||||
|
||||
}, // child code
|
||||
[_rootActionID, _flagCategoryCfgs], // params
|
||||
nil, // position
|
||||
4, // distance
|
||||
[false, false, false, false, false], // other params
|
||||
nil // modifier function code
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// add root action to add flags
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
[
|
||||
(_this select 0), // object
|
||||
0, // action 0 or self-action 1
|
||||
["ACE_MainActions"], // parent
|
||||
_flagRootAction // action
|
||||
] call ace_interact_menu_fnc_addActionToObject;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// add action to remove flag under the root action
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// create action
|
||||
private _removeFlagAction = [
|
||||
_flagRootAction + "_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
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
alive _target && getForcedFlagTexture _target != "";
|
||||
}, // condition
|
||||
nil // child code
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
|
||||
// add the action to the vehicle
|
||||
// in this class event handler, this#0 will be the vehicle
|
||||
[
|
||||
(_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 _baseClassesToApplyActionsFor;
|
||||
|
||||
nil;
|
||||
26
functions/vehicleFlags/fn_isClassExcluded.sqf
Normal file
26
functions/vehicleFlags/fn_isClassExcluded.sqf
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Used to read vehicle flags config and check provided classname against all present exclusion groups.
|
||||
|
||||
Author: IndigoFox
|
||||
|
||||
Parameter(s):
|
||||
0: STRING - Classname of the vehicle to check
|
||||
*/
|
||||
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
params ["_className", "", [""]];
|
||||
if (_className == "") exitWith {false};
|
||||
|
||||
private _vehicleFlagsCfg = call milsim_vehicleFlags_fnc_getVehicleFlagsCfg;
|
||||
private _excludedVehiclesClass = (_vehicleFlagsCfg >> "ExcludedVehicles");
|
||||
private _exclusionGroups = configProperties [_vehicleFlagsCfg >> "ExcludedVehicles"];
|
||||
|
||||
{
|
||||
// Check if the class doesn't have a flag proxy
|
||||
private _excludedClasses = _x call BIS_fnc_getCfgDataArray;
|
||||
if (_className in _excludedClasses) exitWith {true};
|
||||
} forEach _exclusionGroups;
|
||||
|
||||
false;
|
||||
Reference in New Issue
Block a user