2017-08-12 13:25:48 +00:00
|
|
|
/*
|
|
|
|
* Author: Nelson Duarte, AACO, SilentSpike
|
|
|
|
* Function used to handle mouse down event
|
|
|
|
*
|
|
|
|
* Expected behaviour:
|
|
|
|
* Left clicking a unit focuses the camera on that unit (in any camera mode)
|
|
|
|
* Left clicking empty space removes the current camera focus in free camera
|
|
|
|
* Right clicking removes the camera lock, but retains the focus in free camera
|
|
|
|
* Right clicking and dragging orbits around the unit in follow camera
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Control <CONTROL>
|
|
|
|
* 1: Mouse button pressed <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* _this call ace_spectator_fnc_ui_handleMouseButtonDown
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
|
|
|
params ["", "_button"];
|
|
|
|
|
|
|
|
// Left click
|
|
|
|
if (_button == 0) exitWith {
|
|
|
|
if (isNull GVAR(cursorObject)) then {
|
2017-08-30 15:36:53 +00:00
|
|
|
if (GVAR(camMode) == MODE_FREE && { !isNull GVAR(camFocus) }) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
playSound "ReadoutHideClick1";
|
|
|
|
[objNull] call FUNC(setFocus);
|
|
|
|
};
|
|
|
|
} else {
|
2017-08-30 10:40:12 +00:00
|
|
|
if (GVAR(cursorObject) in ([] call FUNC(getTargetEntities))) then {
|
|
|
|
playSound "ReadoutClick";
|
2017-08-12 13:25:48 +00:00
|
|
|
|
2017-08-30 10:40:12 +00:00
|
|
|
// Focus will be at screen center
|
|
|
|
[GVAR(cursorObject)] call FUNC(setFocus);
|
|
|
|
setMousePosition [0.5, 0.5];
|
|
|
|
};
|
2017-08-12 13:25:48 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// Right click
|
|
|
|
if (_button == 1) then {
|
2017-08-30 15:36:53 +00:00
|
|
|
if (GVAR(camMode) == MODE_FREE && { !isNull GVAR(camFocus) } && { !isNull (attachedTo GVAR(camDummy)) }) then {
|
2017-08-12 13:25:48 +00:00
|
|
|
[] call FUNC(cam_resetTarget);
|
|
|
|
};
|
|
|
|
GVAR(holdingRMB) = true;
|
|
|
|
};
|