ACE3/addons/maptools/functions/fnc_handleMouseMove.sqf

64 lines
1.8 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 {
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)];
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
// Update the size and rotation of the maptool
[] call FUNC(updateMapToolMarkers);
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
_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
// Update the size and rotation of the maptool
[] call FUNC(updateMapToolMarkers);
true
2015-01-15 09:51:18 +00:00
};
false