ACE3/addons/spectator/functions/fnc_handleMouse.sqf

47 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2015-07-17 15:45:16 +00:00
/*
* Author: F3 Project, Head, SilentSpike
* Processes the change in mouse position for the spectator camera
*
* Arguments:
2015-07-21 12:31:00 +00:00
* 0: Mouse x coord <NUMBER>
* 1: Mouse y coord <NUMBER>
2015-07-17 15:45:16 +00:00
*
* Return Value:
* None <NIL>
*
* Example:
2015-07-21 12:31:00 +00:00
* [0.5, 0.5] call ace_spectator_fnc_handleMouse;
2015-07-17 15:45:16 +00:00
*
* Public: No
*/
2015-07-15 11:11:19 +00:00
#include "script_component.hpp"
2015-07-18 15:59:05 +00:00
params ["_x","_y"];
private ["_leftButton","_rightButton","_oldX","_oldY","_deltaX","_deltaY","_zoomMod"];
2015-07-15 11:11:19 +00:00
_leftButton = GVAR(mouse) select 0;
_rightButton = GVAR(mouse) select 1;
2015-07-18 15:59:05 +00:00
_oldX = GVAR(mousePos) select 0;
_oldY = GVAR(mousePos) select 1;
2015-07-15 11:11:19 +00:00
// Get change in pos
_deltaX = _oldX - _x;
_deltaY = _oldY - _y;
2015-07-21 17:44:24 +00:00
if (_leftButton) then {
2015-07-21 18:36:20 +00:00
GVAR(camDolly) set [0, _deltaX * -100 * GVAR(camSpeed)];
GVAR(camDolly) set [1, _deltaY * 100 * GVAR(camSpeed)];
2015-07-21 17:05:29 +00:00
} else {
if (_rightButton) then {
// Pan/Tilt amount should be influnced by zoom level (it should really be exponential)
_zoomMod = (GVAR(camZoom) * 0.8) max 1;
GVAR(camPan) = GVAR(camPan) - ((_deltaX * 360) / _zoomMod);
GVAR(camTilt) = ((GVAR(camTilt) + ((_deltaY * 180) / _zoomMod)) min 89) max -89;
2015-07-21 17:05:29 +00:00
};
2015-07-15 11:11:19 +00:00
};
2015-07-18 15:59:05 +00:00
GVAR(mousePos) = [_x,_y];