Handling the spectatable unit list

This commit is contained in:
SilentSpike 2015-07-15 14:58:38 +01:00
parent 147571c76f
commit 7f04164653
3 changed files with 31 additions and 1 deletions

View File

@ -9,6 +9,7 @@ PREP(handleMouse);
PREP(handleRespawn);
PREP(moduleSpectator);
PREP(setSpectator);
PREP(updateUnits);
PREP(updateView);
ADDON = true;

View File

@ -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}];

View File

@ -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);