From 896a4698acbbdd0f54b8bb77cdc74dd3d1a45805 Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Thu, 21 May 2020 18:17:15 +0200 Subject: [PATCH 01/19] API function for adding custom textures --- addons/garage/XEH_PREP.hpp | 1 + .../functions/fnc_defineCustomTexture.sqf | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 addons/garage/functions/fnc_defineCustomTexture.sqf diff --git a/addons/garage/XEH_PREP.hpp b/addons/garage/XEH_PREP.hpp index d188d5cd0..d81cfba5c 100644 --- a/addons/garage/XEH_PREP.hpp +++ b/addons/garage/XEH_PREP.hpp @@ -1,5 +1,6 @@ PREP(applyToAll); PREP(closeGarage); +PREP(defineCustomTexture); PREP(getVehicleData); PREP(handleMouse); PREP(onAnimationSelect); diff --git a/addons/garage/functions/fnc_defineCustomTexture.sqf b/addons/garage/functions/fnc_defineCustomTexture.sqf new file mode 100755 index 000000000..c91fd94b2 --- /dev/null +++ b/addons/garage/functions/fnc_defineCustomTexture.sqf @@ -0,0 +1,36 @@ +#include "script_component.hpp" +/* + * Author: Kex + * Defines custom texture variant for all vehicles that inherit from the given vehicle type. + * + * Arguments: + * 0: Base vehicle type + * 1: Texture variant name + * 2: Path of texture for each hidden selection + * + * Return Value: + * None + * + * Example: + * [vehicleType, variantName, [texturePath1, texturePath2]] call zen_garage_fnc_defineCustomTexture + * + * Public: Yes + */ + +params ["_baseVehicleType", "_variantName", "_texture"]; + +if (isNil QGVAR(customVehicleTextures)) then { + GVAR(customVehicleTextures) = [] call CBA_fnc_createNamespace; +}; + +{ + private _vehicleType = configName _x; + // Clear garage cache + GVAR(vehicleDataCache) setVariable [_vehicleType, []]; + + private _textures = GVAR(customVehicleTextures) getVariable [_vehicleType, []]; + _textures pushBack [_texture, _variantName]; + GVAR(customVehicleTextures) setVariable [_vehicleType, _textures]; +} forEach (format ["configName _x isKindOf '%1'", _baseVehicleType] configClasses (configFile / "CfgVehicles")); + +nil From 3edf0f78de1586735e4e82a6fa786a2ce22ad872 Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Thu, 21 May 2020 18:20:10 +0200 Subject: [PATCH 02/19] Vehicle customization helper functions --- addons/common/XEH_PREP.hpp | 2 + .../common/functions/fnc_customizeVehicle.sqf | 52 +++++++++++++++++++ .../functions/fnc_getVehicleCustomization.sqf | 47 +++++++++++++++++ addons/common/script_component.hpp | 5 ++ 4 files changed, 106 insertions(+) create mode 100755 addons/common/functions/fnc_customizeVehicle.sqf create mode 100755 addons/common/functions/fnc_getVehicleCustomization.sqf diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 307691d1d..0734fc5e5 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -1,6 +1,7 @@ PREP(changeGroupSide); PREP(collapseTree); PREP(createZeus); +PREP(customizeVehicle); PREP(deployCountermeasures); PREP(deserializeInventory); PREP(deserializeObjects); @@ -27,6 +28,7 @@ PREP(getSelectedUnits); PREP(getSelectedVehicles); PREP(getSideIcon); PREP(getVehicleAmmo); +PREP(getVehicleCustomization); PREP(getVehicleIcon); PREP(getWeaponReloadTime); PREP(hasDefaultInventory); diff --git a/addons/common/functions/fnc_customizeVehicle.sqf b/addons/common/functions/fnc_customizeVehicle.sqf new file mode 100755 index 000000000..c0f57d3fc --- /dev/null +++ b/addons/common/functions/fnc_customizeVehicle.sqf @@ -0,0 +1,52 @@ +#include "script_component.hpp" +/* + * Author: Kex + * Changes the textures, animation sources and/or mass of a given vehicle. + * Based on BIS_fnc_initVehicle, but can be applied multiple times without issues. + * In contrast to BIS_fnc_initVehicle, if texture is passed as an array, + * it expect an array of texture paths (i.e. output of getObjectTextures). + * + * Arguments: + * 0: Vehicle + * 1: Texture + * 2: Animation + * 3: Mass + * + * Return Value: + * None + * + * Example: + * [vehicle player, [texturePath1, texturePath2], [animationSource1, animationPhase1]] call zen_common_fnc_customizeVehicle + * + * Public: No + */ + +params ["_vehicle", ["_texture", false, [false, [], ""]], ["_animation", false, [false, [], ""]], ["_mass", false, [false, 0]]]; + +// Fix: BIS_fnc_initVehicle cannot animate doors multiple times +if (_animation isEqualType []) then { + for "_i" from (count _animation - 2) to 0 step -2 do { + private _name = _animation select _i; + private _phase = _animation select (_i + 1); + if ("door" in toLower _name) then { + _vehicle animateDoor [_name, _phase]; + // Remove entry, since already handled + _animation deleteAt _i; + _animation deleteAt _i; + }; + }; + if (_animation isEqualTo []) then { + _animation = nil; + }; +}; + +if (_texture isEqualType []) then { + [_vehicle, nil, _animation, _mass] call BIS_fnc_initVehicle; + { + _vehicle setObjectTextureGlobal [_forEachIndex, _x]; + } forEach _texture; +} else { + [_vehicle, _texture, _animation, _mass] call BIS_fnc_initVehicle; +}; + +nil diff --git a/addons/common/functions/fnc_getVehicleCustomization.sqf b/addons/common/functions/fnc_getVehicleCustomization.sqf new file mode 100755 index 000000000..b0c302031 --- /dev/null +++ b/addons/common/functions/fnc_getVehicleCustomization.sqf @@ -0,0 +1,47 @@ +#include "script_component.hpp" +/* + * Author: Kex + * Return vehicle customization settings. + * Based on BIS_fnc_getVehicleCustomization. + * In contrast to BIS_fnc_getVehicleCustomization, it works properly for doors + * and textures are returned as an array of texture paths (i.e. output of getObjectTextures). + * + * Arguments: + * 0: Vehicle + * + * Return Value: + * Array of texture paths and array of animations + * + * Example: + * [vehicle player] call zen_common_fnc_getVehicleCustomization + * + * Public: No + */ + +params ["_vehicle"]; + +private _vehicleType = typeOf _vehicle; +private _vehicleConfig = configFile >> "CfgVehicles" >> _vehicleType; + +private _animations = []; +{ + private _config = _x; + private _configName = configName _config; + private _source = getText (_config >> "source"); + + if (!(toLower _configName in BLACKLIST_ANIMATION_NAMES) && {!(toLower _source in BLACKLIST_ANIMATION_SOURCES) && {BLACKLIST_ANIMATION_ATTRIBUTES findIf {isClass (_config >> _x)} == -1}}) then { + private _phase = if ("door" in toLower _configName) then { + _vehicle doorPhase _configName; + } else { + _vehicle animationPhase _configName; + }; + // Some sources will return negative values + if (_phase >= 0) then { + _animations append [_configName, _phase]; + } + }; +} forEach configProperties [_vehicleConfig >> "animationSources", "isClass _x", true]; + +private _textures = getObjectTextures _vehicle; + +[_textures, _animations] diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index 5cbc88c54..68580a21b 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -68,3 +68,8 @@ // Prevent certain magazines from being handled by ammo functions #define BLACKLIST_MAGAZINES ["Laserbatteries"] + +// Prevent certain source animations from being displayed in the garage +#define BLACKLIST_ANIMATION_SOURCES ["hit", "markerlight"] +#define BLACKLIST_ANIMATION_NAMES ["proxy", "doors"] +#define BLACKLIST_ANIMATION_ATTRIBUTES ["weapon", "wheel"] From 07cf73d1f5a87b0500b6afde5f28ea8c4deb34b6 Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Thu, 21 May 2020 18:58:02 +0200 Subject: [PATCH 03/19] Extend customization for garage --- addons/garage/functions/fnc_applyToAll.sqf | 4 +- .../garage/functions/fnc_getVehicleData.sqf | 42 ++++++++++--------- .../functions/fnc_onAnimationSelect.sqf | 2 +- .../garage/functions/fnc_onTextureSelect.sqf | 9 +++- addons/garage/functions/fnc_populateLists.sqf | 32 ++++++++++---- 5 files changed, 56 insertions(+), 33 deletions(-) diff --git a/addons/garage/functions/fnc_applyToAll.sqf b/addons/garage/functions/fnc_applyToAll.sqf index bb96b4e97..d053f1dde 100644 --- a/addons/garage/functions/fnc_applyToAll.sqf +++ b/addons/garage/functions/fnc_applyToAll.sqf @@ -16,12 +16,12 @@ * Public: No */ -(GVAR(center) call BIS_fnc_getVehicleCustomization) params ["_texture", "_animations"]; +(GVAR(center) call EFUNC(common,getVehicleCustomization)) params ["_textures", "_animations"]; private _vehicleType = typeOf GVAR(center); { if (typeOf _x isEqualTo _vehicleType) then { - [_x, _texture, _animations, true] call BIS_fnc_initVehicle; + [_x, _textures, _animations, true] call EFUNC(common,customizeVehicle); }; } forEach SELECTED_OBJECTS; diff --git a/addons/garage/functions/fnc_getVehicleData.sqf b/addons/garage/functions/fnc_getVehicleData.sqf index cdac0ffbb..ff2debcf9 100644 --- a/addons/garage/functions/fnc_getVehicleData.sqf +++ b/addons/garage/functions/fnc_getVehicleData.sqf @@ -25,29 +25,31 @@ private _vehicleType = typeOf _vehicle; private _vehicleData = GVAR(vehicleDataCache) getVariable _vehicleType; if (isNil "_vehicleData") then { - _vehicleData = []; - private _vehicleConfig = configFile >> "CfgVehicles" >> _vehicleType; - private _vehicleFaction = faction _vehicle; + private _animations = []; + ([_vehicle] call EFUNC(common,getVehicleCustomization)) params ["", "_currentAnimations"]; + for "_i" from 0 to (count _currentAnimations - 2) step 2 do { + private _configName = _currentAnimations select _i; + private _displayName = getText (_vehicleConfig >> "animationSources" >> _configName >> "displayName"); + if (_displayName == "") then { + _displayName = (_configName splitString "_") joinString " "; + }; + _animations pushBack [_configName, _displayName]; + }; + + private _textures = []; { - private _entries = []; - - { - private _displayName = getText (_x >> "displayName"); - private _factions = getArray (_x >> "factions"); - - if ( - _displayName != "" - && {getNumber (_x >> "scope") == 2 || {!isNumber (_x >> "scope")}} - && {_factions isEqualTo [] || {_factions findIf {_x == _vehicleFaction} > -1}} - ) then { - _entries pushBack [configName _x, _displayName]; - }; - } forEach configProperties [_x, "isClass _x", true]; - - _vehicleData pushBack _entries; - } forEach [_vehicleConfig >> "animationSources", _vehicleConfig >> "textureSources"]; + private _configName = configName _x; + private _displayName = getText (_x >> "displayName"); + _textures pushBack [_configName, _displayName]; + } forEach configProperties [_vehicleConfig >> "textureSources", "isClass _x", true]; + + // Adding custom definitions + private _customTextures = GVAR(customVehicleTextures) getVariable [_vehicleType, []]; + _textures append _customTextures; + + _vehicleData = [_animations, _textures]; GVAR(vehicleDataCache) setVariable [_vehicleType, _vehicleData]; }; diff --git a/addons/garage/functions/fnc_onAnimationSelect.sqf b/addons/garage/functions/fnc_onAnimationSelect.sqf index fc2a511ec..8227fbbe7 100644 --- a/addons/garage/functions/fnc_onAnimationSelect.sqf +++ b/addons/garage/functions/fnc_onAnimationSelect.sqf @@ -31,4 +31,4 @@ for "_i" from 0 to (lbSize _ctrlListAnimations - 1) do { }; // Update vehicle animations -[GVAR(center), nil, _animations, true] call BIS_fnc_initVehicle; +[GVAR(center), nil, _animations, true] call EFUNC(common,customizeVehicle); diff --git a/addons/garage/functions/fnc_onTextureSelect.sqf b/addons/garage/functions/fnc_onTextureSelect.sqf index 0f19cd902..4de4926d8 100644 --- a/addons/garage/functions/fnc_onTextureSelect.sqf +++ b/addons/garage/functions/fnc_onTextureSelect.sqf @@ -26,5 +26,12 @@ for "_i" from 0 to (lbSize _ctrlListTextures - 1) do { // Check selected texture _ctrlListTextures lbSetPicture [_selectedIndex, ICON_CHECKED]; +private _texture = _ctrlListTextures lbData _selectedIndex; + +// Handle serialized array +if (_texture != "" && {_texture select [0, 1] == '['}) then { + _texture = parseSimpleArray _texture; +}; + // Update vehicle textures -[GVAR(center), [_ctrlListTextures lbData _selectedIndex, 1]] call BIS_fnc_initVehicle; +[GVAR(center), _texture] call EFUNC(common,customizeVehicle); diff --git a/addons/garage/functions/fnc_populateLists.sqf b/addons/garage/functions/fnc_populateLists.sqf index 23a9f594c..9ebac446d 100644 --- a/addons/garage/functions/fnc_populateLists.sqf +++ b/addons/garage/functions/fnc_populateLists.sqf @@ -22,12 +22,17 @@ private _vehicleData = [GVAR(center)] call FUNC(getVehicleData); _vehicleData params ["_vehicleAnimations", "_vehicleTextures"]; private _fnc_addToList = { - params ["_ctrlList", "_configName", "_displayName", "_isChecked"]; + params ["_ctrlList", "_variant", "_displayName", "_isChecked"]; + + if !(_variant isEqualType "") then { + _variant = str _variant; + }; if (_isChecked isEqualType false) then {_isChecked = parseNumber _isChecked}; private _index = _ctrlList lbAdd _displayName; - _ctrlList lbSetData [_index, _configName]; + + _ctrlList lbSetData [_index, _variant]; _ctrlList lbSetValue [_index, _isChecked]; _ctrlList lbSetTooltip [_index, _displayName]; _ctrlList lbSetPicture [_index, [ICON_UNCHECKED, ICON_CHECKED] select _isChecked]; @@ -38,7 +43,11 @@ private _ctrlListAnimations = _display displayCtrl IDC_LIST_ANIMATIONS; { _x params ["_configName", "_displayName"]; - private _isChecked = GVAR(center) animationPhase _configName; + private _isChecked = if ("door" in toLower _configName) then { + GVAR(center) doorPhase _configName; + } else { + GVAR(center) animationPhase _configName; + }; [_ctrlListAnimations, _configName, _displayName, _isChecked] call _fnc_addToList; } forEach _vehicleAnimations; @@ -47,20 +56,25 @@ private _ctrlListTextures = _display displayCtrl IDC_LIST_TEXTURES; private _sourcesConfig = configFile >> "CfgVehicles" >> typeOf GVAR(center) >> "textureSources"; private _currentTextures = getObjectTextures GVAR(center) apply {toLower _x}; { - _x params ["_configName", "_displayName"]; + _x params ["_variant", "_displayName"]; - private _configTextures = getArray (_sourcesConfig >> _configName >> "textures"); + private _textures = if (_variant isEqualType "") then { + getArray (_sourcesConfig >> _variant >> "textures"); + } else { + _variant; + }; private _isChecked = true; - if (count _configTextures == count _currentTextures) then { - {if !((_currentTextures select _forEachIndex) in toLower _x) exitWith {_isChecked = false}} forEach _configTextures; + if (count _textures == count _currentTextures) then { + {if !((_currentTextures select _forEachIndex) in toLower _x) exitWith {_isChecked = false}} forEach _textures; } else { _isChecked = false; }; - [_ctrlListTextures, _configName, _displayName, _isChecked] call _fnc_addToList; + [_ctrlListTextures, _variant, _displayName, _isChecked] call _fnc_addToList; } forEach _vehicleTextures; -// Set font height and hide both lists +// Set font height and sort both lists { _x ctrlSetFontHeight POS_H(0.8); // Todo: setting for font height? + lbSort _x; } forEach [_ctrlListAnimations, _ctrlListTextures]; From 7dfdb96fe3c6e0b1d879f38f6f934e2494b62774 Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Thu, 21 May 2020 19:00:18 +0200 Subject: [PATCH 04/19] Support of extend customization for export SQF and deep copy/paste --- addons/common/functions/fnc_deserializeObjects.sqf | 2 +- addons/common/functions/fnc_exportMissionSQF.sqf | 5 +++-- addons/common/functions/fnc_serializeObjects.sqf | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/common/functions/fnc_deserializeObjects.sqf b/addons/common/functions/fnc_deserializeObjects.sqf index 55da9a06f..e1d4ee50d 100644 --- a/addons/common/functions/fnc_deserializeObjects.sqf +++ b/addons/common/functions/fnc_deserializeObjects.sqf @@ -149,7 +149,7 @@ private _fnc_deserializeVehicle = { [_vehicle, "", []] call BIS_fnc_initVehicle; } else { _customization params ["_textures", "_animations"]; - [_vehicle, _textures, _animations, true] call BIS_fnc_initVehicle; + [_vehicle, _textures, _animations, true] call FUNC(customizeVehicle); }; { diff --git a/addons/common/functions/fnc_exportMissionSQF.sqf b/addons/common/functions/fnc_exportMissionSQF.sqf index 262eaf5f1..f7678e9f2 100644 --- a/addons/common/functions/fnc_exportMissionSQF.sqf +++ b/addons/common/functions/fnc_exportMissionSQF.sqf @@ -246,8 +246,9 @@ private _fnc_processVehicle = { _outputObjects pushBack ["%1 forceFlagTexture %2;", _varName, str _flagTexture]; }; - (_vehicle call BIS_fnc_getVehicleCustomization) params ["_textures", "_animations"]; - _outputObjects pushBack ["[%1, %2, %3, true] call BIS_fnc_initVehicle;", _varName, _textures, _animations]; + (_vehicle call FUNC(getVehicleCustomization)) params ["_textures", "_animations"]; + _outputObjects pushBack ["[%1, nil, %2, true] call BIS_fnc_initVehicle;", _varName, _animations]; + _outputObjects pushBack ["{%1 setObjectTextureGlobal [_forEachIndex, _x]} forEach %2;", _varName, _textures]; [_vehicle, _varName] call _fnc_processInventory; diff --git a/addons/common/functions/fnc_serializeObjects.sqf b/addons/common/functions/fnc_serializeObjects.sqf index 0041f7756..fe0fc4dc2 100644 --- a/addons/common/functions/fnc_serializeObjects.sqf +++ b/addons/common/functions/fnc_serializeObjects.sqf @@ -118,7 +118,7 @@ private _fnc_serializeVehicle = { private _fuel = fuel _vehicle; private _inventory = _vehicle call FUNC(serializeInventory); - private _customization = _vehicle call BIS_fnc_getVehicleCustomization; + private _customization = _vehicle call FUNC(getVehicleCustomization); private _flagTexture = getForcedFlagTexture _vehicle; private _pylonMagazines = getPylonMagazines _vehicle; From 7be56dd65dd2994836e0067c5b54d918a6cbda4b Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Thu, 21 May 2020 19:01:32 +0200 Subject: [PATCH 05/19] Add hidden textures as new variants --- addons/garage/XEH_preInit.sqf | 2 + addons/garage/initCustomVehicleTextures.sqf | 102 ++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100755 addons/garage/initCustomVehicleTextures.sqf diff --git a/addons/garage/XEH_preInit.sqf b/addons/garage/XEH_preInit.sqf index 722ae8119..f38540954 100644 --- a/addons/garage/XEH_preInit.sqf +++ b/addons/garage/XEH_preInit.sqf @@ -20,4 +20,6 @@ GVAR(camYaw) = -45; true ] call EFUNC(attributes,addButton); +#include "initCustomVehicleTextures.sqf" + ADDON = true; diff --git a/addons/garage/initCustomVehicleTextures.sqf b/addons/garage/initCustomVehicleTextures.sqf new file mode 100755 index 000000000..58d2a481b --- /dev/null +++ b/addons/garage/initCustomVehicleTextures.sqf @@ -0,0 +1,102 @@ +// Add hidden Tempest variants +[ + "O_Truck_03_ammo_F", + format ["%1 (%2)", localize "STR_A3_texturesources_hex0", localize "str_a3_rscdisplayaanarticle_menu_3"], + [ + "\A3\Soft_F_EPC\Truck_03\Data\Truck_03_ext01_CO.paa", + "\A3\Soft_F_EPC\Truck_03\Data\Truck_03_ext02_CO.paa", + "\A3\Soft_F_EPC\Truck_03\Data\Truck_03_cargo_CO.paa", + "\A3\missions_f_oldman\Data\img\Decals\science_containers_tempest_co.paa" + ] +] call FUNC(defineCustomTexture); +[ + "O_Truck_03_ammo_F", + format ["%1 (%2)", localize "STR_A3_texturesources_greenhex0", localize "str_a3_rscdisplayaanarticle_menu_3"], + [ + "\A3\Soft_F_Exp\Truck_03\Data\Truck_03_ext01_ghex_CO.paa", + "\A3\Soft_F_Exp\Truck_03\Data\Truck_03_ext02_ghex_CO.paa", + "\A3\Soft_F_Exp\Truck_03\Data\Truck_03_cargo_ghex_CO.paa", + "\A3\missions_f_oldman\Data\img\Decals\science_containers_tempest_co.paa" + ] +] call FUNC(defineCustomTexture); + +// Add hidden Taru variants +{ + [ + _x, + format ["%1 (%2)", localize "str_a3_texturesources_black0", localize "str_a3_rscdisplayaanarticle_menu_3"], + [ + "A3\Air_F_Heli\Heli_Transport_04\Data\heli_transport_04_base_01_Black_co.paa", + "A3\Air_F_Heli\Heli_Transport_04\Data\heli_transport_04_base_02_Black_co.paa", + "A3\missions_f_oldman\Data\img\Decals\science_pods_co.paa", + "A3\Air_F_Heli\Heli_Transport_04\Data\Heli_Transport_04_Pod_Ext02_Black_CO.paa" + ] + ] call FUNC(defineCustomTexture); +} forEach ["O_Heli_Transport_04_covered_F", "O_Heli_Transport_04_medevac_F", "O_Heli_Transport_04_box_F"]; + +// Add hidden Gorgon variants +[ + "I_APC_Wheeled_03_cannon_F", + localize "str_a3_texturesources_sand0", + [ + "A3\Armor_F_Gamma\APC_Wheeled_03\Data\apc_wheeled_03_ext_co.paa", + "A3\Armor_F_Gamma\APC_Wheeled_03\Data\apc_wheeled_03_ext2_co.paa", + "A3\Armor_F_Gamma\APC_Wheeled_03\Data\rcws30_co.paa", + "A3\Armor_F_Gamma\APC_Wheeled_03\Data\apc_wheeled_03_ext_alpha_co.paa" + ] +] call FUNC(defineCustomTexture); + +// Add hidden Blackfoot variants +[ + "B_Heli_Attack_01_dynamicLoadout_F", + localize "STR_A3_TEXTURESOURCES_OLIVE0", + [ + "\A3\Air_F_Beta\heli_attack_01\data\heli_attack_01_co.paa" + ] +] call FUNC(defineCustomTexture); +[ + "B_Heli_Attack_01_dynamicLoadout_F", + localize "str_a3_texturesources_green0", + [ + "A3\Air_F\Heli_Light_02\Data\heli_light_02_common_co.paa" + ] +] call FUNC(defineCustomTexture); +[ + "B_Heli_Attack_01_dynamicLoadout_F", + localize "str_a3_texturesources_black0", + [ + "A3\Air_F_Beta\heli_attack_01\data\UI\Heli_Attack_01_EDEN_CA.PAA" + ] +] call FUNC(defineCustomTexture); + +// Add hidden Orca variants +[ + "Heli_Light_02_base_F", + localize "str_a3_cfgfactionclasses_ind_f0", + [ + "\a3\air_f\Heli_Light_02\Data\heli_light_02_ext_indp_co.paa" + ] +] call FUNC(defineCustomTexture); + +// Add hidden Pawnee/Hummingbird variants +[ + "Heli_Light_01_base_F", + localize "str_a3_texturesources_green0", + [ + "A3\Air_F\Heli_Light_01\Data\Heli_Light_01_ext_Blufor_CO.paa" + ] +] call FUNC(defineCustomTexture); +[ + "Heli_Light_01_base_F", + localize "str_a3_texturesources_black0", + [ + "\a3\air_f\Heli_Light_01\Data\heli_light_01_ext_ion_co.paa" + ] +] call FUNC(defineCustomTexture); +[ + "Heli_Light_01_base_F", + localize "str_a3_cfgfactionclasses_ind_f0", + [ + "A3\Air_F\Heli_Light_01\Data\heli_light_01_ext_indp_co.paa" + ] +] call FUNC(defineCustomTexture); From 0dc5c1f5a907f2c78bdb5b962ea95b7e9c013520 Mon Sep 17 00:00:00 2001 From: oOKexOo Date: Sat, 23 May 2020 08:19:37 +0200 Subject: [PATCH 06/19] Make zen_common_fnc_customizeVehicle backward compatible to bis_fnc_initVehicle --- addons/common/functions/fnc_customizeVehicle.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/common/functions/fnc_customizeVehicle.sqf b/addons/common/functions/fnc_customizeVehicle.sqf index c0f57d3fc..4c57c67bf 100755 --- a/addons/common/functions/fnc_customizeVehicle.sqf +++ b/addons/common/functions/fnc_customizeVehicle.sqf @@ -4,7 +4,7 @@ * Changes the textures, animation sources and/or mass of a given vehicle. * Based on BIS_fnc_initVehicle, but can be applied multiple times without issues. * In contrast to BIS_fnc_initVehicle, if texture is passed as an array, - * it expect an array of texture paths (i.e. output of getObjectTextures). + * it can also alternatively be an array of texture paths (i.e. output of getObjectTextures). * * Arguments: * 0: Vehicle @@ -40,7 +40,7 @@ if (_animation isEqualType []) then { }; }; -if (_texture isEqualType []) then { +if (_texture isEqualType [] && {count _texture < 2 || {(_texture select 1) isEqualType ""}}) then { [_vehicle, nil, _animation, _mass] call BIS_fnc_initVehicle; { _vehicle setObjectTextureGlobal [_forEachIndex, _x]; From e78a3de8d2c6ebd35c6dc28022fa6e40303ed671 Mon Sep 17 00:00:00 2001 From: Kex Date: Thu, 7 Jan 2021 09:46:12 +0100 Subject: [PATCH 07/19] Extend source blacklist --- addons/common/script_component.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index c5bc9c8de..0ddd29128 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -92,6 +92,6 @@ #define BLACKLIST_MAGAZINES ["Laserbatteries"] // Prevent certain source animations from being displayed in the garage -#define BLACKLIST_ANIMATION_SOURCES ["hit", "markerlight"] +#define BLACKLIST_ANIMATION_SOURCES ["hit", "markerlight", "reload", "reloadmagazine", "revolving", "ammorandom", "damper", "wheel"] #define BLACKLIST_ANIMATION_NAMES ["proxy", "doors"] #define BLACKLIST_ANIMATION_ATTRIBUTES ["weapon", "wheel"] From ba3d0a3f0ca4e4a3503de5a64a752f2115114eb3 Mon Sep 17 00:00:00 2001 From: Kex Date: Fri, 8 Jan 2021 00:48:17 +0100 Subject: [PATCH 08/19] Fix hide door animation --- addons/common/functions/fnc_customizeVehicle.sqf | 6 +++--- addons/common/functions/fnc_getVehicleCustomization.sqf | 2 +- addons/garage/functions/fnc_populateLists.sqf | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/common/functions/fnc_customizeVehicle.sqf b/addons/common/functions/fnc_customizeVehicle.sqf index 4c57c67bf..bc322f0ff 100755 --- a/addons/common/functions/fnc_customizeVehicle.sqf +++ b/addons/common/functions/fnc_customizeVehicle.sqf @@ -26,10 +26,10 @@ params ["_vehicle", ["_texture", false, [false, [], ""]], ["_animation", false, // Fix: BIS_fnc_initVehicle cannot animate doors multiple times if (_animation isEqualType []) then { for "_i" from (count _animation - 2) to 0 step -2 do { - private _name = _animation select _i; + private _configName = _animation select _i; private _phase = _animation select (_i + 1); - if ("door" in toLower _name) then { - _vehicle animateDoor [_name, _phase]; + if ("door" in toLower _configName && !("hide" in toLower _configName)) then { + _vehicle animateDoor [_configName, _phase]; // Remove entry, since already handled _animation deleteAt _i; _animation deleteAt _i; diff --git a/addons/common/functions/fnc_getVehicleCustomization.sqf b/addons/common/functions/fnc_getVehicleCustomization.sqf index b0c302031..f195417d4 100755 --- a/addons/common/functions/fnc_getVehicleCustomization.sqf +++ b/addons/common/functions/fnc_getVehicleCustomization.sqf @@ -30,7 +30,7 @@ private _animations = []; private _source = getText (_config >> "source"); if (!(toLower _configName in BLACKLIST_ANIMATION_NAMES) && {!(toLower _source in BLACKLIST_ANIMATION_SOURCES) && {BLACKLIST_ANIMATION_ATTRIBUTES findIf {isClass (_config >> _x)} == -1}}) then { - private _phase = if ("door" in toLower _configName) then { + private _phase = if ("door" in toLower _configName && !("hide" in toLower _configName)) then { _vehicle doorPhase _configName; } else { _vehicle animationPhase _configName; diff --git a/addons/garage/functions/fnc_populateLists.sqf b/addons/garage/functions/fnc_populateLists.sqf index c27438e6b..d49bada36 100644 --- a/addons/garage/functions/fnc_populateLists.sqf +++ b/addons/garage/functions/fnc_populateLists.sqf @@ -43,7 +43,7 @@ private _ctrlListAnimations = _display displayCtrl IDC_LIST_ANIMATIONS; { _x params ["_configName", "_displayName"]; - private _isChecked = if ("door" in toLower _configName) then { + private _isChecked = if ("door" in toLower _configName && !("hide" in toLower _configName)) then { GVAR(center) doorPhase _configName; } else { GVAR(center) animationPhase _configName; From 7e7cc6510b91b3f15af17012247610b818e2e069 Mon Sep 17 00:00:00 2001 From: Kex Date: Wed, 13 Jan 2021 18:56:24 +0100 Subject: [PATCH 09/19] Update addons/garage/functions/fnc_defineCustomTexture.sqf Co-authored-by: NeilZar --- addons/garage/functions/fnc_defineCustomTexture.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/garage/functions/fnc_defineCustomTexture.sqf b/addons/garage/functions/fnc_defineCustomTexture.sqf index c91fd94b2..d8ca49e5a 100755 --- a/addons/garage/functions/fnc_defineCustomTexture.sqf +++ b/addons/garage/functions/fnc_defineCustomTexture.sqf @@ -31,6 +31,6 @@ if (isNil QGVAR(customVehicleTextures)) then { private _textures = GVAR(customVehicleTextures) getVariable [_vehicleType, []]; _textures pushBack [_texture, _variantName]; GVAR(customVehicleTextures) setVariable [_vehicleType, _textures]; -} forEach (format ["configName _x isKindOf '%1'", _baseVehicleType] configClasses (configFile / "CfgVehicles")); +} forEach (format ["configName _x isKindOf '%1'", _baseVehicleType] configClasses (configFile >> "CfgVehicles")); nil From b35d0e1b20374161e043b4554f89b652a6c7fd26 Mon Sep 17 00:00:00 2001 From: Kex Date: Thu, 14 Jan 2021 19:51:16 +0100 Subject: [PATCH 10/19] Update documentation --- docs/user_guide/garage.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/user_guide/garage.md b/docs/user_guide/garage.md index 2268fd0b3..210e2c5ab 100644 --- a/docs/user_guide/garage.md +++ b/docs/user_guide/garage.md @@ -15,3 +15,32 @@ In order to easily apply the same customization to multiple vehicles, all vehicl - BACKSPACE : Toggle interface visibility. - LMB : Show hidden interface. - RMB : Toggle interface (when not panning). + +### Register a Texture + +A custom texture can be made available for the garage by calling the `zen_garage_fnc_defineCustomTexture` function. +This function has an effect on all children of the given base vehicle type. +It is local, and thus must be executed on every Zeus client to have a global effect. + +**Arguments:** + + \# | Description | Type | Default Value (if optional) +:---: | ----------- | ---- | --------------------------- +0 | Base vehicle type | STRING | +1 | Texture variant name | STRING | +2 | Path to texture for each hidden selection | ARRAY | + +**Return Value:** + +- None + +**Example:** +```sqf +[ + "Heli_Light_01_base_F", + "My new shiny AAF texture", + [ + "A3\Air_F\Heli_Light_01\Data\heli_light_01_ext_indp_co.paa" + ] +] call zen_garage_fnc_defineCustomTexture; +``` From 3c398b09661e2f2bede1615508c4c0e48850dce8 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 16 Jan 2021 20:07:54 +0100 Subject: [PATCH 11/19] Clear vehicleDataCache for real --- addons/garage/functions/fnc_defineCustomTexture.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/garage/functions/fnc_defineCustomTexture.sqf b/addons/garage/functions/fnc_defineCustomTexture.sqf index d8ca49e5a..04f674935 100755 --- a/addons/garage/functions/fnc_defineCustomTexture.sqf +++ b/addons/garage/functions/fnc_defineCustomTexture.sqf @@ -26,7 +26,7 @@ if (isNil QGVAR(customVehicleTextures)) then { { private _vehicleType = configName _x; // Clear garage cache - GVAR(vehicleDataCache) setVariable [_vehicleType, []]; + GVAR(vehicleDataCache) setVariable [_vehicleType, nil]; private _textures = GVAR(customVehicleTextures) getVariable [_vehicleType, []]; _textures pushBack [_texture, _variantName]; From 724e143e0b273e33cd7d3c13d47638a6bbf5ee94 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 17:05:46 +0100 Subject: [PATCH 12/19] Serialize customization of statics --- addons/common/functions/fnc_deserializeObjects.sqf | 5 ++++- addons/common/functions/fnc_serializeObjects.sqf | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/common/functions/fnc_deserializeObjects.sqf b/addons/common/functions/fnc_deserializeObjects.sqf index bb3ef5f43..1332976a5 100644 --- a/addons/common/functions/fnc_deserializeObjects.sqf +++ b/addons/common/functions/fnc_deserializeObjects.sqf @@ -217,7 +217,7 @@ private _fnc_deserializeVehicle = { }; private _fnc_deserializeStatic = { - params ["_type", "_position", "_direction", "_simulationEnabled", "_inventory", "_attachedObjects"]; + params ["_type", "_position", "_direction", "_simulationEnabled", "_inventory", "_attachedObjects", ["_customization", [[], []]]]; _position = _position vectorAdd _centerPos; @@ -238,6 +238,9 @@ private _fnc_deserializeStatic = { [_object, _inventory] call FUNC(deserializeInventory); [_object, _attachedObjects] call _fnc_deserializeAttachedObjects; + _customization params ["_textures", "_animations"]; + [_object, _textures, _animations, true] call FUNC(customizeVehicle); + _objects pushBack _object; _object diff --git a/addons/common/functions/fnc_serializeObjects.sqf b/addons/common/functions/fnc_serializeObjects.sqf index 0b1667ff1..8c8a0f5b9 100644 --- a/addons/common/functions/fnc_serializeObjects.sqf +++ b/addons/common/functions/fnc_serializeObjects.sqf @@ -182,8 +182,9 @@ private _fnc_serializeStatic = { private _simulationEnabled = simulationEnabled _object; private _inventory = _object call FUNC(serializeInventory); private _attachedObjects = _object call _fnc_serializeAttachedObjects; + private _customization = _object call FUNC(getVehicleCustomization); - [_type, _position, _direction, _simulationEnabled, _inventory, _attachedObjects] + [_type, _position, _direction, _simulationEnabled, _inventory, _attachedObjects, _customization] }; private _fnc_serializeAttachedObjects = { From f2bae4e4e4d9c3d917f74fb1b33017a1f151807f Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 17:08:01 +0100 Subject: [PATCH 13/19] Generalize handling of animations --- .../common/functions/fnc_customizeVehicle.sqf | 27 +++++++++++-------- .../functions/fnc_getVehicleCustomization.sqf | 14 +++++++--- addons/garage/functions/fnc_populateLists.sqf | 17 +++++++++--- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/addons/common/functions/fnc_customizeVehicle.sqf b/addons/common/functions/fnc_customizeVehicle.sqf index bc322f0ff..91d55714e 100755 --- a/addons/common/functions/fnc_customizeVehicle.sqf +++ b/addons/common/functions/fnc_customizeVehicle.sqf @@ -23,30 +23,35 @@ params ["_vehicle", ["_texture", false, [false, [], ""]], ["_animation", false, [false, [], ""]], ["_mass", false, [false, 0]]]; +private _vehicleType = typeOf _vehicle; + // Fix: BIS_fnc_initVehicle cannot animate doors multiple times if (_animation isEqualType []) then { - for "_i" from (count _animation - 2) to 0 step -2 do { + for "_i" from 0 to (count _animation - 2) step 2 do { private _configName = _animation select _i; + private _source = getText (configFile >> "CfgVehicles" >> _vehicleType >> "animationSources" >> _configName >> "source"); private _phase = _animation select (_i + 1); - if ("door" in toLower _configName && !("hide" in toLower _configName)) then { - _vehicle animateDoor [_configName, _phase]; - // Remove entry, since already handled - _animation deleteAt _i; - _animation deleteAt _i; + switch (_source) do { + case "door": { + _vehicle animateDoor [_configName, _phase]; + }; + case "user": { + _vehicle animateSource [_configName, _phase]; + }; + default { + _vehicle animate [_configName, _phase]; + }; }; }; - if (_animation isEqualTo []) then { - _animation = nil; - }; }; if (_texture isEqualType [] && {count _texture < 2 || {(_texture select 1) isEqualType ""}}) then { - [_vehicle, nil, _animation, _mass] call BIS_fnc_initVehicle; + [_vehicle, nil, nil, _mass] call BIS_fnc_initVehicle; { _vehicle setObjectTextureGlobal [_forEachIndex, _x]; } forEach _texture; } else { - [_vehicle, _texture, _animation, _mass] call BIS_fnc_initVehicle; + [_vehicle, _texture, nil, _mass] call BIS_fnc_initVehicle; }; nil diff --git a/addons/common/functions/fnc_getVehicleCustomization.sqf b/addons/common/functions/fnc_getVehicleCustomization.sqf index f195417d4..a7ac2fe48 100755 --- a/addons/common/functions/fnc_getVehicleCustomization.sqf +++ b/addons/common/functions/fnc_getVehicleCustomization.sqf @@ -30,10 +30,16 @@ private _animations = []; private _source = getText (_config >> "source"); if (!(toLower _configName in BLACKLIST_ANIMATION_NAMES) && {!(toLower _source in BLACKLIST_ANIMATION_SOURCES) && {BLACKLIST_ANIMATION_ATTRIBUTES findIf {isClass (_config >> _x)} == -1}}) then { - private _phase = if ("door" in toLower _configName && !("hide" in toLower _configName)) then { - _vehicle doorPhase _configName; - } else { - _vehicle animationPhase _configName; + private _phase = switch (_source) do { + case "door": { + _vehicle doorPhase _configName; + }; + case "user": { + _vehicle animationSourcePhase _configName; + }; + default { + _vehicle animationPhase _configName; + }; }; // Some sources will return negative values if (_phase >= 0) then { diff --git a/addons/garage/functions/fnc_populateLists.sqf b/addons/garage/functions/fnc_populateLists.sqf index d49bada36..39207afa5 100644 --- a/addons/garage/functions/fnc_populateLists.sqf +++ b/addons/garage/functions/fnc_populateLists.sqf @@ -20,6 +20,7 @@ private _display = findDisplay IDD_DISPLAY; // Get animation and texture data for current vehicle private _vehicleData = [GVAR(center)] call FUNC(getVehicleData); _vehicleData params ["_vehicleAnimations", "_vehicleTextures"]; +private _vehicleType = typeOf GVAR(center); private _fnc_addToList = { params ["_ctrlList", "_variant", "_displayName", "_isChecked"]; @@ -43,11 +44,19 @@ private _ctrlListAnimations = _display displayCtrl IDC_LIST_ANIMATIONS; { _x params ["_configName", "_displayName"]; - private _isChecked = if ("door" in toLower _configName && !("hide" in toLower _configName)) then { - GVAR(center) doorPhase _configName; - } else { - GVAR(center) animationPhase _configName; + private _source = getText (configFile >> "CfgVehicles" >> _vehicleType >> "animationSources" >> _configName >> "source"); + private _phase = switch (_source) do { + case "door": { + _vehicle doorPhase _configName; + }; + case "user": { + _vehicle animationSourcePhase _configName; + }; + default { + _vehicle animationPhase _configName; + }; }; + private _isChecked = _phase >= 0.5; [_ctrlListAnimations, _configName, _displayName, _isChecked] call _fnc_addToList; } forEach _vehicleAnimations; From 474ecfd9d3139c04b78d47543b988105c8756de4 Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 17:44:07 +0100 Subject: [PATCH 14/19] Store data with setVariable --- addons/garage/functions/fnc_onAnimationSelect.sqf | 3 ++- addons/garage/functions/fnc_onTextureSelect.sqf | 8 ++------ addons/garage/functions/fnc_populateLists.sqf | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/garage/functions/fnc_onAnimationSelect.sqf b/addons/garage/functions/fnc_onAnimationSelect.sqf index 8227fbbe7..fac563a55 100644 --- a/addons/garage/functions/fnc_onAnimationSelect.sqf +++ b/addons/garage/functions/fnc_onAnimationSelect.sqf @@ -26,7 +26,8 @@ _ctrlListAnimations lbSetPicture [_selectedIndex, CHECK_ICONS select _value]; // Create array of all animation states private _animations = []; for "_i" from 0 to (lbSize _ctrlListAnimations - 1) do { - _animations pushBack (_ctrlListAnimations lbData _i); + private _dataVar = _ctrlListAnimations lbData _i; + _animations pushBack (_ctrlListAnimations getVariable _dataVar); _animations pushBack (_ctrlListAnimations lbValue _i); }; diff --git a/addons/garage/functions/fnc_onTextureSelect.sqf b/addons/garage/functions/fnc_onTextureSelect.sqf index 4de4926d8..2947bcf97 100644 --- a/addons/garage/functions/fnc_onTextureSelect.sqf +++ b/addons/garage/functions/fnc_onTextureSelect.sqf @@ -26,12 +26,8 @@ for "_i" from 0 to (lbSize _ctrlListTextures - 1) do { // Check selected texture _ctrlListTextures lbSetPicture [_selectedIndex, ICON_CHECKED]; -private _texture = _ctrlListTextures lbData _selectedIndex; - -// Handle serialized array -if (_texture != "" && {_texture select [0, 1] == '['}) then { - _texture = parseSimpleArray _texture; -}; +private _dataVar = _ctrlListTextures lbData _selectedIndex; +private _texture = _ctrlListTextures getVariable _dataVar; // Update vehicle textures [GVAR(center), _texture] call EFUNC(common,customizeVehicle); diff --git a/addons/garage/functions/fnc_populateLists.sqf b/addons/garage/functions/fnc_populateLists.sqf index 39207afa5..c2a96f425 100644 --- a/addons/garage/functions/fnc_populateLists.sqf +++ b/addons/garage/functions/fnc_populateLists.sqf @@ -32,11 +32,14 @@ private _fnc_addToList = { if (_isChecked isEqualType false) then {_isChecked = parseNumber _isChecked}; private _index = _ctrlList lbAdd _displayName; + private _dataVar = str _index; - _ctrlList lbSetData [_index, _variant]; + _ctrlList lbSetData [_index, _dataVar]; _ctrlList lbSetValue [_index, _isChecked]; _ctrlList lbSetTooltip [_index, _displayName]; _ctrlList lbSetPicture [_index, [ICON_UNCHECKED, ICON_CHECKED] select _isChecked]; + + _ctrlList setVariable [_dataVar, _variant]; }; // Add items to animations list From 216044c532309ba312b6b79c86330964ebded43d Mon Sep 17 00:00:00 2001 From: Kex Date: Sat, 23 Jan 2021 21:20:24 +0100 Subject: [PATCH 15/19] Instant animation for serialization --- addons/common/functions/fnc_customizeVehicle.sqf | 9 +++++---- addons/garage/functions/fnc_applyToAll.sqf | 2 +- addons/garage/functions/fnc_onAnimationSelect.sqf | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/common/functions/fnc_customizeVehicle.sqf b/addons/common/functions/fnc_customizeVehicle.sqf index 91d55714e..21c56b3b4 100755 --- a/addons/common/functions/fnc_customizeVehicle.sqf +++ b/addons/common/functions/fnc_customizeVehicle.sqf @@ -11,6 +11,7 @@ * 1: Texture * 2: Animation * 3: Mass + * 4: Instant animation * * Return Value: * None @@ -21,7 +22,7 @@ * Public: No */ -params ["_vehicle", ["_texture", false, [false, [], ""]], ["_animation", false, [false, [], ""]], ["_mass", false, [false, 0]]]; +params ["_vehicle", ["_texture", false, [false, [], ""]], ["_animation", false, [false, [], ""]], ["_mass", false, [false, 0]], ["_instantAnimation", true, [false]]]; private _vehicleType = typeOf _vehicle; @@ -33,13 +34,13 @@ if (_animation isEqualType []) then { private _phase = _animation select (_i + 1); switch (_source) do { case "door": { - _vehicle animateDoor [_configName, _phase]; + _vehicle animateDoor [_configName, _phase, _instantAnimation]; }; case "user": { - _vehicle animateSource [_configName, _phase]; + _vehicle animateSource [_configName, _phase, _instantAnimation]; }; default { - _vehicle animate [_configName, _phase]; + _vehicle animate [_configName, _phase, _instantAnimation]; }; }; }; diff --git a/addons/garage/functions/fnc_applyToAll.sqf b/addons/garage/functions/fnc_applyToAll.sqf index d053f1dde..2b02e6a4a 100644 --- a/addons/garage/functions/fnc_applyToAll.sqf +++ b/addons/garage/functions/fnc_applyToAll.sqf @@ -22,6 +22,6 @@ private _vehicleType = typeOf GVAR(center); { if (typeOf _x isEqualTo _vehicleType) then { - [_x, _textures, _animations, true] call EFUNC(common,customizeVehicle); + [_x, _textures, _animations, true, false] call EFUNC(common,customizeVehicle); }; } forEach SELECTED_OBJECTS; diff --git a/addons/garage/functions/fnc_onAnimationSelect.sqf b/addons/garage/functions/fnc_onAnimationSelect.sqf index fac563a55..e91953bfa 100644 --- a/addons/garage/functions/fnc_onAnimationSelect.sqf +++ b/addons/garage/functions/fnc_onAnimationSelect.sqf @@ -32,4 +32,4 @@ for "_i" from 0 to (lbSize _ctrlListAnimations - 1) do { }; // Update vehicle animations -[GVAR(center), nil, _animations, true] call EFUNC(common,customizeVehicle); +[GVAR(center), nil, _animations, true, false] call EFUNC(common,customizeVehicle); From c2dc516324f34ba40a56120e754d015493297ed9 Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 24 Jan 2021 04:31:12 +0100 Subject: [PATCH 16/19] Refactoring --- addons/garage/functions/fnc_defineCustomTexture.sqf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/garage/functions/fnc_defineCustomTexture.sqf b/addons/garage/functions/fnc_defineCustomTexture.sqf index 04f674935..06f54f845 100755 --- a/addons/garage/functions/fnc_defineCustomTexture.sqf +++ b/addons/garage/functions/fnc_defineCustomTexture.sqf @@ -28,9 +28,11 @@ if (isNil QGVAR(customVehicleTextures)) then { // Clear garage cache GVAR(vehicleDataCache) setVariable [_vehicleType, nil]; - private _textures = GVAR(customVehicleTextures) getVariable [_vehicleType, []]; + if (isNil {GVAR(customVehicleTextures) getVariable _vehicleType}) then { + GVAR(customVehicleTextures) setVariable [_vehicleType, []]; + }; + private _textures = GVAR(customVehicleTextures) getVariable _vehicleType; _textures pushBack [_texture, _variantName]; - GVAR(customVehicleTextures) setVariable [_vehicleType, _textures]; } forEach (format ["configName _x isKindOf '%1'", _baseVehicleType] configClasses (configFile >> "CfgVehicles")); nil From 2ee77acfd53d21f0eed459d5b5ea6cca36320663 Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 24 Jan 2021 04:32:18 +0100 Subject: [PATCH 17/19] Handle textures with no display name --- addons/garage/functions/fnc_getVehicleData.sqf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/garage/functions/fnc_getVehicleData.sqf b/addons/garage/functions/fnc_getVehicleData.sqf index ff2debcf9..30254571f 100644 --- a/addons/garage/functions/fnc_getVehicleData.sqf +++ b/addons/garage/functions/fnc_getVehicleData.sqf @@ -32,7 +32,7 @@ if (isNil "_vehicleData") then { for "_i" from 0 to (count _currentAnimations - 2) step 2 do { private _configName = _currentAnimations select _i; private _displayName = getText (_vehicleConfig >> "animationSources" >> _configName >> "displayName"); - if (_displayName == "") then { + if (_displayName isEqualTo "") then { _displayName = (_configName splitString "_") joinString " "; }; _animations pushBack [_configName, _displayName]; @@ -42,6 +42,9 @@ if (isNil "_vehicleData") then { { private _configName = configName _x; private _displayName = getText (_x >> "displayName"); + if (_displayName isEqualTo "") then { + _displayName = (_configName splitString "_") joinString " "; + }; _textures pushBack [_configName, _displayName]; } forEach configProperties [_vehicleConfig >> "textureSources", "isClass _x", true]; From ef5bf7e174f2f0440cb9ae2fa6fb6f043b0c1dfe Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 24 Jan 2021 04:33:41 +0100 Subject: [PATCH 18/19] Don't convert data to string anymore --- addons/garage/functions/fnc_populateLists.sqf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/addons/garage/functions/fnc_populateLists.sqf b/addons/garage/functions/fnc_populateLists.sqf index c2a96f425..20bf2018a 100644 --- a/addons/garage/functions/fnc_populateLists.sqf +++ b/addons/garage/functions/fnc_populateLists.sqf @@ -25,10 +25,6 @@ private _vehicleType = typeOf GVAR(center); private _fnc_addToList = { params ["_ctrlList", "_variant", "_displayName", "_isChecked"]; - if !(_variant isEqualType "") then { - _variant = str _variant; - }; - if (_isChecked isEqualType false) then {_isChecked = parseNumber _isChecked}; private _index = _ctrlList lbAdd _displayName; From 0caa83eb927df61707eb8c3bbe410c96b92488e9 Mon Sep 17 00:00:00 2001 From: Kex Date: Sun, 24 Jan 2021 04:34:59 +0100 Subject: [PATCH 19/19] Refine animation black- and whitelits --- addons/common/functions/fnc_getVehicleCustomization.sqf | 6 +++--- addons/common/script_component.hpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/common/functions/fnc_getVehicleCustomization.sqf b/addons/common/functions/fnc_getVehicleCustomization.sqf index a7ac2fe48..b4f675ddf 100755 --- a/addons/common/functions/fnc_getVehicleCustomization.sqf +++ b/addons/common/functions/fnc_getVehicleCustomization.sqf @@ -26,10 +26,10 @@ private _vehicleConfig = configFile >> "CfgVehicles" >> _vehicleType; private _animations = []; { private _config = _x; - private _configName = configName _config; - private _source = getText (_config >> "source"); + private _configName = toLower configName _config; + private _source = toLower getText (_config >> "source"); - if (!(toLower _configName in BLACKLIST_ANIMATION_NAMES) && {!(toLower _source in BLACKLIST_ANIMATION_SOURCES) && {BLACKLIST_ANIMATION_ATTRIBUTES findIf {isClass (_config >> _x)} == -1}}) then { + if (_source in WHITELIST_ANIMATION_SOURCES && {BLACKLIST_ANIMATION_INNAMES findIf {_x in _configName} == -1 && {BLACKLIST_ANIMATION_ATTRIBUTES findIf {isClass (_config >> _x)} == -1}}) then { private _phase = switch (_source) do { case "door": { _vehicle doorPhase _configName; diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index 0ddd29128..524e3892b 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -92,6 +92,6 @@ #define BLACKLIST_MAGAZINES ["Laserbatteries"] // Prevent certain source animations from being displayed in the garage -#define BLACKLIST_ANIMATION_SOURCES ["hit", "markerlight", "reload", "reloadmagazine", "revolving", "ammorandom", "damper", "wheel"] -#define BLACKLIST_ANIMATION_NAMES ["proxy", "doors"] -#define BLACKLIST_ANIMATION_ATTRIBUTES ["weapon", "wheel"] +#define WHITELIST_ANIMATION_SOURCES ["user", "door", "doors", "proxy"] +#define BLACKLIST_ANIMATION_INNAMES ["proxy", "doors", "offset", "autoloader", "shtora", "elev", "obs", "offset", "recoil", "sight", "hook", "brakes", "eject", "vtol", "pip", "switch", "fuel", "burner" "rwr", "filter"] +#define BLACKLIST_ANIMATION_ATTRIBUTES ["weapon", "wheel", "isComponent"]