ACE3/addons/map/functions/fnc_updateMapToolMarkers.sqf

74 lines
3.0 KiB
Plaintext
Raw Normal View History

2015-01-15 09:51:18 +00:00
/*
* Author: CAA-Picard
*
* Update the map tool markers, position, size, rotation and visibility.
*
* Argument:
* None
*
* Return value:
* Nothing
*/
2015-01-15 21:50:48 +00:00
#include "script_component.hpp"
2015-01-15 09:51:18 +00:00
#define TEXTURE_WIDTH_IN_M 6205
#define CENTER_OFFSET_Y_PERC 0.1606
#define CONSTANT_SCALE 0.2
// If markers exist and they should'nt, delete them
2015-01-16 08:13:29 +00:00
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) == 0}) then {
2015-01-15 09:51:18 +00:00
// If markers exist, delete them
2015-01-15 21:50:48 +00:00
if (!isNil QGVAR(mapTool_markerRotatingFixed)) then {
2015-01-15 09:51:18 +00:00
deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED;
2015-01-15 21:50:48 +00:00
GVAR(mapTool_markerRotatingFixed) = nil;
2015-01-15 09:51:18 +00:00
};
};
2015-01-16 08:13:29 +00:00
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 1}) then {
if (!isNil QGVAR(mapTool_markerRotatingNormal)) then {
2015-01-15 09:51:18 +00:00
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL;
2015-01-15 21:50:48 +00:00
GVAR(mapTool_markerRotatingNormal) = nil;
2015-01-15 09:51:18 +00:00
};
};
2015-01-16 08:13:29 +00:00
if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 2}) then {
if (!isNil QGVAR(mapTool_markerRotatingSmall)) then {
2015-01-15 09:51:18 +00:00
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL;
2015-01-15 21:50:48 +00:00
GVAR(mapTool_markerRotatingSmall) = nil;
2015-01-15 09:51:18 +00:00
};
};
2015-01-16 08:13:29 +00:00
if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {};
2015-01-15 09:51:18 +00:00
// If markers don't exist and should, create them
2015-01-15 21:50:48 +00:00
if (isNil QGVAR(mapTool_markerRotatingFixed)) then {
GVAR(mapTool_markerRotatingFixed) = createMarkerLocal [MARKERNAME_MAPTOOL_FIXED, GVAR(mapTool_pos)];
2015-01-15 09:51:18 +00:00
MARKERNAME_MAPTOOL_FIXED setMarkerType MARKERNAME_MAPTOOL_FIXED;
};
2015-01-16 08:13:29 +00:00
if ((isNil QGVAR(mapTool_markerRotatingNormal)) && {GVAR(mapTool_Shown) == 1}) then {
2015-01-15 21:50:48 +00:00
GVAR(mapTool_markerRotatingNormal) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGNORMAL, GVAR(mapTool_pos)];
2015-01-15 09:51:18 +00:00
MARKERNAME_MAPTOOL_ROTATINGNORMAL setMarkerType MARKERNAME_MAPTOOL_ROTATINGNORMAL;
};
2015-01-16 08:13:29 +00:00
if ((isNil QGVAR(mapTool_markerRotatingSmall)) && {GVAR(mapTool_Shown) == 2}) then {
2015-01-15 21:50:48 +00:00
GVAR(mapTool_markerRotatingSmall) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGSMALL, GVAR(mapTool_pos)];
2015-01-15 09:51:18 +00:00
MARKERNAME_MAPTOOL_ROTATINGSMALL setMarkerType MARKERNAME_MAPTOOL_ROTATINGSMALL;
};
2015-01-16 04:30:04 +00:00
_rotatingMarker = [MARKERNAME_MAPTOOL_ROTATINGNORMAL, MARKERNAME_MAPTOOL_ROTATINGSMALL] select (GVAR(mapTool_Shown) - 1);
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);
2015-01-15 09:51:18 +00:00
// Update scale of both parts
2015-01-15 21:50:48 +00:00
_scale = _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
2015-01-15 09:51:18 +00:00
MARKERNAME_MAPTOOL_FIXED setMarkerSizeLocal [_scale,_scale];
_rotatingMarker setMarkerSizeLocal [_scale,_scale];
// Position of the fixed part
2015-01-15 21:50:48 +00:00
_xPos = GVAR(mapTool_pos) select 0;
_yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
2015-01-15 09:51:18 +00:00
MARKERNAME_MAPTOOL_FIXED setMarkerPosLocal [_xPos,_yPos];
// Position and rotation of the rotating part
2015-01-15 21:50:48 +00:00
_xPos = (GVAR(mapTool_pos) select 0) + sin(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
_yPos = (GVAR(mapTool_pos) select 1) + cos(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
2015-01-15 09:51:18 +00:00
_rotatingMarker setMarkerPosLocal [_xPos,_yPos];
2015-01-15 21:50:48 +00:00
_rotatingMarker setMarkerDirLocal GVAR(mapTool_angle);