|
| 1 | +#include "script_component.hpp" |
| 2 | + |
| 3 | +private _factions = []; |
| 4 | +private _cfgVehicles = configFile >> "CfgVehicles"; |
| 5 | +private _cfgFactionClasses = configFile >> "CfgFactionClasses"; |
| 6 | +private _cfgEditorCategories = configFile >> "CfgEditorCategories"; |
| 7 | + |
| 8 | +// Zeus only includes objects defined in the units array of CfgPatches classes |
| 9 | +{ |
| 10 | + { |
| 11 | + // Classes that do not inherit from AllVehicles have thier side ignored and are considered props (Zeus also ignores animals) |
| 12 | + if (_x isKindOf "AllVehicles" && {!(_x isKindOf "Animal")}) then { |
| 13 | + private _config = _cfgVehicles >> _x; |
| 14 | + |
| 15 | + // scopeCurator always has priority over scope, scope is only used if scopeCurator is not defined |
| 16 | + if (getNumber (_config >> "scopeCurator") == 2 || {getNumber (_config >> "scope") == 2 && {!isNumber (_config >> "scopeCurator")}}) then { |
| 17 | + private _side = getNumber (_config >> "side"); |
| 18 | + |
| 19 | + if (_side in [0, 1, 2, 3]) then { |
| 20 | + // Either editorCategory or faction can be used to set an object's category |
| 21 | + // Usually, faction is used for characters and vehicles and editorCategory is used for props |
| 22 | + // When both are present, editorCategory has priority and is used by Zeus |
| 23 | + private _factionConfig = if (isText (_config >> "editorCategory")) then { |
| 24 | + _cfgEditorCategories >> getText (_config >> "editorCategory") |
| 25 | + } else { |
| 26 | + _cfgFactionClasses >> getText (_config >> "faction") |
| 27 | + }; |
| 28 | + |
| 29 | + _factions pushBackUnique [getText (_factionConfig >> "displayName"), configName _factionConfig, _side]; |
| 30 | + }; |
| 31 | + }; |
| 32 | + }; |
| 33 | + } forEach getArray (_x >> "units"); |
| 34 | +} forEach configProperties [configFile >> "CfgPatches", "isClass _x"]; |
| 35 | + |
| 36 | +// Group compositions do not necessarily use the same faction names as the object's they contain |
| 37 | +{ |
| 38 | + private _side = getNumber (_x >> "side"); |
| 39 | + |
| 40 | + if (_side in [0, 1, 2, 3]) then { |
| 41 | + { |
| 42 | + private _name = getText (_x >> "name"); |
| 43 | + |
| 44 | + // Add the faction if one with this name and side does not exist yet |
| 45 | + if (_factions findIf {_x select 0 == _name && {_x select 2 == _side}} == -1) then { |
| 46 | + private _faction = configName _x; |
| 47 | + |
| 48 | + // Add "_groups" suffix to the faction class name if it already exists |
| 49 | + // Happens when groups use the same faction class as objects but with a different display name |
| 50 | + if (_factions findIf {_x select 1 == _faction} != -1) then { |
| 51 | + _faction = _faction + "_groups"; |
| 52 | + }; |
| 53 | + |
| 54 | + _factions pushBackUnique [_name, _faction, _side]; |
| 55 | + }; |
| 56 | + } forEach configProperties [_x, "isClass _x"]; |
| 57 | + }; |
| 58 | +} forEach configProperties [configFile >> "CfgGroups", "isClass _x"]; |
| 59 | + |
| 60 | +// Sort factions in ascending order by name |
| 61 | +_factions sort true; |
| 62 | + |
| 63 | +uiNamespace setVariable [QGVAR(factions), _factions]; |
0 commit comments