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
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) == 0}) then {
// 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
};
};
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) != 1}) then {
2015-01-15 21:50:48 +00:00
if (!isNil "GVAR(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
};
};
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) != 2}) then {
2015-01-15 21:50:48 +00:00
if (!isNil "GVAR(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
};
};
if (!("ACE_MapTools" in items player)|| {GVAR(mapToolsShown) == 0}) exitWith {};
// 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-15 21:50:48 +00:00
if ((isNil "GVAR(mapTool_markerRotatingNormal)") && {GVAR(mapToolsShown) == 1}) then {
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-15 21:50:48 +00:00
if ((isNil "GVAR(mapTool_markerRotatingSmall)") && {GVAR(mapToolsShown) == 2}) then {
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;
};
_rotatingMarker = [MARKERNAME_MAPTOOL_ROTATINGNORMAL, MARKERNAME_MAPTOOL_ROTATINGSMALL] select (GVAR(mapToolsShown) - 1);
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapToolsShown) - 1);
// 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);