ACE3/addons/maptools/functions/fnc_updateMapToolMarkers.sqf

57 lines
2.0 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
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
*
2016-06-18 09:50:41 +00:00
* Return Value:
* None
*
* Example:
* [CONTROL] call ACE_maptools_fnc_updateMapToolMarkers
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
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 (ACE_player call EFUNC(common,uniqueItems)))}) exitWith {};
2015-04-17 23:13:09 +00:00
// open map tools in center of screen when toggled to be shown
if (GVAR(mapTool_moveToMouse)) then {
private _mousePosition = _theMap ctrlMapScreenToWorld getMousePosition;
GVAR(mapTool_pos) = _mousePosition;
GVAR(mapTool_moveToMouse) = false; // we only need to do this once after opening the map tool
};
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
};
if (GVAR(freedrawing)) then {[_theMap, _textureWidth] call FUNC(drawLinesOnRoamer);};
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;
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];