From 10c1c26c69a3e568721c77ebae48217e00b7422f Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Fri, 17 Jul 2015 18:54:19 +0100 Subject: [PATCH] Improved unit switching --- addons/spectator/UI/interface.hpp | 1 - .../spectator/functions/fnc_handleInterface.sqf | 3 +-- addons/spectator/functions/fnc_updateView.sqf | 15 +++++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/spectator/UI/interface.hpp b/addons/spectator/UI/interface.hpp index e1cc553c82..281ff0697a 100644 --- a/addons/spectator/UI/interface.hpp +++ b/addons/spectator/UI/interface.hpp @@ -170,7 +170,6 @@ class GVAR(interface) { onTreeDblClick = QUOTE([ARR_2('onTreeDblClick',_this)] call FUNC(handleInterface)); }; class unitRefresh: RscButtonMenu { - style = 2; x = 0; y = safeZoneH - TOOL_H * 3; w = TOOL_W * 2; diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 0b2dcdc30c..22e805e321 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -299,8 +299,7 @@ switch (toLower _mode) do { _newMode = [2,2,1] select GVAR(camMode); }; - GVAR(camUnit) = _newUnit; - [_newMode] call FUNC(updateView); + [_newMode,_newUnit] call FUNC(updateView); }; }; }; diff --git a/addons/spectator/functions/fnc_updateView.sqf b/addons/spectator/functions/fnc_updateView.sqf index fbf58b7f7c..706b9e251e 100644 --- a/addons/spectator/functions/fnc_updateView.sqf +++ b/addons/spectator/functions/fnc_updateView.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" -params [["_newMode",GVAR(camMode)]]; +params [["_newMode",GVAR(camMode)],["_newUnit",GVAR(camUnit)]]; // Reset gun cam if mode is changing if (_newMode != GVAR(camMode)) then { @@ -11,6 +11,7 @@ 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 @@ -21,21 +22,23 @@ if (GVAR(camMode) == 0) then { // Free cameraEffectEnableHUD false; } else { // First ensure valid unit is selected - if !(GVAR(camUnit) in GVAR(unitList)) then { - GVAR(camUnit) = GVAR(unitList) select floor(random(count GVAR(unitList))); + if !(_newUnit in GVAR(unitList)) then { + _newUnit = GVAR(unitList) select floor(random(count GVAR(unitList))); }; if (GVAR(camMode) == 1) then { // Internal // Handle gun cam if (GVAR(gunCam)) then { - GVAR(camUnit) switchCamera "gunner"; + _newUnit switchCamera "gunner"; } else { - GVAR(camUnit) switchCamera "internal"; + _newUnit switchCamera "internal"; }; } else { // External - GVAR(camUnit) switchCamera "external"; + _newUnit switchCamera "external"; }; + GVAR(camUnit) = _newUnit; + // Terminate camera view GVAR(camera) cameraEffect ["terminate", "back"]; cameraEffectEnableHUD true;