2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
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:
|
2017-06-08 13:31:51 +00:00
|
|
|
* 0: Map Control <CONTROL>
|
|
|
|
* 1: Mouse position on screen coordinates <ARRAY>
|
2015-01-15 09:51:18 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* true if event was handled <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [CONTROL, [0, 5, 1]] call ACE_maptools_fnc_handleMouseMove
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-15 09:51:18 +00:00
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2016-06-02 19:36:25 +00:00
|
|
|
// If have no map tools, then exit
|
2018-09-17 19:03:28 +00:00
|
|
|
if (((isNull ACE_player) || {!("ACE_MapTools" in (ACE_player call EFUNC(common,uniqueItems)))})) exitWith {
|
2015-04-07 20:01:44 +00:00
|
|
|
false
|
2015-01-15 09:51:18 +00:00
|
|
|
};
|
|
|
|
|
2016-06-02 19:36:25 +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
|
|
|
|
2016-06-02 19:36:25 +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 {
|
2016-06-02 19:36:25 +00:00
|
|
|
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
|
2016-06-02 19:36:25 +00:00
|
|
|
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
|