2015-07-16 10:15:33 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
2015-07-19 01:25:52 +00:00
|
|
|
* Maintains the spectatable unit list and updates the unit tree accordingly
|
2015-07-18 17:46:46 +00:00
|
|
|
* Also updates current camera unit when status changes
|
2015-07-16 10:15:33 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2015-07-19 01:25:52 +00:00
|
|
|
* 0: Parameters <ANY>
|
|
|
|
* 1: PFH handle <NUMBER>
|
2015-07-16 10:15:33 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
2015-07-19 12:40:08 +00:00
|
|
|
* [ace_spectator_fnc_handleUnits, 10, _display] call CBA_fnc_addPerFrameHandler;
|
2015-07-16 10:15:33 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-19 01:25:52 +00:00
|
|
|
params ["_display"];
|
|
|
|
|
2015-07-17 01:30:00 +00:00
|
|
|
// Kill PFH when display is closed
|
2015-07-19 01:25:52 +00:00
|
|
|
if (isNull _display) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
|
2015-07-16 10:15:33 +00:00
|
|
|
|
2015-07-18 15:50:11 +00:00
|
|
|
// Remove all dead and null units from the list
|
2015-07-19 01:25:52 +00:00
|
|
|
[] call FUNC(updateUnits);
|
2015-07-18 15:50:11 +00:00
|
|
|
|
2015-08-05 12:19:47 +00:00
|
|
|
// Camera shouldn't stay on unit that isn't in the list (unless dead)
|
2015-07-18 17:25:59 +00:00
|
|
|
if !(GVAR(camUnit) in GVAR(unitList)) then {
|
2015-08-05 12:19:47 +00:00
|
|
|
if (alive GVAR(camUnit) || isNull GVAR(camUnit)) then {
|
|
|
|
[nil,1] call FUNC(cycleCamera);
|
|
|
|
};
|
2015-07-18 17:25:59 +00:00
|
|
|
};
|
|
|
|
|
2015-07-19 12:40:08 +00:00
|
|
|
// Reduce overhead when unit tree is hidden
|
2015-07-19 22:03:40 +00:00
|
|
|
if (ctrlShown (_display displayCtrl IDC_UNIT)) then {
|
2015-07-19 12:40:08 +00:00
|
|
|
// Reduce overhead by spreading across frames
|
2016-05-22 13:27:24 +00:00
|
|
|
[FUNC(handleInterface),["onUnitsUpdate",[(_display displayCtrl IDC_UNIT) controlsGroupCtrl IDC_UNIT_TREE]],1] call CBA_fnc_waitAndExecute;
|
2015-07-19 12:40:08 +00:00
|
|
|
};
|