diff --git a/addons/placement/XEH_postInit.sqf b/addons/placement/XEH_postInit.sqf index e66c15f1f..79602cdac 100644 --- a/addons/placement/XEH_postInit.sqf +++ b/addons/placement/XEH_postInit.sqf @@ -15,6 +15,20 @@ IDC_RSCDISPLAYCURATOR_CREATE_UNITS_CIV, IDC_RSCDISPLAYCURATOR_CREATE_UNITS_EMPTY ]; + + // Need special handling for recent tree since items in the tree are not always objects + private _ctrlTreeRecent = _display displayCtrl IDC_RSCDISPLAYCURATOR_CREATE_RECENT; + _ctrlTreeRecent ctrlAddEventHandler ["TreeSelChanged", { + params ["_ctrlTreeRecent", "_selectedPath"]; + + private _objectType = _ctrlTreeRecent tvData _selectedPath; + + if (!isClass (configFile >> "CfgVehicles" >> _objectType)) then { + _objectType = ""; + }; + + [_objectType] call FUNC(setupPreview); + }]; }] call CBA_fnc_addEventHandler; ["zen_curatorDisplayUnloaded", { diff --git a/addons/placement/functions/fnc_handleTreeChange.sqf b/addons/placement/functions/fnc_handleTreeChange.sqf index b26c3ac20..3ccfda2db 100644 --- a/addons/placement/functions/fnc_handleTreeChange.sqf +++ b/addons/placement/functions/fnc_handleTreeChange.sqf @@ -6,26 +6,31 @@ * Arguments: * 0: Display * 1: Mode - * 2: Side * * Return Value: * None * * Example: - * [DISPLAY, 0, 0] call zen_placement_fnc_handleTreeChange + * [DISPLAY, 0] call zen_placement_fnc_handleTreeChange * * Public: No */ if (!GVAR(enabled)) exitWith {}; -params ["_display", "_mode", "_side"]; +params ["_display", "_mode"]; // Setup the preview with if object placement is active // Otherwise delete the current preview -private _objectType = if (_mode == 0 && {call EFUNC(common,isPlacementActive)}) then { +private _objectType = if (_mode in [0, 4] && {call EFUNC(common,isPlacementActive)}) then { private _ctrlTree = call EFUNC(common,getActiveTree); - _ctrlTree tvData tvCurSel _ctrlTree + private _data = _ctrlTree tvData tvCurSel _ctrlTree; + + if (_mode == 4 && {!isClass (configFile >> "CfgVehicles" >> _data)}) then { + _data = ""; + }; + + _data } else { "" };