ACE3/addons/maptools/functions/fnc_updateMapToolMarkers.sqf

61 lines
2.0 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
2015-09-01 03:50:01 +00:00
private ["_rotatingTexture", "_textureWidth", "_scaleX", "_scaleY", "_xPos", "_yPos"];
2015-04-17 23:13:09 +00:00
// Show/Hide draw buttons
2015-08-18 21:57:56 +00:00
if ([] call FUNC(canDraw)) then {
2015-08-18 02:51:40 +00:00
{ ((findDisplay 12) displayCtrl _x) ctrlShow true; } forEach GVAR(drawing_controls);
} else {
2015-08-18 02:51:40 +00:00
{ ((findDisplay 12) displayCtrl _x) ctrlShow false; } forEach GVAR(drawing_controls);
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
};
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
2015-04-07 19:38:35 +00:00
_rotatingTexture = "";
_textureWidth = 0;
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"];
_scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
_scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios
2015-01-15 09:51:18 +00:00
// 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-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];