This commit is contained in:
2024-02-03 20:59:51 -08:00
parent 7ef48ecaa2
commit 09dcde7471
7 changed files with 366 additions and 226 deletions

129
defines/VehicleFlags.hpp Normal file
View File

@@ -0,0 +1,129 @@
class VehicleFlags {
texturePBOName = "textures";
baseClassesToApplyActionsFor[] = {
"LandVehicle",
"Helicopter"
};
class ExcludedVehicles {
classesWithoutFlagProxies[] = {
"TF373_SOAR_MH47G_Base", // MH-47G Chinook
"RHS_MELB_base", // MELB AH-6M/MH-6M/H-6M Little Bird
"USAF_C17", // C17 Globemaster III
"USAF_C130J", // C130J Super Hercules
"USAF_AC130U", // AC130 Spooky II
"ej_UH60M_base", // UH-60M Black Hawk + DAP variants
"rhsusf_fmtv_base" // M1083A1P2 variants + SOV SOCOM variants
};
};
class FlagCategories {
class ChevronNumbers {
actionID = "flag_chevron_numbers";
actionTitle = "Chevron Numbers";
class Chevron1 {
actionID = "flag_chevron_id1";
actionTitle = "Flag 1";
texture = "textures\flag_number\flag_id_1_co.paa";
};
class Chevron2 {
actionID = "flag_chevron_id2";
actionTitle = "Flag 2";
texture = "textures\flag_number\flag_id_2_co.paa";
};
class Chevron3 {
actionID = "flag_chevron_id3";
actionTitle = "Flag 3";
texture = "textures\flag_number\flag_id_3_co.paa";
};
class Chevron4 {
actionID = "flag_chevron_id4";
actionTitle = "Flag 4";
texture = "textures\flag_number\flag_id_4_co.paa";
};
class Chevron5 {
actionID = "flag_chevron_id5";
actionTitle = "Flag 5";
texture = "textures\flag_number\flag_id_5_co.paa";
};
class Chevron6 {
actionID = "flag_chevron_id6";
actionTitle = "Flag 6";
texture = "textures\flag_number\flag_id_6_co.paa";
};
class Chevron7 {
actionID = "flag_chevron_id7";
actionTitle = "Flag 7";
texture = "textures\flag_number\flag_id_7_co.paa";
};
class Chevron8 {
actionID = "flag_chevron_id8";
actionTitle = "Flag 8";
texture = "textures\flag_number\flag_id_8_co.paa";
};
class Chevron9 {
actionID = "flag_chevron_id9";
actionTitle = "Flag 9";
texture = "textures\flag_number\flag_id_9_co.paa";
};
class Chevron10 {
actionID = "flag_chevron_id10";
actionTitle = "Flag 10";
texture = "textures\flag_number\flag_id_10_co.paa";
};
class ChevronHQ {
actionID = "flag_chevron_hq";
actionTitle = "Flag HQ";
texture = "textures\flag_number\flag_id_hq_co.paa";
};
};
class SimpleShapes {
actionID = "flag_simpleshape";
actionTitle = "Simple Shapes";
class GreenOctagon {
actionID = "flag_simpleshape_greenoctagon";
actionTitle = "Green Octagon";
texture = "textures\simple_shape\flag_simpleshape_greenoctagon_co.paa";
};
class BlueCircle {
actionID = "flag_simpleshape_bluecircle";
actionTitle = "Blue Circle";
texture = "textures\simple_shape\flag_simpleshape_bluecircle_co.paa";
};
class OrangeSquare {
actionID = "flag_simpleshape_orangesquare";
actionTitle = "Orange Square";
texture = "textures\simple_shape\flag_simpleshape_orangesquare_co.paa";
};
class PinkTriangle {
actionID = "flag_simpleshape_pinktriangle";
actionTitle = "Pink Triangle";
texture = "textures\simple_shape\flag_simpleshape_pinktriangle_co.paa";
};
class RedPentagon {
actionID = "flag_simpleshape_redpentagon";
actionTitle = "Red Pentagon";
texture = "textures\simple_shape\flag_simpleshape_redpentagon_co.paa";
};
};
class Miscellaneous {
actionID = "flag_misc";
actionTitle = "Miscellaneous";
class BattalionEmblem {
actionID = "flag_17th_emblem";
actionTitle = "17th Emblem";
texture = "textures\flags_misc\flag_17th_emblem_co.paa";
};
class RedCross {
actionID = "flag_redcross";
actionTitle = "Red Cross";
texture = "textures\flags_misc\flag_redcross_co.paa";
};
};
};
};

View File

@@ -39,7 +39,6 @@ class milsim
class addClientStatsPFH {};
class addMedicalOverlayPFH { postInit = 1; };
class calculateClientStats {};
class initVehicleFlags { postInit = 1; };
class bindEmptyGroupGarbageCleanup { postInit = 1; };
};
@@ -132,3 +131,13 @@ class milsim_reinsert {
class requestShowQueue {};
};
};
class milsim_vehicleFlags {
class functions {
file = "functions\vehicleFlags";
class initVehicleFlags {postInit = 1};
class getActionsFlagCategories {};
class getVehicleFlagsCfg {};
class isClassExcluded{};
};
};

View File

@@ -1,225 +0,0 @@
milsim_vehicleflag_options = [
["Chevron IDs", [
["flag_chevron_id1", createHashMapFromArray [
["Title", "Flag 1"],
["Texture", "textures\flag_number\flag_id_1_co.paa"]
]],
["flag_chevron_id2", createHashMapFromArray [
["Title", "Flag 2"],
["Texture", "textures\flag_number\flag_id_2_co.paa"]
]],
["flag_chevron_id3", createHashMapFromArray [
["Title", "Flag 3"],
["Texture", "textures\flag_number\flag_id_3_co.paa"]
]],
["flag_chevron_id4", createHashMapFromArray [
["Title", "Flag 4"],
["Texture", "textures\flag_number\flag_id_4_co.paa"]
]],
["flag_chevron_id5", createHashMapFromArray [
["Title", "Flag 5"],
["Texture", "textures\flag_number\flag_id_5_co.paa"]
]],
["flag_chevron_id6", createHashMapFromArray [
["Title", "Flag 6"],
["Texture", "textures\flag_number\flag_id_6_co.paa"]
]],
["flag_chevron_id7", createHashMapFromArray [
["Title", "Flag 7"],
["Texture", "textures\flag_number\flag_id_7_co.paa"]
]],
["flag_chevron_id8", createHashMapFromArray [
["Title", "Flag 8"],
["Texture", "textures\flag_number\flag_id_8_co.paa"]
]],
["flag_chevron_id9", createHashMapFromArray [
["Title", "Flag 9"],
["Texture", "textures\flag_number\flag_id_9_co.paa"]
]],
["flag_chevron_id10", createHashMapFromArray [
["Title", "Flag 10"],
["Texture", "textures\flag_number\flag_id_10_co.paa"]
]],
["flag_chevron_hq", createHashMapFromArray [
["Title", "Flag HQ"],
["Texture", "textures\flag_number\flag_id_hq_co.paa"]
]]
]],
["Simple Shapes", [
["flag_simpleshape_greenoctagon", createHashMapFromArray [
["Title", "Green Octagon"],
["Texture", "textures\simple_shape\flag_simpleshape_greenoctagon_co.paa"]
]],
["flag_simpleshape_bluecircle", createHashMapFromArray [
["Title", "Blue Circle"],
["Texture", "textures\simple_shape\flag_simpleshape_bluecircle_co.paa"]
]],
["flag_simpleshape_orangesquare", createHashMapFromArray [
["Title", "Orange Square"],
["Texture", "textures\simple_shape\flag_simpleshape_orangesquare_co.paa"]
]],
["flag_simpleshape_pinktriangle", createHashMapFromArray[
["Title", "Pink Triangle"],
["Texture", "textures\simple_shape\flag_simpleshape_pinktriangle_co.paa"]
]],
["flag_simpleshape_redpentagon", createHashMapFromArray [
["Title", "Red Pentagon"],
["Texture", "textures\simple_shape\flag_simpleshape_redpentagon_co.paa"]
]]
]],
["Miscellaneous", [
["flag_17th_emblem", createHashMapFromArray [
["Title", "17th Emblem"],
["Texture", "textures\flags_misc\flag_17th_emblem_co.paa"]
]],
["flag_redcross", createHashMapFromArray [
["Title", "Red Cross"],
["Texture", "textures\flags_misc\flag_redcross_co.paa"]
]]
]]
];
private _appliedParentClasses = [
"LandVehicle",
"Helicopter"
];
private _modelsWithoutFlagProxies = [
"TF373_SOAR_MH47G_Base", // MH-47G Chinook
"RHS_MELB_base", // MELB AH-6M/MH-6M/H-6M Little Bird
"USAF_C17", // C17 Globemaster III
"USAF_C130J", // C130J Super Hercules
"USAF_AC130U", // AC130 Spooky II
"ej_UH60M_base", // UH-60M Black Hawk + DAP variants
"rhsusf_fmtv_base" // M1083A1P2 variants + SOV SOCOM variants
];
{
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
{
params ["_target", "_player", "_params"];
private _modelsWithoutFlagProxies = _params select 1;
// check if hierarchy includes any of the models without flag proxies
private _excluded = false;
{
if (_excluded) exitWith {false};
_excluded = _target isKindOf _x;
} forEach _modelsWithoutFlagProxies;
if (_excluded) exitWith {false};
// check if vehicle is alive
alive _target;
}, // condition
{
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 = [];
{
_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;
}, // child code
[_flagActionID, _modelsWithoutFlagProxies], // 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
{
params ["_target", "_player", "_params"];
alive _target && getForcedFlagTexture _target != "";
}, // 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;

View 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;

View File

@@ -0,0 +1 @@
(missionConfigFile >> "VehicleFlags");

View 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;

View 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;