-Switched to CBA keybinds.

-Localized keybinds.
-Removed fnc_cameraIntro.sqf; superfluous.
-Various code clean ups.
-Changed: Condition for mission end now checks allUnits (todo: change to allPlayers when available).
This commit is contained in:
voiper 2015-07-04 01:00:27 -07:00
parent d4b5f88a76
commit 981c961ce1
6 changed files with 1809 additions and 500 deletions

View File

@ -18,7 +18,7 @@
if (GVAR(endMission) && isServer) then {
[{
if ({(isPlayer _x) && (alive _x) && !(_x getVariable [QGVAR(isSpectator), false])} count playableUnits == 0) then {
if ({(isPlayer _x) && (alive _x) && !(_x getVariable [QGVAR(isSpectator), false])} count allUnits == 0) then {
[["endDeath", false], "BIS_fnc_endMission"] call BIS_fnc_MP;
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
@ -36,7 +36,7 @@
player addEventHandler ["Killed", {
[player] joinSilent grpNull;
if (isClass (configFile >> "CfgPatches" >> "ace_hearing")) then {EGVAR(hearing,disableVolumeUpdate) = true};
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {EGVAR(hearing,disableVolumeUpdate) = true};
_delay = getNumber (missionConfigFile >> "respawnDelay");
_delay fadeSound 0;
999999 cutText ["", "BLACK", _delay];
@ -44,4 +44,6 @@
player addEventHandler ["Respawn", FUNC(setSpectator)];
}] call EFUNC(common,addEventHandler);
#include "initKeybinds.sqf";
}] call EFUNC(common,addEventHandler);

View File

@ -3,7 +3,6 @@
ADDON = false;
PREP(camera);
PREP(cameraIntro);
PREP(canSpectateUnit);
PREP(checkUnits);
PREP(compass);

View File

@ -8,10 +8,10 @@
Arguments:
0: Mode: "Init" is the only mission relevant one <String>
1: <Array> (optional):
0: Whether player can escape from camera (false for MP spectator; true for SP photography) <Bool>
0: Whether camera is permanent (can't be escaped via escape key) <Bool>
Example:
["Init", [false]] call ace_spectator_fnc_camera;
["Init", [true]] call ace_spectator_fnc_camera;
Return Value:
None
@ -21,9 +21,9 @@
*/
#include "script_component.hpp"
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
disableSerialization;
_mode = _this select 0;
_this = _this select 1;
@ -31,7 +31,11 @@ switch _mode do {
case "Init": {
GVAR(noEscape) = if (count _this > 0) then {_this select 0} else {false};
GVAR(noEscape) = if (count _this > 0) then {
_this select 0
} else {
false
};
_camPos = if (!isNil QGVAR(startingPos)) then {
GVAR(startingPos)
@ -46,7 +50,7 @@ switch _mode do {
};
_camPos set [2, (_camPos select 2) + 2];
_cam = "camera" camCreate _camPos;
_cam = "Camera" camCreate _camPos;
_cam setDir _camDir;
_cam cameraEffect ["internal", "back"];
_cam camSetFocus [-1, -1];
@ -54,10 +58,8 @@ switch _mode do {
showCinemaBorder false;
cameraEffectEnableHUD true;
//variables
//camera vars
GVAR(cam) = _cam;
GVAR(LMB) = false;
GVAR(RMB) = false;
GVAR(vector) = [_camDir, 0, 0];
GVAR(fov) = 0.7;
GVAR(vision) = 0;
@ -67,11 +69,42 @@ switch _mode do {
GVAR(lock) = [-1];
GVAR(attach) = objNull;
GVAR(unit) = objNull;
GVAR(mouseBusy) = false;
GVAR(markers) = 3;
GVAR(accTime) = 1;
GVAR(third) = false;
//mouse vars
GVAR(mouseLeft) = false;
GVAR(mouseRight) = false;
GVAR(mouseBusy) = false;
//kb vars
GVAR(keyCamMoveForward) = false;
GVAR(keyCamMoveBackward) = false;
GVAR(keyCamMoveLeft) = false;
GVAR(keyCamMoveRight) = false;
GVAR(keyCamMoveUp) = false;
GVAR(keyCamMoveDown) = false;
GVAR(keyCamRotDownLeft) = false;
GVAR(keyCamRotDown) = false;
GVAR(keyCamRotDownRight) = false;
GVAR(keyCamRotLeft) = false;
GVAR(keyCamRotRight) = false;
GVAR(keyCamRotUpLeft) = false;
GVAR(keyCamRotUp) = false;
GVAR(keyCamRotUpRight) = false;
GVAR(keyCamBankLeft) = false;
GVAR(keyCamBankRight) = false;
GVAR(keyFOVup) = false;
GVAR(keyFOVdown) = false;
GVAR(keyFocusUp) = false;
GVAR(keyFocusDown) = false;
GVAR(keyTimeAccUp) = false;
GVAR(keyTimeAccDown) = false;
GVAR(keyCamBankMod) = false;
GVAR(keyCamRotMore) = false;
GVAR(keyCamRotLess) = false;
//define only if doesn't exist (to preserve saved spots from a previous camera)
if (isNil QGVAR(savedSpots)) then {
GVAR(savedSpots) = [];
@ -83,24 +116,39 @@ switch _mode do {
for "_i" from 0 to 9 do {GVAR(savedUnits) set [_i, objNull]};
};
GVAR(keys) = [];
_DIKcodes = true call BIS_fnc_keyCode;
_DIKlast = _DIKcodes select (count _DIKcodes - 1);
for "_i" from 0 to (_DIKlast - 1) do {
GVAR(keys) set [_i, false];
};
_display = findDisplay 46;
GVAR(ehDraw3D) = addMissionEventhandler ["Draw3D", {['Draw3D', _this] call FUNC(draw3D)}];
addMissionEventHandler ["Ended", {if (!isNil QGVAR(cam)) then {["Exit"] call FUNC(camera)}}];
GVAR(ehKeyDown) = _display displayAddEventHandler ["keyDown", {['KeyDown', _this] call FUNC(camera)}];
GVAR(ehKeyUp) = _display displayAddEventHandler ["keyUp", {['KeyUp', _this] call FUNC(camera)}];
GVAR(ehMouseButtonDown) = _display displayAddEventHandler ["mouseButtonDown", {['MouseButtonDown', _this] call FUNC(camera)}];
GVAR(ehMouseButtonUp) = _display displayAddEventHandler ["mouseButtonUp", {['MouseButtonUp',_this] call FUNC(camera)}];
GVAR(ehMouseZChanged) = _display displayAddEventHandler ["mouseZChanged", {['MouseZChanged',_this] call FUNC(camera)}];
GVAR(ehMouseMoving) = _display displayAddEventHandler ["mouseMoving", {['Mouse',_this] call FUNC(camera)}];
GVAR(ehMouseHolding) =_display displayAddEventHandler ["mouseHolding", {['Mouse',_this] call FUNC(camera)}];
GVAR(ehKeyDown) = _display displayAddEventHandler ["keyDown", {
_key = _this select 1;
_ret = false;
//block grave/tilde key (there is no default tilde keybind we use to override)
if (_key == 41) then {
_ret = true
};
//escape sequence initiated (CBA can't handle escape)
if (_key == 1) then {
if GVAR(noEscape) exitWith {_ret = false};
//insert excuse for using spawn
_this spawn {
disableSerialization;
_display = _this select 0;
_message = [localize LSTRING(Exit), localize LSTRING(Module_DisplayName), nil, true, _display] call BIS_fnc_guiMessage;
if (_message) then {["Exit"] call FUNC(camera)};
};
_ret = true;
};
_ret
}];
//remove mission layer
_displayMission = call (uiNamespace getVariable "BIS_fnc_displayMission");
@ -133,13 +181,13 @@ switch _mode do {
_layer = [QGVAR(help)] call BIS_fnc_rscLayer;
preloadTitleRsc [QGVAR(help), "PLAIN", 0, true];
if (isClass (configFile >> "CfgPatches" >> "ace_nametags")) then {
if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {
GVAR(tags) = [EGVAR(nametags,showPlayerNames), EGVAR(nametags,showNamesForAI)];
EGVAR(nametags,showPlayerNames) = 0;
EGVAR(nametags,showNamesForAI) = false;
};
if (isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) then {
if (["ace_interact_menu"] call EFUNC(common,isModLoaded)) then {
[QGVAR(interactCondition), {false}] call EFUNC(common,addCanInteractWithCondition);
};
@ -148,7 +196,9 @@ switch _mode do {
[FUNC(checkUnits), 2] call CBA_fnc_addPerFrameHandler
};
[FUNC(cameraIntro), 1] call CBA_fnc_addPerFrameHandler;
//intro
999999 cutText ["", "BLACK IN", 2];
2 fadeSound 1;
};
//////////////////////////////////////////
@ -156,15 +206,15 @@ switch _mode do {
_mapOn = uiNamespace getVariable QGVAR(map);
if (!isNull _mapOn) exitWith {};
_keys = GVAR(keys);
_cam = GVAR(cam);
_dir = GVAR(vector) select 0;
_pitch = GVAR(vector) select 1;
_bank = GVAR(vector) select 2;
_camPos = getPosASL _cam;
_coef = (GVAR(moveScale) * (((getPosATL _cam) select 2) / 2)) min 50 max 0.001;
_coef = GVAR(moveScale * (((getPosATL _cam) select 2) / 2)) min 50 max 0.001;
_move = {
//temporary functions / TODO: Move to external func?
_camMove = {
_inPos = _this;
if !GVAR(cameraOn) exitWith {};
if (_inPos select 2 > 20000) then {_inPos set [2, 20000]};
@ -179,40 +229,7 @@ switch _mode do {
};
};
if (GVAR(LMB) || GVAR(RMB)) then {
if GVAR(mouseBusy) exitWith {};
_mX = (_this select 1) * (GVAR(accTime) max 0.05);
_mY = (_this select 2) * (GVAR(accTime) max 0.05);
if GVAR(RMB) then {
_dX = _mX;
_dY = -_mY;
_camPos = [_camPos, _dY, getDir _cam] call BIS_fnc_relPos;
_camPos = [_camPos, _dX, getDir _cam + 90] call BIS_fnc_relPos;
_camPos call _move;
} else {
if (GVAR(lock) select 0 > -1) exitWith {};
_dX = _mX / 50 * 180 * GVAR(fov);
_dY = -_mY / 50 * 180 * GVAR(fov);
if (_keys select DIK_LSHIFT) then {
_pitch = (_pitch + _dY) max -180 min 180;
_bank = (_bank + _dX) max -181 min 181;
if (_bank <= -181) then {_bank = 180} else {if (_bank >= 181) then {_bank = -180}};
} else {
_dir = _dir + _dX;
_pitch = (_pitch + _dY) max -90 min 90;
};
GVAR(vector) = [_dir, _pitch, _bank];
[_cam, GVAR(vector)] call BIS_fnc_setObjectRotation;
};
};
_camMove = {
_camMoveKeyboard = {
_dX = _this select 0;
_dY = _this select 1;
_dZ = _this select 2;
@ -226,7 +243,13 @@ switch _mode do {
//for some reason, at visual height = 0, cameras report 10cm higher than they actually are
_camPos set [2, (_camPos select 2) max (getTerrainHeightASL _camPos + 0.1)];
_camPos call _move;
_camPos call _camMove;
};
_rotMod = if (GVAR(keyCamRotMore) && !GVAR(keyCamRotLess)) then {
5
} else {
if (!GVAR(keyCamRotMore) && GVAR(keyCamRotLess)) then {0.1} else {1};
};
_camRotate = {
@ -250,51 +273,73 @@ switch _mode do {
[_cam, GVAR(vector)] call BIS_fnc_setObjectRotation;
};
_numPad0 = _keys select DIK_NUMPAD0;
_numPadDel = _keys select DIK_DECIMAL;
_rotMod = if (_numPad0 && !_numPadDel) then {
5
} else {
if (!_numPad0 && _numPadDel) then {0.1} else {1};
//apply mouse
if (GVAR(mouseLeft) || GVAR(mouseRight)) then {
if GVAR(mouseBusy) exitWith {};
_mX = (_this select 1) * (GVAR(accTime) max 0.05);
_mY = (_this select 2) * (GVAR(accTime) max 0.05);
if GVAR(mouseRight) then {
_dX = _mX;
_dY = -_mY;
_camPos = [_camPos, _dY, getDir _cam] call BIS_fnc_relPos;
_camPos = [_camPos, _dX, getDir _cam + 90] call BIS_fnc_relPos;
_camPos call _camMove;
} else {
if (GVAR(lock) select 0 > -1) exitWith {};
_dX = _mX / 50 * 180 * GVAR(fov);
_dY = -_mY / 50 * 180 * GVAR(fov);
if GVAR(keyCamBankMod) then {
_pitch = (_pitch + _dY) max -180 min 180;
_bank = (_bank + _dX) max -181 min 181;
if (_bank <= -181) then {_bank = 180} else {if (_bank >= 181) then {_bank = -180}};
} else {
_dir = _dir + _dX;
_pitch = (_pitch + _dY) max -90 min 90;
};
GVAR(vector) = [_dir, _pitch, _bank];
[_cam, GVAR(vector)] call BIS_fnc_setObjectRotation;
};
};
if (_keys select DIK_W) then {[0,1,0] call _camMove};
if (_keys select DIK_S) then {[0,-1,0] call _camMove};
if (_keys select DIK_A) then {[-1,1,0] call _camMove};
if (_keys select DIK_D) then {[1,1,0] call _camMove};
//apply kb
if GVAR(keyCamMoveForward) then {[0,1,0] call _camMoveKeyboard};
if GVAR(keyCamMoveBackward) then {[0,-1,0] call _camMoveKeyboard};
if GVAR(keyCamMoveLeft) then {[-1,1,0] call _camMoveKeyboard};
if GVAR(keyCamMoveRight) then {[1,1,0] call _camMoveKeyboard};
if GVAR(keyCamMoveUp) then {[0,0,1] call _camMoveKeyboard};
if GVAR(keyCamMoveDown) then {[0,0,-1] call _camMoveKeyboard};
if (_keys select DIK_Q) then {[0,0,1] call _camMove};
if (_keys select DIK_Z) then {[0,0,-1] call _camMove};
if GVAR(keyCamRotDownLeft) then {[-1,-1,0] call _camRotate};
if GVAR(keyCamRotDown) then {[+0,-1,0] call _camRotate};
if GVAR(keyCamRotDownRight) then {[+1,-1,0] call _camRotate};
if GVAR(keyCamRotLeft) then {[-1,+0,0] call _camRotate};
if GVAR(keyCamRotRight) then {[+1,+0,0] call _camRotate};
if GVAR(keyCamRotUpLeft) then {[-1,+1,0] call _camRotate};
if GVAR(keyCamRotUp) then {[+0,+1,0] call _camRotate};
if GVAR(keyCamRotUpRight) then {[+1,+1,0] call _camRotate};
if (_keys select DIK_NUMPAD1) then {[-1,-1,0] call _camRotate};
if (_keys select DIK_NUMPAD2) then {[+0,-1,0] call _camRotate};
if (_keys select DIK_NUMPAD3) then {[+1,-1,0] call _camRotate};
if (_keys select DIK_NUMPAD4) then {[-1,+0,0] call _camRotate};
if (_keys select DIK_NUMPAD6) then {[+1,+0,0] call _camRotate};
if (_keys select DIK_NUMPAD7) then {[-1,+1,0] call _camRotate};
if (_keys select DIK_NUMPAD8) then {[+0,+1,0] call _camRotate};
if (_keys select DIK_NUMPAD9) then {[+1,+1,0] call _camRotate};
if (_keys select DIK_DIVIDE) then {[-1] call _camBank};
if (_keys select DIK_MULTIPLY) then {[+1] call _camBank};
if GVAR(keyCamBankLeft) then {[-1] call _camBank};
if GVAR(keyCamBankRight) then {[+1] call _camBank};
if (_keys select DIK_ADD) then {
if GVAR(keyFOVup) then {
GVAR(fov) = GVAR(fov) - (GVAR(fov) / 50 * _rotMod) max 0.01;
_cam camPrepareFOV GVAR(fov);
_cam camCommitPrepared 0;
};
if (_keys select DIK_SUBTRACT) then {
if GVAR(keyFOVdown) then {
GVAR(fov) = GVAR(fov) + (GVAR(fov) / 50 * _rotMod) min 2;
_cam camPrepareFOV GVAR(fov);
_cam camCommitPrepared 0;
};
if (_keys select DIK_NUMPADENTER) then {
GVAR(fov) = 0.7;
_cam camPrepareFOV GVAR(fov);
_cam camCommitPrepared 0;
};
if (_keys select DIK_MINUS) then {
if GVAR(keyFocusDown) then {
_cur = GVAR(focus) select 0;
if (_cur < 0) then {_cur = 1};
_cur = _cur - (_cur / 25) max 0.25;
@ -303,7 +348,7 @@ switch _mode do {
_cam camCommit 0;
};
if (_keys select DIK_EQUALS) then {
if GVAR(keyFocusUp) then {
_cur = GVAR(focus) select 0;
if (_cur < 0) then {_cur = 1};
_cur = _cur + (_cur / 25) min 5000;
@ -312,7 +357,7 @@ switch _mode do {
_cam camCommit 0;
};
if (_keys select DIK_LBRACKET)then {
if GVAR(keyTimeAccDown) then {
if (!isMultiplayer) then {
_cur = GVAR(accTime);
_cur = _cur - (_cur / 25) max 0;
@ -321,7 +366,7 @@ switch _mode do {
};
};
if (_keys select DIK_RBRACKET)then {
if GVAR(keyTimeAccUp) then {
if (!isMultiplayer) then {
_cur = GVAR(accTime);
_cur = _cur + (_cur / 25) min 4;
@ -337,15 +382,10 @@ switch _mode do {
if (!isNull _mapOn) exitWith {};
_button = _this select 1;
_mX = _this select 2;
_mY = _this select 3;
_shift = _this select 4;
_ctrl = _this select 5;
_alt = _this select 6;
switch (_button) do {
case 0: {GVAR(LMB) = true};
case 1: {GVAR(RMB) = true};
case 0: {GVAR(mouseLeft) = true};
case 1: {GVAR(mouseRight) = true};
};
};
@ -355,9 +395,10 @@ switch _mode do {
if (!isNull _mapOn) exitWith {};
_button = _this select 1;
switch (_button) do {
case 0: {GVAR(LMB) = false};
case 1: {GVAR(RMB) = false};
case 0: {GVAR(mouseLeft) = false};
case 1: {GVAR(mouseRight) = false};
};
};
@ -375,14 +416,10 @@ switch _mode do {
};
//////////////////////////////////////////
case "KeyDown": {
_key = _this select 1;
_shift = _this select 2;
_ctrl = _this select 3;
_alt = _this select 4;
_return = false;
case "CameraSlot": {
GVAR(keys) set [_key, true];
_mode = _this select 0;
_value = _this select 1;
_cam = GVAR(cam);
_camOn = GVAR(cameraOn);
@ -407,7 +444,7 @@ switch _mode do {
_arr = GVAR(savedSpots) select _num;
if (count (_arr) > 0) then {
if (!_camOn) then {
["Camera", ["Free"]] call FUNC(camera)
["CameraMode", ["Free"]] call FUNC(camera)
};
call _detach;
_cam setPos (_arr select 0);
@ -437,21 +474,21 @@ switch _mode do {
_unit = GVAR(savedUnits) select _num;
if (!isNull _unit) then {
if (_lock > -1) then {
["Camera", ["Lock"]] call FUNC(camera)
["CameraMode", ["Lock"]] call FUNC(camera)
};
if (GVAR(unit) == _unit) then {
call _detach;
if (_camOn) then {
["Camera", ["Third"]] call FUNC(camera);
["CameraMode", ["Third"]] call FUNC(camera);
} else {
["Camera", ["SwitchUnit"]] call FUNC(camera);
["CameraMode", ["SwitchUnit"]] call FUNC(camera);
};
} else {
GVAR(unit) = _unit;
if ((GVAR(lock) select 0) > -1) then {["Camera", ["Lock"]] call FUNC(camera)};
if ((GVAR(lock) select 0) > -1) then {["CameraMode", ["Lock"]] call FUNC(camera)};
if (!_camOn) then {
call _detach;
["Camera", ["SwitchUnit"]] call FUNC(camera);
["CameraMode", ["SwitchUnit"]] call FUNC(camera);
};
};
};
@ -459,230 +496,31 @@ switch _mode do {
_detach = {
if (!isNull GVAR(attach)) then {
["Camera", ["Attach"]] call FUNC(camera);
["CameraMode", ["Attach"]] call FUNC(camera);
};
};
switch (_key) do {
case (DIK_F1): {if (_ctrl) then {[0] call _camSaveSpot} else {[0] call _camLoadSpot}; _return = true};
case (DIK_F2): {if (_ctrl) then {[1] call _camSaveSpot} else {[1] call _camLoadSpot}; _return = true};
case (DIK_F3): {if (_ctrl) then {[2] call _camSaveSpot} else {[2] call _camLoadSpot}; _return = true};
case (DIK_F4): {if (_ctrl) then {[3] call _camSaveSpot} else {[3] call _camLoadSpot}; _return = true};
case (DIK_F5): {if (_ctrl) then {[4] call _camSaveSpot} else {[4] call _camLoadSpot}; _return = true};
case (DIK_F6): {if (_ctrl) then {[5] call _camSaveSpot} else {[5] call _camLoadSpot}; _return = true};
case (DIK_F7): {if (_ctrl) then {[6] call _camSaveSpot} else {[6] call _camLoadSpot}; _return = true};
case (DIK_F8): {if (_ctrl) then {[7] call _camSaveSpot} else {[7] call _camLoadSpot}; _return = true};
case (DIK_F9): {if (_ctrl) then {[8] call _camSaveSpot} else {[8] call _camLoadSpot}; _return = true};
case (DIK_F10): {if (_ctrl) then {[9] call _camSaveSpot} else {[9] call _camLoadSpot}; _return = true};
case (DIK_F11): {if (_ctrl) then {[10] call _camSaveSpot} else {[10] call _camLoadSpot}; _return = true};
case (DIK_F12): {if (_ctrl) then {[11] call _camSaveSpot} else {[11] call _camLoadSpot}; _return = true};
case (DIK_1): {if (_ctrl) then {[0] call _camSaveUnit} else {[0] call _camLoadUnit}; _return = true};
case (DIK_2): {if (_ctrl) then {[1] call _camSaveUnit} else {[1] call _camLoadUnit}; _return = true};
case (DIK_3): {if (_ctrl) then {[2] call _camSaveUnit} else {[2] call _camLoadUnit}; _return = true};
case (DIK_4): {if (_ctrl) then {[3] call _camSaveUnit} else {[3] call _camLoadUnit}; _return = true};
case (DIK_5): {if (_ctrl) then {[4] call _camSaveUnit} else {[4] call _camLoadUnit}; _return = true};
case (DIK_6): {if (_ctrl) then {[5] call _camSaveUnit} else {[5] call _camLoadUnit}; _return = true};
case (DIK_7): {if (_ctrl) then {[6] call _camSaveUnit} else {[6] call _camLoadUnit}; _return = true};
case (DIK_8): {if (_ctrl) then {[7] call _camSaveUnit} else {[7] call _camLoadUnit}; _return = true};
case (DIK_9): {if (_ctrl) then {[8] call _camSaveUnit} else {[8] call _camLoadUnit}; _return = true};
case (DIK_0): {if (_ctrl) then {[9] call _camSaveUnit} else {[9] call _camLoadUnit}; _return = true};
case (DIK_NUMPAD5): {
_dir = getDir _cam;
if (!isNull GVAR(attach)) then {_dir = _dir - getDir GVAR(attach)};
GVAR(vector) = [_dir, 0, 0];
[_cam, GVAR(vector)] call BIS_fnc_setObjectRotation;
GVAR(fov) = 0.7;
_cam camPrepareFOV GVAR(fov);
_cam camCommitPrepared 0;
switch _mode do {
case "SaveSpot": {
[_value] call _camSaveSpot
};
case (DIK_NUMPADENTER): {_return = true};
case (DIK_NUMPAD0): {_return = true};
case (DIK_DECIMAL): {_return = true};
case (DIK_BACKSPACE): {
GVAR(focus) = if (!_shift) then {
[-1, 1];
} else {
[-1, -1];
};
_cam camPrepareFocus GVAR(focus);
_cam camCommitPrepared 0;
_return = true;
case "LoadSpot": {
[_value] call _camLoadSpot
};
case (DIK_BACKSLASH): {
if (!isMultiplayer) then {
GVAR(accTime) = 1;
setAccTime GVAR(accTime);
};
case "SaveUnit": {
[_value] call _camSaveUnit
};
case (DIK_GRAVE): {_return = true};
case (DIK_SPACE): {
if (!_camOn) exitWith {};
if (_ctrl) then {
["Camera", ["Attach"]] call FUNC(camera);
} else {
["Camera", ["Lock"]] call FUNC(camera);
};
case "LoadUnit": {
[_value] call _camLoadUnit
};
case (DIK_LEFT): {
["Camera", ["NewUnit", -1]] call FUNC(camera)
};
case (DIK_RIGHT): {
["Camera", ["NewUnit", 1]] call FUNC(camera)
};
case (DIK_UP): {
if (isNull GVAR(unit)) exitWith {};
if (_lock > -1) then {["Camera", ["Lock"]] call FUNC(camera)};
call _detach;
if (_camOn) then {
["Camera", ["Third"]] call FUNC(camera);
} else {
if GVAR(third) then {
["Camera", ["First"]] call FUNC(camera);
};
};
};
case (DIK_DOWN): {
if (isNull GVAR(unit)) exitWith {};
if (_lock > -1) then {["Camera", ["Lock"]] call FUNC(camera)};
call _detach;
if (!_camOn) then {
if !GVAR(third) then {
["Camera", ["Third"]] call FUNC(camera);
} else {
["Camera", ["Free"]] call FUNC(camera);
};
};
};
case (DIK_T): {
GVAR(markers) = GVAR(markers) + 1;
if (GVAR(markers) > 3) then {GVAR(markers) = 0};
if (GVAR(markers) == 0) then {clearRadio};
};
case (DIK_U): {
_map = uiNameSpace getVariable [QGVAR(map), findDisplay 12202];
if (!isNull _map) exitWith {};
_overlay = uiNamespace getVariable [QGVAR(overlay), findDisplay 12200];
if (isNull _overlay) then {
createDialog QGVAR(overlay);
} else {
closeDialog 0;
};
};
case (DIK_X): {
_layer = [QGVAR(crosshair)] call BIS_fnc_rscLayer;
_xhair = uiNamespace getVariable QGVAR(crosshair);
if (isNull _xhair) then {
_layer cutRsc [QGVAR(crosshair), "PLAIN", 0, true];
call FUNC(crosshair);
} else {
_layer cutText ["", "PLAIN"];
};
};
case (DIK_C): {
_layer = [QGVAR(compass)] call BIS_fnc_rscLayer;
if (isNull (uiNamespace getVariable QGVAR(compass))) then {
_layer cutRsc [QGVAR(compass), "PLAIN", 0, true];
} else {
_layer cutText ["", "PLAIN"];
};
_layer = [QGVAR(status)] call BIS_fnc_rscLayer;
if (isNull (uiNamespace getVariable QGVAR(status))) then {
_layer cutRsc [QGVAR(status), "PLAIN", 0, true];
} else {
_layer cutText ["", "PLAIN"];
};
};
case (DIK_H): {
_layer = [QGVAR(help)] call BIS_fnc_rscLayer;
if (isNull (uiNamespace getVariable QGVAR(help))) then {
_layer cutRsc [QGVAR(help), "PLAIN", 0, true];
} else {
_layer cutText ["", "PLAIN"];
};
};
case (DIK_M): {
_map = uiNameSpace getVariable [QGVAR(map), findDisplay 12202];
if (isNull _map) then {
createDialog QGVAR(map);
} else {
closeDialog 0;
};
};
case (DIK_N): {
GVAR(vision) = GVAR(vision) + 1;
if (GVAR(vision) > 4) then {GVAR(vision) = 0};
switch GVAR(vision) do {
case 0: {
camUseNVG false;
false SetCamUseTi 0;
};
case 1: {
camUseNVG true;
false SetCamUseTi 0;
};
case 2: {
camUseNVG false;
true SetCamUseTi 0;
};
case 3: {
camUseNVG false;
true SetCamUseTi 1;
};
case 4: {
camUseNVG false;
true SetCamUseTi 4;
};
};
};
case (DIK_ESCAPE): {
if !GVAR(noEscape) then {
_return = true;
_this spawn {
disableSerialization;
_display = _this select 0;
_message = ["Do you want to exit spectator?", "ACE Spectator", nil, true, _display] call BIS_fnc_guiMessage;
if (_message) then {["Exit"] call FUNC(camera)};
};
};
};
default {};
};
_return
};
//////////////////////////////////////////
case "KeyUp": {
GVAR(keys) set [_this select 1, false];
};
//////////////////////////////////////////
case "Camera": {
case "CameraMode": {
_mode = _this select 0;
@ -690,9 +528,9 @@ switch _mode do {
_camOn = GVAR(cameraOn);
_unit = GVAR(unit);
_lock = GVAR(lock) select 0;
_camPos = [getPos _cam, GVAR(vector), GVAR(fov), GVAR(focus)];
_findTarget = {
_ret = [];
_screenPos = screenToWorld [0.5,0.5];
_camPosASL = getPosASL _cam;
@ -791,21 +629,20 @@ switch _mode do {
if (_index > (_count - 1)) then {_index = 0};
GVAR(unit) = _units select _index;
if (!_camOn) then {["Camera", ["SwitchUnit"]] call FUNC(camera)};
if (!_camOn) then {["CameraMode", ["SwitchUnit"]] call FUNC(camera)};
};
};
case "SwitchUnit": {
if !GVAR(third) then {
["Camera", ["First"]] call FUNC(camera);
["CameraMode", ["First"]] call FUNC(camera);
} else {
["Camera", ["Third"]] call FUNC(camera);
["CameraMode", ["Third"]] call FUNC(camera);
};
};
case "Lock": {
if (_lock < 0) then {
_target = call _findTarget;
if (typeName _target == "OBJECT") then {
@ -820,13 +657,12 @@ switch _mode do {
_cam camCommitPrepared 0;
call FUNC(crosshair);
} else {
_dir = getDir _cam;
_pitchBank = _cam call BIS_fnc_getPitchBank;
GVAR(lock) = [-1];
_cam cameraEffect ["Terminate", "Back"];
camDestroy _cam;
_cam = "camera" camCreate (_camPos select 0);
_cam = "Camera" camCreate (_camPos select 0);
[_cam, _camPos select 1] call BIS_fnc_setObjectRotation;
_cam camPrepareFOV (_camPos select 2);
_cam camPrepareFocus GVAR(focus);
@ -872,145 +708,20 @@ switch _mode do {
call FUNC(crosshair);
};
//////////////////////////////////////////
case "Help": {
_dialog = _this;
_c1Action = parseText "<t align='left'>
<t underline='true'>Camera:</t><br />
<br />
Move<br />
Pitch, Yaw<br />
Roll<br />
Slide<br />
Speed Multiplier<br />
Camera Mode<br />
Track Pos or Object<br />
Lock to Object<br />
Save Pos<br />
Recall Pos<br />
Optic Mode<br />
Focus<br />
Autofocus<br />
Disable Focus<br />
Pitch and Yaw<br />
Roll<br />
Pitch/Roll Reset<br />
Zoom<br />
Reset Zoom<br />
Pitch/Yaw/Roll/Zoom Fast<br />
Pitch/Yaw/Roll/Zoom Slow<br />
</t>
";
_c1Control = parseText "<t align='left'>
<br />
<br />
W, A, S, D<br />
LMB + Mouse<br />
Shift + LMB + Mouse<br />
RMB + Mouse<br />
MouseWheel Up, Down<br />
Arrow Up, Down<br />
Space<br />
Ctrl + Space<br />
Ctrl + F1...F12<br />
F1...F12<br />
N<br />
Keyboard - and +<br />
Backspace<br />
Shift + Backspace<br />
Numpad 1...9<br />
Numpad / and *<br />
Numpad 5<br />
Numpad - and +<br />
Numpad Enter<br />
Numpad 0<br />
Numpad Decimal<br />
</t>
";
_c2Action = parseText "<t align='left'>
<t underline='true'>Units:</t><br />
<br />
Cycle Unit<br />
Save Unit<br />
Recall Unit<br />
Unit List<br />
<br />
<t underline='true'>Display:</t><br />
<br />
Toggle Crosshair<br />
Toggle Status Bar<br />
View Distance Dialog<br />
Cycle Marker Mode<br />
Toggle Help<br />
</t>
";
_c2Control = parseText "<t align='left'>
<br />
<br />
Arrow Left, Right<br />
Ctrl + 1...10<br />
1...10<br />
U<br />
<br />
<br />
<br />
X<br />
C<br />
G<br />
T<br />
H<br />
</t>
";
if (!isMultiplayer) then {
_add1 = parseText "<t align='left'>
<br />
<t underline='true'>Time:</t><br />
<br />
Faster, Slower<br />
Reset
</t>
";
_add2 = parseText "<t align='left'>
<br />
<br />
<br />
[ and ]<br />
\<br />
</t>
";
_c2Action = composeText [_c2Action, _add1];
_c2Control = composeText [_c2Control, _add2];
};
(_dialog displayCtrl 1) ctrlSetStructuredText _c1Action;
(_dialog displayCtrl 2) ctrlSetStructuredText _c1Control;
(_dialog displayCtrl 3) ctrlSetStructuredText _c2Action;
(_dialog displayCtrl 4) ctrlSetStructuredText _c2Control;
};
//////////////////////////////////////////
case "Exit": {
if (isClass (configFile >> "CfgPatches" >> "ace_nametags")) then {
if (["ace_nametags"] call EFUNC(common,isModLoaded)) then {
EGVAR(nametags,showPlayerNames) = GVAR(tags) select 0;
EGVAR(nametags,showNamesForAI) = GVAR(tags) select 1;
GVAR(tags) = nil;
};
if (isClass (configFile >> "CfgPatches" >> "ace_hearing")) then {
if (["ace_hearing"] call EFUNC(common,isModLoaded)) then {
EGVAR(hearing,disableVolumeUpdate) = false;
};
if (isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) then {
if (["ace_interact_menu"] call EFUNC(common,isModLoaded)) then {
[QGVAR(interactCondition)] call EFUNC(common,removeCanInteractWithCondition);
};
@ -1020,10 +731,9 @@ _add2 = parseText "<t align='left'>
camDestroy GVAR(cam);
clearRadio;
//camera vars
GVAR(noEscape) = nil;
GVAR(cam) = nil;
GVAR(LMB) = nil;
GVAR(RMB) = nil;
GVAR(vector) = nil;
GVAR(fov) = nil;
GVAR(vision) = nil;
@ -1033,24 +743,51 @@ _add2 = parseText "<t align='left'>
GVAR(lock) = nil;
GVAR(attach) = nil;
GVAR(unit) = nil;
GVAR(mouseBusy) = nil;
GVAR(markers) = nil;
GVAR(keys) = nil;
GVAR(accTime) = nil;
//mouse vars
GVAR(mouseLeft) = nil;
GVAR(mouseRight) = nil;
GVAR(mouseBusy) = nil;
//kb vars
GVAR(keyCamMoveForward) = nil;
GVAR(keyCamMoveBackward) = nil;
GVAR(keyCamMoveLeft) = nil;
GVAR(keyCamMoveRight) = nil;
GVAR(keyCamMoveUp) = nil;
GVAR(keyCamMoveDown) = nil;
GVAR(keyCamRotDownLeft) = nil;
GVAR(keyCamRotDown) = nil;
GVAR(keyCamRotDownRight) = nil;
GVAR(keyCamRotLeft) = nil;
GVAR(keyCamRotRight) = nil;
GVAR(keyCamRotUpLeft) = nil;
GVAR(keyCamRotUp) = nil;
GVAR(keyCamRotUpRight) = nil;
GVAR(keyCamBankLeft) = nil;
GVAR(keyCamBankRight) = nil;
GVAR(keyFOVup) = nil;
GVAR(keyFOVdown) = nil;
GVAR(keyFocusUp) = nil;
GVAR(keyFocusDown) = nil;
GVAR(keyTimeAccUp) = nil;
GVAR(keyTimeAccDown) = nil;
GVAR(keyCamBankMod) = nil;
GVAR(keyCamRotMore) = nil;
GVAR(keyCamRotLess) = nil;
_display = findDisplay 46;
removeMissionEventHandler ["Draw3D", GVAR(ehDraw3D)];
_display displayRemoveEventHandler ["keyDown", GVAR(ehKeyDown)];
_display displayRemoveEventHandler ["keyUp", GVAR(ehKeyUp)];
_display displayRemoveEventHandler ["mouseButtonDown", GVAR(ehMouseButtonDown)];
_display displayRemoveEventHandler ["mouseButtonUp", GVAR(ehMouseButtonUp)];
_display displayRemoveEventHandler ["mouseZChanged", GVAR(ehMouseZChanged)];
_display displayRemoveEventHandler ["mouseMoving", GVAR(ehMouseMoving)];
_display displayRemoveEventHandler ["mouseHolding", GVAR(ehMouseHolding)];
GVAR(ehDraw3D) = nil;
GVAR(ehKeyDown) = nil;
GVAR(ehKeyUp) = nil;
GVAR(ehMouseButtonDown) = nil;
GVAR(ehMouseButtonUp) = nil;
GVAR(ehMouseZChanged) = nil;
@ -1066,4 +803,4 @@ _add2 = parseText "<t align='left'>
if (!isMultiplayer) then {setAccTime 1};
ACE_player switchCamera "Internal";
};
};
};

View File

@ -1,28 +0,0 @@
/*
Author:
voiper
Description:
Curtain, sound, and text intro when camera starts.
Arguments:
None
Example:
call ace_spectator_fnc_camIntro;
Return Value:
None
Public:
No
*/
#include "script_component.hpp"
999999 cutText ["", "BLACK IN", 2];
2 fadeSound 1;
["Press H for spectator controls", 2] call EFUNC(common,displaytextstructured);
[_this select 1] call CBA_fnc_removePerFrameHandler;

File diff suppressed because it is too large Load Diff

View File

@ -40,5 +40,271 @@
<Key ID="STR_ACE_Spectator_End_Description">
<English>End mission when all players dead (default BIS behaviour)?</English>
</Key>
<Key ID="STR_ACE_Spectator_Exit">
<English>Are you sure you want to exit camera mode?</English>
</Key>
<!-- Keybinds -->
<Key ID="STR_ACE_Spectator_keyCamMoveForward">
<English>Move Camera Forward</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamMoveBackward">
<English>Move Camera Backward</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamMoveLeft">
<English>Move Camera Left</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamMoveRight">
<English>Move Camera Right</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamMoveUp">
<English>Move Camera Up</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamMoveDown">
<English>Move Camera Down</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotUp">
<English>Angle Camera Up</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotDown">
<English>Angle Camera Down</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotLeft">
<English>Angle Camera Left</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotRight">
<English>Angle Camera Right</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotUpLeft">
<English>Angle Camera Up + Left</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotUpRight">
<English>Angle Camera Up + Right</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotDownLeft">
<English>Angle Camera Down + Left</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotDownRight">
<English>Angle Camera Down + Right</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamBankLeft">
<English>Bank Camera Left</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamBankRight">
<English>Bank Camera Right</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotMore">
<English>Angle/Bank Camera Faster (keyboard only)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamRotLess">
<English>Angle/Bank Camera Slower (keyboard only)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamBankMod">
<English>Bank Camera Modifier (with mouse)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamReset">
<English>Reset Camera Angle</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamLock">
<English>Follow Target or Position</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCamAttach">
<English>Attach Camera to Object</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot1">
<English>Save Position #1</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot2">
<English>Save Position #2</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot3">
<English>Save Position #3</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot4">
<English>Save Position #4</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot5">
<English>Save Position #5</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot6">
<English>Save Position #6</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot7">
<English>Save Position #7</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot8">
<English>Save Position #8</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot9">
<English>Save Position #9</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot10">
<English>Save Position #10</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot11">
<English>Save Position #11</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveSpot12">
<English>Save Position #12</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot1">
<English>Restore Position #1</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot2">
<English>Restore Position #2</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot3">
<English>Restore Position #3</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot4">
<English>Restore Position #4</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot5">
<English>Restore Position #5</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot6">
<English>Restore Position #6</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot7">
<English>Restore Position #7</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot8">
<English>Restore Position #8</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot9">
<English>Restore Position #9</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot10">
<English>Restore Position #10</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot11">
<English>Restore Position #11</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadSpot12">
<English>Restore Position #12</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit1">
<English>Save Unit #1</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit2">
<English>Save Unit #2</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit3">
<English>Save Unit #3</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit4">
<English>Save Unit #4</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit5">
<English>Save Unit #5</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit6">
<English>Save Unit #6</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit7">
<English>Save Unit #7</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit8">
<English>Save Unit #8</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit9">
<English>Save Unit #9</English>
</Key>
<Key ID="STR_ACE_Spectator_keySaveUnit10">
<English>Save Unit #10</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit1">
<English>Restore Unit #1</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit2">
<English>Restore Unit #2</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit3">
<English>Restore Unit #3</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit4">
<English>Restore Unit #4</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit5">
<English>Restore Unit #5</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit6">
<English>Restore Unit #6</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit7">
<English>Restore Unit #7</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit8">
<English>Restore Unit #8</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit9">
<English>Restore Unit #9</English>
</Key>
<Key ID="STR_ACE_Spectator_keyLoadUnit10">
<English>Restore Unit #10</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFOVup">
<English>Increase FOV</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFOVdown">
<English>Decrease FOV</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFOVreset">
<English>Reset FOV</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFocusUp">
<English>Increase Focal Distance (PP must be enabled)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFocusDown">
<English>Decrease Focal Distance (PP must be enabled)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFocusReset">
<English>Reset Focal Distance (PP must be enabled)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyFocusInfinite">
<English>Disable Focus</English>
</Key>
<Key ID="STR_ACE_Spectator_keyTimeAccUp">
<English>Increase Time Acceleration (SP only)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyTimeAccDown">
<English>Decrease Time Acceleration (SP only)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyTimeAccReset">
<English>Reset Time Acceleration (SP only)</English>
</Key>
<Key ID="STR_ACE_Spectator_keyToggleMarkers">
<English>Toggle 2D/3D Marker Mode</English>
</Key>
<Key ID="STR_ACE_Spectator_keyUnitList">
<English>Toggle Unit List</English>
</Key>
<Key ID="STR_ACE_Spectator_keyCrosshair">
<English>Toggle Crosshair</English>
</Key>
<Key ID="STR_ACE_Spectator_keyStatus">
<English>Toggle Status Overlay</English>
</Key>
<Key ID="STR_ACE_Spectator_keyMap">
<English>Toggle Map</English>
</Key>
<Key ID="STR_ACE_Spectator_keyVision">
<English>Toggle Vision Mode</English>
</Key>
<Key ID="STR_ACE_Spectator_keyUnitNext">
<English>Switch to Next Unit</English>
</Key>
<Key ID="STR_ACE_Spectator_keyUnitPrevious">
<English>Switch to Previous Unit</English>
</Key>
<Key ID="STR_ACE_Spectator_keyPOVup">
<English>Unit POV In</English>
</Key>
<Key ID="STR_ACE_Spectator_keyPOVdown">
<English>Unit POV Out</English>
</Key>
<Key ID="STR_ACE_Spectator_keyExit">
<English>Exit Camera Key (mission dependent)</English>
</Key>
</Package>
</Project>