Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placement preview support to recent tree #689

Merged
merged 1 commit into from
Dec 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions addons/placement/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
15 changes: 10 additions & 5 deletions addons/placement/functions/fnc_handleTreeChange.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,31 @@
* Arguments:
* 0: Display <DISPLAY>
* 1: Mode <NUMBER>
* 2: Side <NUMBER>
*
* 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 {
""
};
Expand Down