Improve view switching UX

This commit is contained in:
SilentSpike 2015-07-16 19:43:16 +01:00
parent 20f05d9906
commit 723a0f96f6
2 changed files with 22 additions and 12 deletions

View File

@ -234,10 +234,7 @@ switch (toLower _mode) do {
//[_show] call FUNC(handleMap);
};
case 57: { // Spacebar
GVAR(camMode) = [1,2,0] select GVAR(camMode);
GVAR(gunCam) = false;
call FUNC(updateView);
[[1,2,0] select GVAR(camMode)] call FUNC(updateView);
};
};
@ -279,19 +276,25 @@ switch (toLower _mode) do {
// Tree events
case "ontreedblclick": {
// Update camera view when listbox unit is double clicked on
private ["_sel","_netID"];
private ["_sel","_netID","_newUnit","_newMode"];
_sel = _args select 1;
// Ensure a unit was selected
if (count _sel == 2) then {
_netID = (_args select 0) tvData _sel;
GVAR(camUnit) = objectFromNetId _netID;
_newUnit = objectFromNetId _netID;
// Only update camera mode when in free cam
if (GVAR(camMode) == 0) then {
GVAR(camMode) = 1;
_newMode = = 1;
} else {
// When unit is reselected, toggle camera mode
if (_newUnit == GVAR(camUnit)) then {
_newMode = [0,2,1] select GVAR(camMode);
};
call FUNC(updateView);
};
GVAR(camUnit) = _newUnit;
[_newMode] call FUNC(updateView);
};
};
};

View File

@ -1,8 +1,16 @@
#include "script_component.hpp"
params [["_newMode",GVAR(camMode)]];
// Reset gun cam if mode is changing
if (_newMode != GVAR(camMode)) then {
GVAR(gunCam) = false;
GVAR(camMode) = _newMode;
};
GVAR(camera) camSetFOV GVAR(camFOV);
if (GVAR(camMode) == 0) then { // Free
if (_newMode == 0) then { // Free
GVAR(camera) cameraEffect ["internal", "back"];
// HUD stuff
@ -11,8 +19,7 @@ if (GVAR(camMode) == 0) then { // Free
} else {
// When no units available to spectate, exit to freecam
if (unitList isEqualTo []) exitWith {
GVAR(camMode) = 0;
call FUNC(updateView);
[0] call FUNC(updateView);
};
// First ensure valid unit is selected
@ -20,7 +27,7 @@ if (GVAR(camMode) == 0) then { // Free
GVAR(camUnit) = GVAR(unitList) select floor(random(count GVAR(unitList)));
};
if (GVAR(camMode) == 1) then { // Internal
if (_newMode == 1) then { // Internal
// Handle gun cam
if (GVAR(gunCam)) then {
GVAR(camUnit) switchCamera "gunner";