diff --git a/addons/spectator/XEH_preInit.sqf b/addons/spectator/XEH_preInit.sqf index 059d8a9b8e..52aa5db1e0 100644 --- a/addons/spectator/XEH_preInit.sqf +++ b/addons/spectator/XEH_preInit.sqf @@ -9,6 +9,7 @@ PREP(handleMouse); PREP(handleRespawn); PREP(moduleSpectator); PREP(setSpectator); +PREP(updateUnits); PREP(updateView); ADDON = true; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 42aa11be8f..3a16c68692 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -137,7 +137,7 @@ switch (toLower _mode) do { (_display displayCtrl IDC_VIEW) ctrlSetText (["FREE","FIRST","THIRD"] select GVAR(camMode)); // Populate unit tree - //["onload",_display displayCtrl IDC_TREE] call FUNC(updateUnits); + call FUNC(updateUnits); // Hacky way to enable keybindings //_display displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}]; diff --git a/addons/spectator/functions/fnc_updateUnits.sqf b/addons/spectator/functions/fnc_updateUnits.sqf new file mode 100644 index 0000000000..f2feeb948f --- /dev/null +++ b/addons/spectator/functions/fnc_updateUnits.sqf @@ -0,0 +1,29 @@ +#include "script_component.hpp" + +// Remove dead and null units +GVAR(unitList) - [objNull]; +GVAR(unitList) - allDead; + +// Fetch new units for list +{ + if ( + (simulationEnabled _x) && + {(side _x) in [west,east,resistance,civilian] } && + //{!isObjectHidden _unit} && // (currently dev branch only) + {!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen? + ) then { + GVAR(unitList) pushBack _x; + }; +} forEach (allUnits - GVAR(unitList)); + +disableSerialization; +_display = GETUVAR(GVAR(display),displayNull); +_ctrl = _display displayCtrl IDC_TREE; + +// Clear the tree +_ctrl tvCollapse []; + +// Update the tree +{ + // _ctrl tvAdd [[,_forEachIndex], name _x]; +} forEach GVAR(unitList);