2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-15 09:51:18 +00:00
|
|
|
/*
|
2024-01-07 18:02:05 +00:00
|
|
|
* Author: esteldunedain, LorenLuke
|
|
|
|
* Handle mouse movement over the map tool and plotting board.
|
2015-01-15 09:51:18 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2024-01-07 18:02:05 +00:00
|
|
|
* 0: Map control <CONTROL>
|
2017-06-08 13:31:51 +00:00
|
|
|
* 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:
|
2024-01-07 18:02:05 +00:00
|
|
|
* If the event was handled <BOOL>
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-01-07 18:02:05 +00:00
|
|
|
* [CONTROL, [0, 5]] call ace_maptools_fnc_handleMouseMove
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-15 09:51:18 +00:00
|
|
|
*/
|
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
params ["_mapCtrl", "_mousePosX", "_mousePosY"];
|
|
|
|
TRACE_3("params",_mapCtrl,_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
|
2024-01-07 18:02:05 +00:00
|
|
|
if (isNull ACE_player || {
|
|
|
|
private _uniqueItems = ACE_player call EFUNC(common,uniqueItems);
|
|
|
|
|
|
|
|
!(("ACE_MapTools" in _uniqueItems) || {"ACE_PlottingBoard" in _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
|
2024-01-07 18:02:05 +00:00
|
|
|
if (GVAR(mapTool_Shown) == 0 && {GVAR(plottingBoard_Shown) == 0}) exitWith {false};
|
2015-01-15 09:51:18 +00:00
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
private _mousePosition = _mapCtrl ctrlMapScreenToWorld [_mousePosX, _mousePosY];
|
2016-06-02 19:36:25 +00:00
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
// Map tools - translation
|
2015-01-15 21:50:48 +00:00
|
|
|
if (GVAR(mapTool_isDragging)) exitWith {
|
2024-01-07 18:02:05 +00:00
|
|
|
GVAR(mapTool_pos) = GVAR(mapTool_startPos) vectorAdd _mousePosition vectorDiff GVAR(mapTool_startDragPos);
|
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
|
|
|
};
|
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
// Map tools - 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
|
2024-01-07 18:02:05 +00:00
|
|
|
private _pos = _mousePosition vectorDiff GVAR(mapTool_startPos);
|
|
|
|
private _angle = (_pos select 0) atan2 (_pos select 1);
|
|
|
|
|
|
|
|
GVAR(mapTool_angle) = ((GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle)) % 360 + 360) % 360;
|
|
|
|
|
|
|
|
true
|
|
|
|
};
|
|
|
|
|
|
|
|
// Plotting board - translation
|
|
|
|
if (GVAR(plottingBoard_isDragging)) exitWith {
|
|
|
|
GVAR(plottingBoard_pos) = GVAR(plottingBoard_startPos) vectorAdd _mousePosition vectorDiff GVAR(plottingBoard_startDragPos);
|
|
|
|
|
|
|
|
true
|
|
|
|
};
|
|
|
|
|
|
|
|
// Plotting board - rotation
|
|
|
|
if (GVAR(plottingBoard_isRotating) > -1) exitWith {
|
|
|
|
// Get new angle
|
|
|
|
private _pos = _mousePosition vectorDiff GVAR(plottingBoard_startPos);
|
|
|
|
private _angle = (_pos select 0) atan2 (_pos select 1);
|
|
|
|
private _returnAngle = ((GVAR(plottingBoard_startAngle) + _angle - GVAR(plottingBoard_startDragAngle)) % 360 + 360) % 360;
|
|
|
|
|
|
|
|
switch (GVAR(plottingBoard_isRotating)) do {
|
|
|
|
case 0: {GVAR(plottingBoard_angle) = _returnAngle};
|
|
|
|
case 1: {GVAR(plottingBoard_acrylicAngle) = _returnAngle};
|
|
|
|
case 2: {GVAR(plottingBoard_rulerAngle) = _returnAngle};
|
|
|
|
};
|
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
|