mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improved camUnit handling
This commit is contained in:
parent
bfd9be9ce1
commit
60b3c6c0f8
@ -59,13 +59,5 @@ switch (GVAR(camMode)) do {
|
||||
[GVAR(camera), GVAR(camTilt), GVAR(camBank)] call BIS_fnc_setPitchBank;
|
||||
};
|
||||
case 1: { // Internal
|
||||
// Update view when state of unit changes
|
||||
if !(
|
||||
(alive GVAR(camUnit)) &&
|
||||
{vehicle GVAR(camUnit) == GVAR(camUnit)} &&
|
||||
{GVAR(camUnit) in GVAR(unitList)}
|
||||
) then {
|
||||
[] call FUNC(updateCamera);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -19,6 +19,10 @@
|
||||
// Kill PFH when display is closed
|
||||
if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith { [_this select 1] call CBA_fnc_removePerFrameHandler; };
|
||||
|
||||
// Remove all dead and null units from the list
|
||||
GVAR(unitList) = GVAR(unitList) - allDead;
|
||||
GVAR(unitList) = GVAR(unitList) - [objNull];
|
||||
|
||||
// Fetch tree
|
||||
disableSerialization;
|
||||
_display = GETUVAR(GVAR(display),displayNull);
|
||||
@ -33,37 +37,38 @@ tvClear _ctrl;
|
||||
// Update the tree from the unit list
|
||||
_cachedGrps = [];
|
||||
{
|
||||
// Exclude any currently dead/disabled units
|
||||
if ((alive _x) && (simulationEnabled _x) && !(_x getVariable [QGVAR(isSpectator), false])) then {
|
||||
_grp = group _x;
|
||||
_node = 0;
|
||||
// If group already exists, find existing node
|
||||
if !(_grp in _cachedGrps) then {
|
||||
_side = [west,east,resistance,civilian,sideLogic] find (side _grp);
|
||||
_node = _ctrl tvCount [];
|
||||
_grp = group _x;
|
||||
_node = 0;
|
||||
// If group already exists, find existing node
|
||||
if !(_grp in _cachedGrps) then {
|
||||
_side = [west,east,resistance,civilian,sideLogic] find (side _grp);
|
||||
_node = _ctrl tvCount [];
|
||||
|
||||
_ctrl tvAdd [[], groupID _grp];
|
||||
_ctrl tvSetValue [[_node], _side];
|
||||
_ctrl tvAdd [[], groupID _grp];
|
||||
_ctrl tvSetValue [[_node], _side];
|
||||
|
||||
_cachedGrps pushBack _grp;
|
||||
} else {
|
||||
_node = _cachedGrps find _grp;
|
||||
};
|
||||
|
||||
_index = _ctrl tvCount [_node];
|
||||
|
||||
_ctrl tvAdd [[_node], name _x];
|
||||
_ctrl tvSetData [[_node,_index], netID _x];
|
||||
|
||||
// Preserve the previous selection
|
||||
if (_curSelData == (_ctrl tvData [_node,_index])) then {
|
||||
_ctrl tvSetCurSel [_node,_index];
|
||||
};
|
||||
|
||||
_ctrl tvSort [[_node],false];
|
||||
_ctrl tvExpand [_node];
|
||||
_cachedGrps pushBack _grp;
|
||||
} else {
|
||||
_node = _cachedGrps find _grp;
|
||||
};
|
||||
|
||||
_index = _ctrl tvCount [_node];
|
||||
|
||||
_ctrl tvAdd [[_node], name _x];
|
||||
_ctrl tvSetData [[_node,_index], netID _x];
|
||||
|
||||
// Preserve the previous selection
|
||||
if (_curSelData == (_ctrl tvData [_node,_index])) then {
|
||||
_ctrl tvSetCurSel [_node,_index];
|
||||
};
|
||||
|
||||
_ctrl tvSort [[_node],false];
|
||||
_ctrl tvExpand [_node];
|
||||
} forEach GVAR(unitList);
|
||||
|
||||
if ((tvCurSel _ctrl) isEqualTo []) then {
|
||||
[0,objNull] call FUNC(updateCamera);
|
||||
};
|
||||
|
||||
// Sort group nodes by side
|
||||
_ctrl tvSortByValue [[],false];
|
||||
|
@ -11,19 +11,19 @@ if (_newMode != GVAR(camMode)) then {
|
||||
// When no units available to spectate, exit to freecam
|
||||
if (GVAR(unitList) isEqualTo []) then {
|
||||
GVAR(camMode) = 0;
|
||||
GVAR(camUnit) = objNull;
|
||||
};
|
||||
|
||||
if (GVAR(camMode) == 0) then { // Free
|
||||
// Preserve camUnit value for consistency when manually changing view
|
||||
GVAR(camera) cameraEffect ["internal", "back"];
|
||||
|
||||
GVAR(camUnit) = GVAR(camera);
|
||||
|
||||
// HUD stuff
|
||||
showCinemaBorder false;
|
||||
cameraEffectEnableHUD false;
|
||||
} else {
|
||||
// First ensure valid unit is selected
|
||||
if !(_newUnit in GVAR(unitList)) then {
|
||||
// When null unit is given choose random
|
||||
if (isNull _newUnit) then {
|
||||
_newUnit = GVAR(unitList) select floor(random(count GVAR(unitList)));
|
||||
};
|
||||
|
||||
|
@ -61,6 +61,7 @@ if (GVAR(filterSides) == 0) then {
|
||||
(alive _x) &&
|
||||
{(_x isKindOf "CAManBase")} &&
|
||||
{(side _x) in _sides} && // Side filter
|
||||
{simulationEnabled _x}
|
||||
{!(_x getVariable [QGVAR(isSpectator), false])} // Who watches the watchmen?
|
||||
) then {
|
||||
GVAR(unitList) pushBack _x;
|
||||
|
Loading…
Reference in New Issue
Block a user