ACE3/addons/maptools/functions/fnc_updateMapToolMarkers.sqf

49 lines
1.6 KiB
Plaintext
Raw Normal View History

2015-01-15 09:51:18 +00:00
/*
2015-03-24 04:18:00 +00:00
* Author: esteldunedain
2015-01-15 09:51:18 +00:00
* Update the map tool markers, position, size, rotation and visibility.
*
2015-04-07 19:38:35 +00:00
* Arguments:
* 0: The Map <CONTROL>
2015-01-15 09:51:18 +00:00
*
* Return value:
* Nothing
2015-04-07 20:01:44 +00:00
*
* Public: No
2015-01-15 09:51:18 +00:00
*/
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
2015-08-18 02:51:40 +00:00
params ["_theMap"];
2015-01-15 09:51:18 +00:00
if ((GVAR(mapTool_Shown) == 0) || {!("ACE_MapTools" in items ACE_player)}) exitWith {};
2015-04-17 23:13:09 +00:00
private _rotatingTexture = "";
private _textureWidth = 0;
2015-04-07 19:38:35 +00:00
if (GVAR(mapTool_Shown) == 1) then {
2016-04-08 18:34:50 +00:00
_rotatingTexture = QPATHTOF(data\mapToolRotatingNormal.paa);
2015-04-07 19:38:35 +00:00
_textureWidth = TEXTURE_WIDTH_IN_M;
} else {
2016-04-08 18:34:50 +00:00
_rotatingTexture = QPATHTOF(data\mapToolRotatingSmall.paa);
2015-04-07 19:38:35 +00:00
_textureWidth = TEXTURE_WIDTH_IN_M / 2;
2015-01-15 09:51:18 +00:00
};
// Update scale of both parts
2015-09-01 03:50:01 +00:00
getResolution params ["_resWidth", "_resHeight", "", "", "_aspectRatio"];
private _scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
private _scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios
2015-01-15 09:51:18 +00:00
// Position of the fixed part
private _xPos = GVAR(mapTool_pos) select 0;
private _yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
2015-04-07 19:38:35 +00:00
2016-04-08 18:34:50 +00:00
_theMap drawIcon [QPATHTOF(data\mapToolFixed.paa), [1,1,1,1], [_xPos,_yPos], _scaleX, _scaleY, 0, "", 0];
2015-01-15 09:51:18 +00:00
// 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-04-07 19:38:35 +00:00
2015-09-01 03:50:01 +00:00
_theMap drawIcon [_rotatingTexture, [1,1,1,1], [_xPos,_yPos], _scaleX, _scaleY, GVAR(mapTool_angle), "", 0];