ACE3/addons/maptools/functions/fnc_handleMouseMove.sqf

78 lines
2.3 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-01-15 09:51:18 +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:
* 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:
* If the event was handled <BOOL>
*
* Example:
* [CONTROL, [0, 5]] call ace_maptools_fnc_handleMouseMove
*
* Public: No
2015-01-15 09:51:18 +00:00
*/
params ["_mapCtrl", "_mousePosX", "_mousePosY"];
TRACE_3("params",_mapCtrl,_mousePosX,_mousePosY);
2015-08-18 02:51:40 +00:00
// If have no map tools, then exit
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
};
// If map tools not shown, then exit
if (GVAR(mapTool_Shown) == 0 && {GVAR(plottingBoard_Shown) == 0}) exitWith {false};
2015-01-15 09:51:18 +00:00
private _mousePosition = _mapCtrl ctrlMapScreenToWorld [_mousePosX, _mousePosY];
// Map tools - translation
2015-01-15 21:50:48 +00:00
if (GVAR(mapTool_isDragging)) exitWith {
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
};
// 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
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