Skip to content

Commit 2f08cf7

Browse files
authored
Add placement preview support to recent tree (#689)
1 parent 1ee7ccf commit 2f08cf7

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

addons/placement/XEH_postInit.sqf

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@
1515
IDC_RSCDISPLAYCURATOR_CREATE_UNITS_CIV,
1616
IDC_RSCDISPLAYCURATOR_CREATE_UNITS_EMPTY
1717
];
18+
19+
// Need special handling for recent tree since items in the tree are not always objects
20+
private _ctrlTreeRecent = _display displayCtrl IDC_RSCDISPLAYCURATOR_CREATE_RECENT;
21+
_ctrlTreeRecent ctrlAddEventHandler ["TreeSelChanged", {
22+
params ["_ctrlTreeRecent", "_selectedPath"];
23+
24+
private _objectType = _ctrlTreeRecent tvData _selectedPath;
25+
26+
if (!isClass (configFile >> "CfgVehicles" >> _objectType)) then {
27+
_objectType = "";
28+
};
29+
30+
[_objectType] call FUNC(setupPreview);
31+
}];
1832
}] call CBA_fnc_addEventHandler;
1933

2034
["zen_curatorDisplayUnloaded", {

addons/placement/functions/fnc_handleTreeChange.sqf

+10-5
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,31 @@
66
* Arguments:
77
* 0: Display <DISPLAY>
88
* 1: Mode <NUMBER>
9-
* 2: Side <NUMBER>
109
*
1110
* Return Value:
1211
* None
1312
*
1413
* Example:
15-
* [DISPLAY, 0, 0] call zen_placement_fnc_handleTreeChange
14+
* [DISPLAY, 0] call zen_placement_fnc_handleTreeChange
1615
*
1716
* Public: No
1817
*/
1918

2019
if (!GVAR(enabled)) exitWith {};
2120

22-
params ["_display", "_mode", "_side"];
21+
params ["_display", "_mode"];
2322

2423
// Setup the preview with if object placement is active
2524
// Otherwise delete the current preview
26-
private _objectType = if (_mode == 0 && {call EFUNC(common,isPlacementActive)}) then {
25+
private _objectType = if (_mode in [0, 4] && {call EFUNC(common,isPlacementActive)}) then {
2726
private _ctrlTree = call EFUNC(common,getActiveTree);
28-
_ctrlTree tvData tvCurSel _ctrlTree
27+
private _data = _ctrlTree tvData tvCurSel _ctrlTree;
28+
29+
if (_mode == 4 && {!isClass (configFile >> "CfgVehicles" >> _data)}) then {
30+
_data = "";
31+
};
32+
33+
_data
2934
} else {
3035
""
3136
};

0 commit comments

Comments
 (0)