ACE3/addons/dagr/functions/fnc_outputWP.sqf

95 lines
3.0 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
2015-06-07 15:53:37 +00:00
* Author: Rosuto
* DAGR waypoint output loop
*
* Arguments:
* None
2015-06-07 15:53:37 +00:00
*
* Return Value:
* None
2015-06-07 15:53:37 +00:00
*
* Example:
* call ace_dagr_fnc_outputWP
2015-06-07 15:53:37 +00:00
*
* Public: No
*/
135471 cutRsc ["DAGR_DISPLAY", "plain down"];
2015-06-08 10:57:16 +00:00
#define __display (uiNameSpace getVariable "DAGR_DISPLAY")
2015-06-07 15:53:37 +00:00
2015-06-08 10:57:16 +00:00
#define __gridControl (__display displayCtrl 266851)
#define __speedControl (__display displayCtrl 266858)
#define __elevationControl (__display displayCtrl 266857)
#define __headingControl (__display displayCtrl 266854)
#define __timeControl (__display displayCtrl 266859)
#define __background (__display displayCtrl 266856)
2015-06-07 15:53:37 +00:00
2016-04-08 18:34:50 +00:00
__background ctrlSetText QPATHTOF(UI\dagr_wp.paa);
2015-06-07 15:53:37 +00:00
2015-06-12 16:23:01 +00:00
if (GVAR(outputPFH) != -1) exitWith {};
GVAR(outputPFH) = [{
2015-06-08 10:57:16 +00:00
// Abort Condition
if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith {
2015-06-12 16:23:01 +00:00
GVAR(outputPFH) = -1;
2015-06-08 10:57:16 +00:00
135471 cutText ["", "PLAIN"];
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
2015-08-09 00:33:00 +00:00
2015-06-08 10:57:16 +00:00
// GRID
private _gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos);
2015-08-09 00:33:00 +00:00
_gridArray params ["_gridArrayX","_gridArrayY"];
private _dagrGrid = format ["%1 %2", (_gridArrayX select [0,4]), (_gridArrayY select [0,4])];
2015-06-08 10:57:16 +00:00
// WP Grid
private _xGrid2 = floor (DAGR_WP_INFO / 10000);
private _yGrid2 = DAGR_WP_INFO - _xGrid2 * 10000;
2015-08-09 00:33:00 +00:00
2015-06-08 10:57:16 +00:00
_xCoord2 = switch true do {
case (_xGrid2 >= 1000): { "" + Str(_xGrid2) };
case (_xGrid2 >= 100): { "0" + Str(_xGrid2) };
case (_xGrid2 >= 10): { "00" + Str(_xGrid2) };
default { "000" + Str(_xGrid2) };
};
2015-06-07 15:53:37 +00:00
2015-06-08 10:57:16 +00:00
_yCoord2 = switch true do {
case (_yGrid2 >= 1000): { "" + Str(_yGrid2) };
case (_yGrid2 >= 100): { "0" + Str(_yGrid2) };
case (_yGrid2 >= 10): { "00" + Str(_yGrid2) };
default { "000" + Str(_yGrid2) };
};
2015-08-09 00:33:00 +00:00
2015-06-08 10:57:16 +00:00
_dagrGrid2 = _xCoord2 + " " + _yCoord2;
2015-06-07 15:53:37 +00:00
2015-06-08 10:57:16 +00:00
// Distance
private _WPpos = [_dagrGrid2, true] call EFUNC(common,getMapPosFromGrid);
private _MYpos = [_dagrGrid, true] call EFUNC(common,getMapPosFromGrid);
private _distance = _MYpos distance _WPpos;
2015-06-08 10:57:16 +00:00
_distance = floor (_distance * 10) / 10;
private _dagrDistance = str _distance + "m";
2015-08-09 00:33:00 +00:00
2015-06-08 10:57:16 +00:00
// Heading
private _dagrHeading = floor (if (GVAR(useDegrees)) then {
2015-06-08 10:57:16 +00:00
direction (vehicle ACE_player)
2015-06-07 15:53:37 +00:00
} else {
2015-06-08 10:57:16 +00:00
DEG_TO_MIL(direction (vehicle ACE_player))
});
// WP Heading
private _bearing = floor (if (GVAR(useDegrees)) then {
((_WPpos vectorDiff _MYpos) call CBA_fnc_vectDir)
} else {
DEG_TO_MIL(((_WPpos vectorDiff _MYpos) call CBA_fnc_vectDir))
});
2015-08-09 00:33:00 +00:00
2015-06-08 10:57:16 +00:00
// Output
__gridControl ctrlSetText _dagrGrid;
__speedControl ctrlSetText str _bearing;
__elevationControl ctrlSetText _dagrGrid2;
__headingControl ctrlSetText (if (!GVAR(useDegrees)) then { str _dagrHeading } else { format ["%1°", _dagrHeading] });
__timeControl ctrlSetText _dagrDistance;
2015-08-09 00:33:00 +00:00
}, GVAR(updateInterval), []] call CBA_fnc_addPerFrameHandler;