mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Map Tools - Code cleanup (#9750)
* Maptools cleanup * Changed conditions to check * Minor cleanup + fix
This commit is contained in:
parent
c150d923f7
commit
6ba46ffa90
@ -1,4 +1,3 @@
|
||||
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
|
||||
|
@ -92,7 +92,7 @@ class CfgVehicles {
|
||||
};
|
||||
class ACE_PlottingBoard {
|
||||
displayName = CSTRING(ShowPlottingBoard);
|
||||
condition = QUOTE(GVAR(plottingBoard_Shown) < 1 && {call FUNC(canUsePlottingBoard)});
|
||||
condition = QUOTE(GVAR(plottingBoard_Shown) == 0 && {call FUNC(canUsePlottingBoard)});
|
||||
statement = QUOTE(GVAR(plottingBoard_Shown) = 1);
|
||||
EXCEPTIONS;
|
||||
showDisabled = 0;
|
||||
@ -127,7 +127,7 @@ class CfgVehicles {
|
||||
};
|
||||
class ACE_PlottingBoardAlign {
|
||||
displayName = CSTRING(AlignTo);
|
||||
condition = QUOTE(GVAR(plottingBoard_Shown) > 0);
|
||||
condition = QUOTE(GVAR(plottingBoard_Shown) != 0);
|
||||
statement = "";
|
||||
EXCEPTIONS;
|
||||
showDisabled = 0;
|
||||
@ -141,7 +141,7 @@ class CfgVehicles {
|
||||
|
||||
class ACE_PlottingBoardAlignBoardMaptool {
|
||||
displayName = CSTRING(ToMapToolLabel);
|
||||
condition = QUOTE(GVAR(mapTool_Shown) > 0 && GVAR(plottingBoard_angle) != GVAR(mapTool_angle));
|
||||
condition = QUOTE(GVAR(mapTool_Shown) != 0 && GVAR(plottingBoard_angle) != GVAR(mapTool_angle));
|
||||
statement = QUOTE(GVAR(plottingBoard_angle) = GVAR(mapTool_angle));
|
||||
EXCEPTIONS;
|
||||
showDisabled = 0;
|
||||
@ -163,7 +163,7 @@ class CfgVehicles {
|
||||
|
||||
class ACE_PlottingBoardAlignAcrylicMaptool {
|
||||
displayName = CSTRING(ToMapToolLabel);
|
||||
condition = QUOTE(GVAR(mapTool_Shown) > 0 && GVAR(plottingBoard_acrylicAngle) != GVAR(mapTool_angle));
|
||||
condition = QUOTE(GVAR(mapTool_Shown) != 0 && GVAR(plottingBoard_acrylicAngle) != GVAR(mapTool_angle));
|
||||
statement = QUOTE(GVAR(plottingBoard_acrylicAngle) = GVAR(mapTool_angle));
|
||||
EXCEPTIONS;
|
||||
showDisabled = 0;
|
||||
@ -185,7 +185,7 @@ class CfgVehicles {
|
||||
|
||||
class ACE_PlottingBoardAlignRulerMaptool {
|
||||
displayName = CSTRING(ToMapToolLabel);
|
||||
condition = QUOTE(GVAR(mapTool_Shown) > 0 && GVAR(plottingBoard_rulerAngle) != GVAR(mapTool_angle));
|
||||
condition = QUOTE(GVAR(mapTool_Shown) != 0 && GVAR(plottingBoard_rulerAngle) != GVAR(mapTool_angle));
|
||||
statement = QUOTE(GVAR(plottingBoard_rulerAngle) = GVAR(mapTool_angle));
|
||||
EXCEPTIONS;
|
||||
showDisabled = 0;
|
||||
|
@ -25,13 +25,16 @@ GVAR(plottingBoard_isRotating) = -1;
|
||||
GVAR(plottingBoard_moveToMouse) = true; // used to display it in center of screen when opened
|
||||
GVAR(plottingBoard_markers) = createHashMap;
|
||||
|
||||
//Install the event handers for the map tools on the main in-game map
|
||||
[{!isNull findDisplay 12},
|
||||
{
|
||||
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}];
|
||||
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}];
|
||||
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}];
|
||||
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {call FUNC(updateMapToolMarkers); call FUNC(openMapGpsUpdate);}];
|
||||
// Install the event handers for the map tools on the main in-game map
|
||||
[{
|
||||
!isNull findDisplay 12
|
||||
}, {
|
||||
private _map = (findDisplay 12) displayCtrl 51;
|
||||
|
||||
_map ctrlAddEventHandler ["MouseMoving", LINKFUNC(handleMouseMove)];
|
||||
_map ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}];
|
||||
_map ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}];
|
||||
_map ctrlAddEventHandler ["Draw", {call FUNC(updateMapToolMarkers); call FUNC(openMapGpsUpdate);}];
|
||||
}, []] call CBA_fnc_waitUntilAndExecute;
|
||||
|
||||
["visibleMap", {
|
||||
|
@ -1,21 +1,22 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
* Returns the equivalent of 100m in screen coordinates
|
||||
* Returns the equivalent of 100m in screen coordinates.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
* Map scale <NUMBER>
|
||||
*
|
||||
* Example:
|
||||
* call ACE_maptools_fnc_calculateMapScale
|
||||
* call ace_maptools_fnc_calculateMapScale
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
private _pos = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5];
|
||||
private _screenOffset = ((findDisplay 12) displayCtrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)];
|
||||
private _mapCtrl = (findDisplay 12) displayCtrl 51;
|
||||
private _pos = _mapCtrl ctrlMapScreenToWorld [0.5, 0.5];
|
||||
private _screenOffset = _mapCtrl posWorldToScreen (_pos vectorAdd [100, 0]);
|
||||
|
||||
(_screenOffset select 0) - 0.5
|
||||
|
@ -1,16 +1,16 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
* canUseMapGPS
|
||||
* Returns if the GPS on the map can be used.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
* GPS can be used <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* call ACE_maptools_fnc_canUseMapGPS
|
||||
* call ace_maptools_fnc_canUseMapGPS
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
@ -1,23 +1,23 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain
|
||||
* canUseMapTools
|
||||
* Returns if the map tools can be used.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
* Map tools can be used <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* call ACE_maptools_fnc_canUseMapTools
|
||||
* call ace_maptools_fnc_canUseMapTools
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
visibleMap &&
|
||||
{alive ACE_player} &&
|
||||
{"ACE_MapTools" in (ACE_player call EFUNC(common,uniqueItems))} &&
|
||||
{!GVAR(mapTool_isDragging)} &&
|
||||
{!GVAR(mapTool_isRotating)} &&
|
||||
{getUnitLoadout ACE_player param [9, []] param [0, ""] != ""}
|
||||
{ACE_player getSlotItemName TYPE_MAP != ""} &&
|
||||
{[ACE_player, "ACE_MapTools"] call EFUNC(common,hasItem)}
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
visibleMap &&
|
||||
{alive ACE_player} &&
|
||||
{[ACE_player, "ACE_PlottingBoard"] call EFUNC(common,hasItem)} &&
|
||||
{!GVAR(plottingBoard_isDragging)} &&
|
||||
{GVAR(plottingBoard_isRotating) == -1}
|
||||
{GVAR(plottingBoard_isRotating) == -1} &&
|
||||
{[ACE_player, "ACE_PlottingBoard"] call EFUNC(common,hasItem)}
|
||||
|
@ -4,63 +4,71 @@
|
||||
* Prevents the cursor from entering the roamer when drawing lines and records the positions
|
||||
*
|
||||
* Arguments:
|
||||
* 0: The Map <CONTROL>
|
||||
* 0: Map control <CONTROL>
|
||||
* 1: Roamer Width <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [map, 300] call ace_maptools_fnc_drawLinesOnRoamer
|
||||
* [CONTROL, 300] call ace_maptools_fnc_drawLinesOnRoamer
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (!GVAR(drawStraightLines)) exitWith {};
|
||||
|
||||
params ["_theMap", "_roamerWidth"];
|
||||
params ["_mapCtrl", "_roamerWidth"];
|
||||
GVAR(mapTool_pos) params ["_roamerPosX", "_roamerPosY"];
|
||||
|
||||
private _posCenter = [_roamerPosX, _roamerPosY, 0];
|
||||
|
||||
private _posTopRight = [
|
||||
_roamerPosX + (cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (-sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
0];
|
||||
_roamerPosX + (cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (-sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
0
|
||||
];
|
||||
|
||||
private _posTopLeft = [
|
||||
_roamerPosX + (-cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
0];
|
||||
_roamerPosX + (-cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_TOP_TO_CENTER_PERC * _roamerWidth,
|
||||
0
|
||||
];
|
||||
|
||||
private _posBottomLeft = [
|
||||
_roamerPosX + (-cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
0];
|
||||
_roamerPosX + (-cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
0
|
||||
];
|
||||
|
||||
private _posBottomRight = [
|
||||
_roamerPosX + (cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (-sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
0];
|
||||
_roamerPosX + (cos GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (sin GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
_roamerPosY + (-sin GVAR(mapTool_angle)) * DIST_LEFT_TO_CENTER_PERC * _roamerWidth + (cos GVAR(mapTool_angle)) * DIST_BOTTOM_TO_CENTER_PERC * _roamerWidth,
|
||||
0
|
||||
];
|
||||
|
||||
private _fnc_Distance = { // Get distance point _p is from a line made from _a to _b (uses 3d array commands, but z should be 0)
|
||||
private _fnc_distance = { // Get distance point _p is from a line made from _a to _b (uses 3d array commands, but z should be 0)
|
||||
// Ref: https://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line#Vector_formulation
|
||||
params ["_a", "_b", "_p"];
|
||||
|
||||
private _n = _b vectorDiff _a;
|
||||
private _pa = _a vectorDiff _p;
|
||||
private _c = _n vectorMultiply ((_pa vectorDotProduct _n) / (_n vectorDotProduct _n));
|
||||
private _d = _pa vectorDiff _c;
|
||||
sqrt (_d vectorDotProduct _d);
|
||||
|
||||
sqrt (_d vectorDotProduct _d)
|
||||
};
|
||||
|
||||
private _currentMousePos = _theMap ctrlMapScreenToWorld getMousePosition;
|
||||
private _currentMousePos = _mapCtrl ctrlMapScreenToWorld getMousePosition;
|
||||
_currentMousePos set [2, 0];
|
||||
|
||||
// Break the roamer rectangle into 4 triangle, one for each side
|
||||
switch (true) do {
|
||||
case (_currentMousePos inPolygon [_posCenter, _posTopLeft, _posBottomLeft]): { // Left
|
||||
private _distanceToRoamerLine = ([_posTopLeft, _posBottomLeft, _currentMousePos] call _fnc_Distance);
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, (GVAR(mapTool_angle) - 90) ,0] call CBA_fnc_polar2vect);
|
||||
private _distanceToRoamerLine = [_posTopLeft, _posBottomLeft, _currentMousePos] call _fnc_distance;
|
||||
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, GVAR(mapTool_angle) - 90, 0] call CBA_fnc_polar2vect);
|
||||
|
||||
if (GVAR(freeDrawingData) isEqualTo []) then { // We start drawing on the line
|
||||
GVAR(freeDrawingData) = ["left", _currentMousePos, _currentMousePos];
|
||||
} else {
|
||||
@ -68,17 +76,21 @@ switch (true) do {
|
||||
if ((_currentMousePos distance2d _posTopLeft) < ((GVAR(freeDrawingData) select 1) distance2d _posTopLeft)) then {
|
||||
GVAR(freeDrawingData) set [1, _currentMousePos];
|
||||
};
|
||||
|
||||
if ((_currentMousePos distance2d _posBottomLeft) < ((GVAR(freeDrawingData) select 2) distance2d _posBottomLeft)) then {
|
||||
GVAR(freeDrawingData) set [2, _currentMousePos];
|
||||
};
|
||||
};
|
||||
};
|
||||
private _screenPosOfCorrectedPos = _theMap ctrlMapWorldToScreen _currentMousePos;
|
||||
|
||||
private _screenPosOfCorrectedPos = _mapCtrl ctrlMapWorldToScreen _currentMousePos;
|
||||
setMousePosition _screenPosOfCorrectedPos;
|
||||
};
|
||||
case (_currentMousePos inPolygon [_posCenter, _posTopLeft, _posTopRight]): { // Top
|
||||
private _distanceToRoamerLine = ([_posTopLeft, _posTopRight, _currentMousePos] call _fnc_Distance);
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, (GVAR(mapTool_angle) + 0) ,0] call CBA_fnc_polar2vect);
|
||||
private _distanceToRoamerLine = [_posTopLeft, _posTopRight, _currentMousePos] call _fnc_distance;
|
||||
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, GVAR(mapTool_angle), 0] call CBA_fnc_polar2vect);
|
||||
|
||||
if (GVAR(freeDrawingData) isEqualTo []) then { // We start drawing on the line
|
||||
GVAR(freeDrawingData) = ["top", _currentMousePos, _currentMousePos];
|
||||
} else {
|
||||
@ -86,17 +98,21 @@ switch (true) do {
|
||||
if ((_currentMousePos distance2d _posTopLeft) < ((GVAR(freeDrawingData) select 1) distance2d _posTopLeft)) then {
|
||||
GVAR(freeDrawingData) set [1, _currentMousePos];
|
||||
};
|
||||
|
||||
if ((_currentMousePos distance2d _posTopRight) < ((GVAR(freeDrawingData) select 2) distance2d _posTopRight)) then {
|
||||
GVAR(freeDrawingData) set [2, _currentMousePos];
|
||||
};
|
||||
};
|
||||
};
|
||||
private _screenPosOfCorrectedPos = _theMap ctrlMapWorldToScreen _currentMousePos;
|
||||
|
||||
private _screenPosOfCorrectedPos = _mapCtrl ctrlMapWorldToScreen _currentMousePos;
|
||||
setMousePosition _screenPosOfCorrectedPos;
|
||||
};
|
||||
case (_currentMousePos inPolygon [_posCenter, _posTopRight, _posBottomRight]): { // Right
|
||||
private _distanceToRoamerLine = ([_posTopRight, _posBottomRight, _currentMousePos] call _fnc_Distance);
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, (GVAR(mapTool_angle) + 90) ,0] call CBA_fnc_polar2vect);
|
||||
private _distanceToRoamerLine = [_posTopRight, _posBottomRight, _currentMousePos] call _fnc_distance;
|
||||
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, GVAR(mapTool_angle) + 90, 0] call CBA_fnc_polar2vect);
|
||||
|
||||
if (GVAR(freeDrawingData) isEqualTo []) then { // We start drawing on the line
|
||||
GVAR(freeDrawingData) = ["right", _currentMousePos, _currentMousePos];
|
||||
} else {
|
||||
@ -104,17 +120,21 @@ switch (true) do {
|
||||
if ((_currentMousePos distance2d _posTopRight) < ((GVAR(freeDrawingData) select 1) distance2d _posTopRight)) then {
|
||||
GVAR(freeDrawingData) set [1, _currentMousePos];
|
||||
};
|
||||
|
||||
if ((_currentMousePos distance2d _posBottomRight) < ((GVAR(freeDrawingData) select 2) distance2d _posBottomRight)) then {
|
||||
GVAR(freeDrawingData) set [2, _currentMousePos];
|
||||
};
|
||||
};
|
||||
};
|
||||
private _screenPosOfCorrectedPos = _theMap ctrlMapWorldToScreen _currentMousePos;
|
||||
|
||||
private _screenPosOfCorrectedPos = _mapCtrl ctrlMapWorldToScreen _currentMousePos;
|
||||
setMousePosition _screenPosOfCorrectedPos;
|
||||
};
|
||||
case (_currentMousePos inPolygon [_posCenter, _posBottomLeft, _posBottomRight]): { // Bottom
|
||||
private _distanceToRoamerLine = ([_posBottomLeft, _posBottomRight, _currentMousePos] call _fnc_Distance);
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, (GVAR(mapTool_angle) + 180) ,0] call CBA_fnc_polar2vect);
|
||||
private _distanceToRoamerLine = [_posBottomLeft, _posBottomRight, _currentMousePos] call _fnc_distance;
|
||||
|
||||
_currentMousePos = _currentMousePos vectorAdd ([_distanceToRoamerLine, GVAR(mapTool_angle) + 180, 0] call CBA_fnc_polar2vect);
|
||||
|
||||
if (GVAR(freeDrawingData) isEqualTo []) then { // We start drawing on the line
|
||||
GVAR(freeDrawingData) = ["bottom", _currentMousePos, _currentMousePos];
|
||||
} else {
|
||||
@ -122,23 +142,26 @@ switch (true) do {
|
||||
if ((_currentMousePos distance2d _posBottomLeft) < ((GVAR(freeDrawingData) select 1) distance2d _posBottomLeft)) then {
|
||||
GVAR(freeDrawingData) set [1, _currentMousePos];
|
||||
};
|
||||
|
||||
if ((_currentMousePos distance2d _posBottomRight) < ((GVAR(freeDrawingData) select 2) distance2d _posBottomRight)) then {
|
||||
GVAR(freeDrawingData) set [2, _currentMousePos];
|
||||
};
|
||||
};
|
||||
};
|
||||
private _screenPosOfCorrectedPos = _theMap ctrlMapWorldToScreen _currentMousePos;
|
||||
|
||||
private _screenPosOfCorrectedPos = _mapCtrl ctrlMapWorldToScreen _currentMousePos;
|
||||
setMousePosition _screenPosOfCorrectedPos;
|
||||
};
|
||||
};
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
_theMap drawIcon ['iconStaticMG',[1,0,0,1],_posTopRight,24,24,getDir player,'1,1',1,0.03,'TahomaB','right'];
|
||||
_theMap drawIcon ['iconStaticMG',[1,0,0,1],_posTopLeft,24,24,getDir player,'-1,1',1,0.03,'TahomaB','right'];
|
||||
_theMap drawIcon ['iconStaticMG',[1,0,0,1],_posBottomLeft,24,24,getDir player,'-1,-1',1,0.03,'TahomaB','right'];
|
||||
_theMap drawIcon ['iconStaticMG',[1,0,0,1],_posBottomRight,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[1,0,0,1],_posTopRight,24,24,getDir player,'1,1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[1,0,0,1],_posTopLeft,24,24,getDir player,'-1,1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[1,0,0,1],_posBottomLeft,24,24,getDir player,'-1,-1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[1,0,0,1],_posBottomRight,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
|
||||
if (GVAR(freeDrawingData) isNotEqualTo []) then {
|
||||
_theMap drawIcon ['iconStaticMG',[0,0,1,1],GVAR(freeDrawingData) select 1,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
_theMap drawIcon ['iconStaticMG',[0,0,1,1],GVAR(freeDrawingData) select 2,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[0,0,1,1],GVAR(freeDrawingData) select 1,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
_mapCtrl drawIcon ['iconStaticMG',[0,0,1,1],GVAR(freeDrawingData) select 2,24,24,getDir player,'1,-1',1,0.03,'TahomaB','right'];
|
||||
};
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
* 1: Parameters of the mouse button event <ARRAY>
|
||||
*
|
||||
* Return Value:
|
||||
* True if event was handled <BOOL>
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [0, []] call ace_maptools_fnc_handleMouseButton
|
||||
@ -80,13 +80,11 @@ if (_dir != 1) then {
|
||||
if (GVAR(mapTool_isDragging) || GVAR(mapTool_isRotating)) then {
|
||||
GVAR(mapTool_isDragging) = false;
|
||||
GVAR(mapTool_isRotating) = false;
|
||||
_handled = true;
|
||||
};
|
||||
|
||||
if (GVAR(plottingBoard_isDragging) || GVAR(plottingBoard_isRotating) > -1) then {
|
||||
GVAR(plottingBoard_isDragging) = false;
|
||||
GVAR(plottingBoard_isRotating) = -1;
|
||||
_handled = true;
|
||||
};
|
||||
} else {
|
||||
// If clicking
|
||||
@ -125,8 +123,6 @@ if (_dir != 1) then {
|
||||
// Start dragging
|
||||
GVAR(mapTool_isDragging) = true;
|
||||
};
|
||||
|
||||
_handled = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -170,11 +166,7 @@ if (_dir != 1) then {
|
||||
// Start dragging
|
||||
GVAR(plottingBoard_isDragging) = true;
|
||||
};
|
||||
|
||||
_handled = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
_handled
|
||||
|
@ -5,10 +5,11 @@
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Map control <CONTROL>
|
||||
* 1: Mouse position on screen coordinates <ARRAY>
|
||||
* 1: Mouse x position <NUMBER>
|
||||
* 2: Mouse y position <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* If the event was handled <BOOL>
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [CONTROL, [0, 5]] call ace_maptools_fnc_handleMouseMove
|
||||
@ -24,9 +25,7 @@ if (isNull ACE_player || {
|
||||
private _uniqueItems = ACE_player call EFUNC(common,uniqueItems);
|
||||
|
||||
!(("ACE_MapTools" in _uniqueItems) || {"ACE_PlottingBoard" in _uniqueItems})
|
||||
}) exitWith {
|
||||
false
|
||||
};
|
||||
}) exitWith {};
|
||||
|
||||
// If map tools not shown, then exit
|
||||
if (GVAR(mapTool_Shown) == 0 && {GVAR(plottingBoard_Shown) == 0}) exitWith {false};
|
||||
@ -36,8 +35,6 @@ private _mousePosition = _mapCtrl ctrlMapScreenToWorld [_mousePosX, _mousePosY];
|
||||
// Map tools - translation
|
||||
if (GVAR(mapTool_isDragging)) exitWith {
|
||||
GVAR(mapTool_pos) = GVAR(mapTool_startPos) vectorAdd _mousePosition vectorDiff GVAR(mapTool_startDragPos);
|
||||
|
||||
true
|
||||
};
|
||||
|
||||
// Map tools - rotation
|
||||
@ -47,15 +44,11 @@ if (GVAR(mapTool_isRotating)) exitWith {
|
||||
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
|
||||
@ -70,8 +63,4 @@ if (GVAR(plottingBoard_isRotating) > -1) exitWith {
|
||||
case 1: {GVAR(plottingBoard_acrylicAngle) = _returnAngle};
|
||||
case 2: {GVAR(plottingBoard_rulerAngle) = _returnAngle};
|
||||
};
|
||||
|
||||
true
|
||||
};
|
||||
|
||||
false
|
||||
|
@ -30,7 +30,7 @@ if (_deleted) exitWith {
|
||||
};
|
||||
|
||||
// Do not process non-local or already processed markers, don't check if the plotting board isn't shown
|
||||
if (!_local || {GVAR(plottingBoard_Shown) < 1} || {QUOTE(ADDON) in _marker}) exitWith {};
|
||||
if (!_local || {GVAR(plottingBoard_Shown) == 0} || {QUOTE(ADDON) in _marker}) exitWith {};
|
||||
|
||||
// Check if the channel the marker was made in can be marked on the plotting board
|
||||
private _continue = true;
|
||||
|
@ -4,32 +4,32 @@
|
||||
* Return true if the position is inside the map marker (to allow dragging).
|
||||
*
|
||||
* Arguments:
|
||||
* 0: x Position (in meters) <NUMBER>
|
||||
* 1: y Position (in meters) <NUMBER>
|
||||
* 0: x position (in meters) <NUMBER>
|
||||
* 1: y position (in meters) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Boolean <BOOL>
|
||||
* Is inside map tool <BOOL>
|
||||
*
|
||||
* Example:
|
||||
* [0, 5] call ACE_maptools_fnc_isInsideMapTool
|
||||
* [0, 5] call ace_maptools_fnc_isInsideMapTool
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
if (GVAR(mapTool_Shown) == 0) exitWith {false};
|
||||
|
||||
private _textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);
|
||||
|
||||
private _pos = [_this select 0, _this select 1, 0];
|
||||
private _relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0];
|
||||
private _dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0];
|
||||
private _relPos = _this vectorDiff GVAR(mapTool_pos);
|
||||
private _dirVector = [sin GVAR(mapTool_angle), cos GVAR(mapTool_angle)];
|
||||
|
||||
// Projection of the relative position over the longitudinal axis of the map tool
|
||||
private _lambdaLong = _dirVector vectorDotProduct _relPos;
|
||||
|
||||
if (_lambdaLong < DIST_BOTTOM_TO_CENTER_PERC * _textureWidth) exitWith {false};
|
||||
|
||||
// Projection of the relative position over the trasversal axis of the map tool
|
||||
private _lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong));
|
||||
if (_lambdaLong > DIST_TOP_TO_CENTER_PERC * _textureWidth) exitWith {false};
|
||||
if (_lambdaTrasAbs > DIST_LEFT_TO_CENTER_PERC * _textureWidth) exitWith {false};
|
||||
|
||||
true
|
||||
// Projection of the relative position over the transversal axis of the map tool
|
||||
private _lambdaTransAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong));
|
||||
|
||||
_lambdaTransAbs <= DIST_LEFT_TO_CENTER_PERC * _textureWidth
|
||||
|
@ -4,8 +4,8 @@
|
||||
* Return if the position is inside the map marker (to allow dragging) or not.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: x Position (in meters) <NUMBER>
|
||||
* 1: y Position (in meters) <NUMBER>
|
||||
* 0: x position (in meters) <NUMBER>
|
||||
* 1: y position (in meters) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Where in the plotting board it is <NUMBER>
|
||||
@ -30,9 +30,11 @@ private _isRuler = if (GVAR(plottingBoard_Shown) == 2) then {
|
||||
private _dirRightVector = [_dirVector select 1, -(_dirVector select 0)];
|
||||
private _rulerAng = acos (_rulerVector vectorCos _relPos);
|
||||
|
||||
if (cos _rulerAng > 0 && {tan (_rulerAng) * _dist < PLOTTINGBOARD_RULERHALFWIDTH}) exitWith {true};
|
||||
if (cos _rulerAng > 0 && {(tan _rulerAng) * _dist < PLOTTINGBOARD_RULERHALFWIDTH}) exitWith {true};
|
||||
|
||||
_dist > PLOTTINGBOARD_RULERINNERCIRCLE && {_dist < PLOTTINGBOARD_RULEROUTERCIRCLE && {abs (_rulerAng * DEGTOMILS) < PLOTTINGBOAR_RULEROUTERHALFANGLE}}
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
if (_isRuler) exitWith {2};
|
||||
|
@ -1,34 +1,39 @@
|
||||
#include "..\script_component.hpp"
|
||||
/*
|
||||
* Author: esteldunedain, PabstMirror
|
||||
* update gps display, called from main map's draw
|
||||
* Update GPS display, called from main map's draw.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Map ctrl <CONTROL>
|
||||
* 0: Map control <CONTROL>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* [findDisplay 12 displayCtrl 51] call ACE_maptools_fnc_openMapGpsUpdate;
|
||||
* [findDisplay 12 displayCtrl 51] call ace_maptools_fnc_openMapGpsUpdate;
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_mapCtrl"];
|
||||
|
||||
private _mapDisplay = ctrlParent _mapCtrl;
|
||||
|
||||
if ((!GVAR(mapGpsShow)) || {!(call FUNC(canUseMapGPS))}) exitWith {
|
||||
if (!GVAR(mapGpsShow) || {!(call FUNC(canUseMapGPS))}) exitWith {
|
||||
(_mapDisplay displayCtrl 913589) ctrlShow false;
|
||||
};
|
||||
|
||||
(_mapDisplay displayCtrl 913589) ctrlShow true;
|
||||
|
||||
if (CBA_missionTime < GVAR(mapGpsNextUpdate)) exitWith {};
|
||||
|
||||
GVAR(mapGpsNextUpdate) = CBA_missionTime + 0.5;
|
||||
|
||||
private _ctrl = _mapDisplay displayCtrl 913590;
|
||||
_ctrl ctrlSetText str (round (getDir ACE_player)); // Set Heading
|
||||
|
||||
_ctrl = _mapDisplay displayCtrl 913591;
|
||||
_ctrl ctrlSetText str (round ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude)); // Set Altitude
|
||||
|
||||
_ctrl = _mapDisplay displayCtrl 913592;
|
||||
_ctrl ctrlSetText mapGridPosition ACE_player; // Set grid cords
|
||||
|
@ -27,6 +27,7 @@ if (GVAR(plottingBoard_Shown) == 0) then {
|
||||
} forEach GVAR(plottingBoard_markers);
|
||||
} else {
|
||||
if !([ACE_player, "ACE_PlottingBoard"] call EFUNC(common,hasItem)) exitWith {};
|
||||
|
||||
if (GVAR(plottingBoard_moveToMouse)) then {
|
||||
GVAR(plottingBoard_pos) = _mapCtrl ctrlMapScreenToWorld getMousePosition;
|
||||
GVAR(plottingBoard_moveToMouse) = false; // we only need to do this once after opening the map tool
|
||||
@ -90,7 +91,7 @@ if (GVAR(plottingBoard_Shown) == 0) then {
|
||||
} forEach GVAR(plottingBoard_markers);
|
||||
};
|
||||
|
||||
if ((GVAR(mapTool_Shown) > 0) && {[ACE_player, "ACE_MapTools"] call EFUNC(common,hasItem)}) then {
|
||||
if ((GVAR(mapTool_Shown) != 0) && {[ACE_player, "ACE_MapTools"] call EFUNC(common,hasItem)}) then {
|
||||
// Open map tools in center of screen when toggled to be shown
|
||||
if (GVAR(mapTool_moveToMouse)) then {
|
||||
GVAR(mapTool_pos) = _mapCtrl ctrlMapScreenToWorld getMousePosition;
|
||||
|
@ -1,4 +1,4 @@
|
||||
private _category = format ["ACE %1", localize LSTRING(Name)];
|
||||
private _category = format ["ACE %1", LLSTRING(Name)];
|
||||
|
||||
[
|
||||
QGVAR(rotateModifierKey), "LIST",
|
||||
|
@ -18,17 +18,17 @@
|
||||
|
||||
#define DEGTOMILS 17.7777778
|
||||
|
||||
#define TEXTURE_WIDTH_IN_M 6205
|
||||
#define CENTER_OFFSET_Y_PERC 0.1606
|
||||
#define CONSTANT_SCALE 0.2
|
||||
#define TEXTURE_WIDTH_IN_M 6205
|
||||
#define CENTER_OFFSET_Y_PERC 0.1606
|
||||
#define CONSTANT_SCALE 0.2
|
||||
#define DIST_BOTTOM_TO_CENTER_PERC -0.33
|
||||
#define DIST_TOP_TO_CENTER_PERC 0.65
|
||||
#define DIST_LEFT_TO_CENTER_PERC 0.30
|
||||
#define DIST_TOP_TO_CENTER_PERC 0.65
|
||||
#define DIST_LEFT_TO_CENTER_PERC 0.30
|
||||
|
||||
#define PLOTTINGBOARD_DRAWRANGE 3000
|
||||
#define PLOTTINGBOARD_TEXTUREWIDTH 6000
|
||||
#define PLOTTINGBOARD_RULERCENTER 450
|
||||
#define PLOTTINGBOARD_RULERHALFWIDTH 100
|
||||
#define PLOTTINGBOARD_DRAWRANGE 3000
|
||||
#define PLOTTINGBOARD_TEXTUREWIDTH 6000
|
||||
#define PLOTTINGBOARD_RULERCENTER 450
|
||||
#define PLOTTINGBOARD_RULERHALFWIDTH 100
|
||||
#define PLOTTINGBOARD_RULERINNERCIRCLE 2900
|
||||
#define PLOTTINGBOARD_RULEROUTERCIRCLE 3000
|
||||
#define PLOTTINGBOARD_RULEROUTERHALFANGLE 100
|
||||
|
Loading…
Reference in New Issue
Block a user