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.
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* 0: Map Control
|
|
|
|
* 1: Mouse position on screen coordinates
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* 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
|
|
|
|
2015-01-15 09:51:18 +00:00
|
|
|
private ["_control", "_pos"];
|
|
|
|
|
2015-08-18 02:51:40 +00:00
|
|
|
GVAR(mousePosition) = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY];
|
2015-01-15 09:51:18 +00:00
|
|
|
GVAR(mousePosition) set [2, 0]; //convert 2d pos to 3d
|
|
|
|
|
|
|
|
// If cannot draw then exit
|
|
|
|
if !(call FUNC(canDraw)) exitWith {
|
2015-04-07 20:01:44 +00:00
|
|
|
// If was drawing, cancel
|
|
|
|
if (GVAR(drawing_isDrawing)) then {
|
|
|
|
call FUNC(cancelDrawing);
|
|
|
|
};
|
|
|
|
false
|
2015-01-15 09:51:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Handle drawing
|
2015-01-15 21:50:48 +00:00
|
|
|
if (GVAR(drawing_isDrawing)) exitWith {
|
2015-04-07 20:01:44 +00:00
|
|
|
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
|
2015-08-18 21:57:56 +00:00
|
|
|
TRACE_1("updating line pos",GVAR(mousePosition));
|
2015-04-07 20:01:44 +00:00
|
|
|
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
|
|
|
|
false
|
2015-01-15 09:51:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Handle Map tools
|
2015-04-07 19:38:35 +00:00
|
|
|
if (GVAR(mapTool_Shown) == 0) exitWith {false};
|
2015-01-15 09:51:18 +00:00
|
|
|
|
|
|
|
// Translation
|
2015-01-15 21:50:48 +00:00
|
|
|
if (GVAR(mapTool_isDragging)) exitWith {
|
2015-04-07 20:01:44 +00:00
|
|
|
GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (GVAR(mousePosition) select 0) - (GVAR(mapTool_startDragPos) select 0)];
|
|
|
|
GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (GVAR(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-17 23:13:09 +00:00
|
|
|
private "_angle";
|
2015-04-07 20:01:44 +00:00
|
|
|
// Get new angle
|
|
|
|
_angle = (180 + ((GVAR(mousePosition) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mousePosition) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
|
|
|
|
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
|