ACE3/addons/maptools/functions/fnc_handleMouseMove.sqf

46 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-01-15 09:51:18 +00:00
/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain
2015-01-15 09:51:18 +00:00
* Handle mouse movement over the map tool.
*
2016-06-18 09:50:41 +00:00
* Arguments:
2015-01-15 09:51:18 +00:00
* 0: Map Control
* 1: Mouse position on screen coordinates
*
2016-06-18 09:50:41 +00:00
* Return Value:
2015-01-15 09:51:18 +00:00
* Boolean, true if event was handled
*/
2015-01-15 21:50:48 +00:00
#include "script_component.hpp"
2015-08-18 02:51:40 +00:00
params ["_control", "_mousePosX", "_mousePosY"];
2015-08-18 21:57:56 +00:00
TRACE_3("params",_control,_mousePosX,_mousePosY);
2015-08-18 02:51:40 +00:00
// If have no map tools, then exit
if (((isNull ACE_player) || {!("ACE_MapTools" in items ACE_player)})) exitWith {
2015-04-07 20:01:44 +00:00
false
2015-01-15 09:51:18 +00:00
};
// If map tools not shown, then exit
2015-04-07 19:38:35 +00:00
if (GVAR(mapTool_Shown) == 0) exitWith {false};
2015-01-15 09:51:18 +00:00
private _mousePosition = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY];
2015-01-15 09:51:18 +00:00
// Translation
2015-01-15 21:50:48 +00:00
if (GVAR(mapTool_isDragging)) exitWith {
GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (_mousePosition select 0) - (GVAR(mapTool_startDragPos) select 0)];
GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (_mousePosition select 1) - (GVAR(mapTool_startDragPos) select 1)];
2015-01-15 09:51:18 +00:00
2015-04-07 20:01:44 +00:00
true
2015-01-15 09:51:18 +00:00
};
// Rotation
2015-01-15 21:50:48 +00:00
if (GVAR(mapTool_isRotating)) exitWith {
2015-04-07 20:01:44 +00:00
// Get new angle
private _angle = (180 + ((_mousePosition select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((_mousePosition select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
2015-04-07 20:01:44 +00:00
GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle);
2015-01-15 09:51:18 +00:00
2015-04-07 20:01:44 +00:00
true
2015-01-15 09:51:18 +00:00
};
false