ACE3/addons/maptools/functions/fnc_handleMouseMove.sqf

64 lines
1.7 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.
*
* 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-01-15 09:51:18 +00:00
private ["_control", "_pos"];
_control = _this select 0;
_pos = [_this select 1, _this select 2];
GVAR(mousePosition) = _control ctrlMapScreenToWorld _pos;
GVAR(mousePosition) set [2, 0]; //convert 2d pos to 3d
// If cannot draw then exit
if !(call FUNC(canDraw)) exitWith {
// If was drawing, cancel
2015-01-15 21:50:48 +00:00
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
2015-01-15 09:51:18 +00:00
};
false
};
// Handle drawing
2015-01-15 21:50:48 +00:00
if (GVAR(drawing_isDrawing)) exitWith {
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
2015-01-15 09:51:18 +00:00
false
};
// Handle Map tools
2015-01-15 21:50:48 +00:00
if (isNil QGVAR(mapTool_markerRotatingFixed)) exitWith {false};
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) + (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
// Update the size and rotation of the maptool
2015-01-15 21:50:48 +00:00
[] call FUNC(updateMapToolMarkers);
2015-01-15 09:51:18 +00:00
true
};
// Rotation
2015-01-15 21:50:48 +00:00
if (GVAR(mapTool_isRotating)) exitWith {
2015-01-15 09:51:18 +00:00
// Get new angle
2015-01-15 21:50:48 +00:00
_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
// Update the size and rotation of the maptool
2015-01-15 21:50:48 +00:00
[] call FUNC(updateMapToolMarkers);
2015-01-15 09:51:18 +00:00
true
};
false