2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2024-01-07 18:02:05 +00:00
|
|
|
* Author: esteldunedain, LorenLuke
|
2015-01-11 16:42:31 +00:00
|
|
|
* Handle mouse buttons.
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2024-01-07 18:02:05 +00:00
|
|
|
* 0: 1 if mouse down down, 0 if mouse button up <NUMBER>
|
2017-06-08 13:31:51 +00:00
|
|
|
* 1: Parameters of the mouse button event <ARRAY>
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2024-02-03 18:48:21 +00:00
|
|
|
* None
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Example:
|
2024-01-07 18:02:05 +00:00
|
|
|
* [0, []] call ace_maptools_fnc_handleMouseButton
|
2017-06-08 13:31:51 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2015-08-18 02:51:40 +00:00
|
|
|
params ["_dir", "_params"];
|
|
|
|
_params params ["_control", "_button", "_screenPosX", "_screenPosY", "_shiftKey", "_ctrlKey", "_altKey"];
|
2015-08-18 21:57:56 +00:00
|
|
|
TRACE_2("params",_dir,_params);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-10-07 22:21:19 +00:00
|
|
|
// Using line drawing
|
|
|
|
if ((_button == 0) && {GVAR(freedrawing) || _ctrlKey}) exitWith {
|
|
|
|
if (GVAR(freedrawing) && {_dir == 0}) then {
|
|
|
|
GVAR(freedrawing) = false;
|
2024-01-07 18:02:05 +00:00
|
|
|
|
2019-06-27 17:57:30 +00:00
|
|
|
if (_shiftKey) exitWith {
|
|
|
|
TRACE_1("using vanilla straight line",_shiftKey);
|
|
|
|
};
|
2024-01-07 18:02:05 +00:00
|
|
|
|
2019-06-27 17:57:30 +00:00
|
|
|
TRACE_2("Ending Line",GVAR(freedrawing),GVAR(freeDrawingData));
|
2024-01-07 18:02:05 +00:00
|
|
|
|
2016-10-07 22:21:19 +00:00
|
|
|
[{
|
2024-01-07 18:02:05 +00:00
|
|
|
if (GVAR(freeDrawingData) isEqualTo []) exitWith {TRACE_1("never touched roamer",GVAR(freeDrawingData))};
|
|
|
|
|
|
|
|
private _allMarkers = allMapMarkers;
|
|
|
|
|
|
|
|
if (_allMarkers isEqualTo []) exitWith {};
|
|
|
|
|
|
|
|
private _markerName = _allMarkers select -1;
|
2016-10-07 22:21:19 +00:00
|
|
|
private _markerPos = getMarkerPos _markerName;
|
2024-01-07 18:02:05 +00:00
|
|
|
private _distanceCheck = _markerPos distance2D GVAR(drawPosStart);
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2016-10-07 22:21:19 +00:00
|
|
|
TRACE_3("Line Drawn",_markerName,_markerPos,_distanceCheck);
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
if (_distanceCheck > 1) exitWith {WARNING("Wrong Marker!")};
|
2017-06-08 13:31:51 +00:00
|
|
|
|
2016-10-07 22:21:19 +00:00
|
|
|
GVAR(freeDrawingData) params ["", "_startStraightPos", "_endStraightPos"];
|
|
|
|
|
2023-04-03 17:18:47 +00:00
|
|
|
_markerName setMarkerPolyline [
|
|
|
|
_startStraightPos#0, _startStraightPos#1,
|
|
|
|
_endStraightPos#0, _endStraightPos#1
|
|
|
|
];
|
2016-10-07 22:21:19 +00:00
|
|
|
}, []] call CBA_fnc_execNextFrame;
|
|
|
|
} else {
|
|
|
|
if (_ctrlKey && {_dir == 1}) then {
|
|
|
|
GVAR(freeDrawingData) = [];
|
|
|
|
GVAR(freedrawing) = true;
|
|
|
|
GVAR(drawPosStart) = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY];
|
|
|
|
TRACE_2("Starting Line",GVAR(freedrawing),GVAR(drawPosStart));
|
|
|
|
} else {
|
|
|
|
GVAR(freedrawing) = false;
|
2024-01-07 18:02:05 +00:00
|
|
|
TRACE_1("weird - resetting",GVAR(freedrawing));
|
2016-10-07 22:21:19 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
false // return
|
|
|
|
};
|
2015-01-16 23:13:26 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
// If it's not a left button event, exit
|
2024-01-07 18:02:05 +00:00
|
|
|
if (_button != 0) exitWith {
|
|
|
|
false // return
|
|
|
|
};
|
|
|
|
|
|
|
|
private _handled = false;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// If releasing
|
2015-08-18 21:57:56 +00:00
|
|
|
if (_dir != 1) then {
|
|
|
|
if (GVAR(mapTool_isDragging) || GVAR(mapTool_isRotating)) then {
|
|
|
|
GVAR(mapTool_isDragging) = false;
|
|
|
|
GVAR(mapTool_isRotating) = false;
|
|
|
|
};
|
2024-01-07 18:02:05 +00:00
|
|
|
|
|
|
|
if (GVAR(plottingBoard_isDragging) || GVAR(plottingBoard_isRotating) > -1) then {
|
|
|
|
GVAR(plottingBoard_isDragging) = false;
|
|
|
|
GVAR(plottingBoard_isRotating) = -1;
|
|
|
|
};
|
2015-08-18 21:57:56 +00:00
|
|
|
} else {
|
|
|
|
// If clicking
|
2024-01-07 18:02:05 +00:00
|
|
|
if (call FUNC(canUseMapTools)) then {
|
|
|
|
GVAR(mapTool_isDragging) = false;
|
|
|
|
GVAR(mapTool_isRotating) = false;
|
2016-06-07 16:52:28 +00:00
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
// If no map tool marker then exit
|
|
|
|
if (GVAR(mapTool_Shown) != 0) then {
|
|
|
|
// Transform mouse screen position to coordinates
|
|
|
|
private _pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY];
|
|
|
|
|
|
|
|
// Check if clicking the maptool
|
|
|
|
if (_pos call FUNC(isInsideMapTool)) then {
|
|
|
|
// Store data for dragging
|
|
|
|
GVAR(mapTool_startPos) = +GVAR(mapTool_pos);
|
|
|
|
GVAR(mapTool_startDragPos) = _pos;
|
|
|
|
|
|
|
|
private _rotateKeyPressed = switch (GVAR(rotateModifierKey)) do {
|
|
|
|
case 1: {_altKey};
|
|
|
|
case 2: {_ctrlKey};
|
|
|
|
case 3: {_shiftKey};
|
|
|
|
default {false};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_rotateKeyPressed) then {
|
|
|
|
// Store data for rotating
|
|
|
|
GVAR(mapTool_startAngle) = GVAR(mapTool_angle);
|
|
|
|
|
|
|
|
private _pos = GVAR(mapTool_startDragPos) vectorDiff GVAR(mapTool_startPos);
|
|
|
|
GVAR(mapTool_startDragAngle) = ((_pos select 0) atan2 (_pos select 1) + 360) % 360;
|
|
|
|
|
|
|
|
// Start rotating
|
|
|
|
GVAR(mapTool_isRotating) = true;
|
|
|
|
} else {
|
|
|
|
// Start dragging
|
|
|
|
GVAR(mapTool_isDragging) = true;
|
|
|
|
};
|
|
|
|
};
|
2016-06-07 16:52:28 +00:00
|
|
|
};
|
2024-01-07 18:02:05 +00:00
|
|
|
};
|
2016-06-07 16:52:28 +00:00
|
|
|
|
2024-01-07 18:02:05 +00:00
|
|
|
if (call FUNC(canUsePlottingBoard)) then {
|
|
|
|
GVAR(plottingBoard_isDragging) = false;
|
|
|
|
GVAR(plottingBoard_isRotating) = -1;
|
|
|
|
|
|
|
|
if (GVAR(plottingBoard_Shown) != 0) then {
|
|
|
|
// Transform mouse screen position to coordinates
|
|
|
|
private _pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY];
|
|
|
|
private _click = _pos call FUNC(isInsidePlottingBoard);
|
|
|
|
|
|
|
|
if (_click > -1) then {
|
|
|
|
GVAR(plottingBoard_startPos) = +GVAR(plottingBoard_pos);
|
|
|
|
GVAR(plottingBoard_startDragPos) = _pos;
|
|
|
|
|
|
|
|
private _rotateKeyPressed = switch (GVAR(rotateModifierKey)) do {
|
|
|
|
case 1: {_altKey};
|
|
|
|
case 2: {_ctrlKey};
|
|
|
|
case 3: {_shiftKey};
|
|
|
|
default {false};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_rotateKeyPressed) then {
|
|
|
|
// Store data for rotating
|
|
|
|
private _ang = switch (_click) do {
|
|
|
|
case 1: {GVAR(plottingBoard_acrylicAngle)};
|
|
|
|
case 2: {GVAR(plottingBoard_rulerAngle)};
|
|
|
|
default {GVAR(plottingBoard_angle)};
|
|
|
|
};
|
|
|
|
|
|
|
|
GVAR(plottingBoard_startAngle) = _ang;
|
|
|
|
|
|
|
|
private _pos = GVAR(plottingBoard_startDragPos) vectorDiff GVAR(plottingBoard_startPos);
|
|
|
|
GVAR(plottingBoard_startDragAngle) = ((_pos select 0) atan2 (_pos select 1) + 360) % 360;
|
|
|
|
|
|
|
|
// Start rotating
|
|
|
|
GVAR(plottingBoard_isRotating) = _click;
|
|
|
|
} else {
|
|
|
|
// Start dragging
|
|
|
|
GVAR(plottingBoard_isDragging) = true;
|
|
|
|
};
|
|
|
|
};
|
2015-04-07 19:38:35 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
|
|
|
};
|