ACE3/addons/microdagr/XEH_clientInit.sqf

76 lines
2.6 KiB
Plaintext
Raw Normal View History

2015-03-09 15:46:59 +00:00
//XEH_clientInit.sqf
#include "script_component.hpp"
if (!hasInterface) exitWith {};
//Add Keybinds:
["ACE3", QGVAR(openGPS), (localize "STR_ACE_microdagr_toggleUnit"),
2015-03-09 15:46:59 +00:00
{
// canInteractWith (can use on map)
if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
2015-03-09 15:46:59 +00:00
// Conditions: specific
if (!("ACE_microDAGR" in (items ace_player))) exitWith {false};
[] call FUNC(openDisplay); //toggle display mode
2015-03-09 15:46:59 +00:00
true;
},
{false},
[0xC7, [false, false, false]], false] call cba_fnc_addKeybind; //Home Key
2015-03-11 02:48:57 +00:00
["ACE3", QGVAR(closeGPS), (localize "STR_ACE_microdagr_closeUnit"),
2015-03-09 15:46:59 +00:00
{
// canInteractWith (can use on map)
if !([ACE_player, objNull, ["notOnMap", "isNotInside"]] call EFUNC(common,canInteractWith)) exitWith {false};
2015-03-09 15:46:59 +00:00
// Conditions: specific
if (!("ACE_microDAGR" in (items ace_player))) exitWith {false};
2015-03-11 02:48:57 +00:00
if (GVAR(currentShowMode) == DISPLAY_MODE_CLOSED) exitWith {false};
2015-03-09 15:46:59 +00:00
[DISPLAY_MODE_CLOSED] call FUNC(openDisplay); //close unit
2015-03-09 15:46:59 +00:00
true;
},
{false},
[0xC7, [false, true, false]], false] call cba_fnc_addKeybind; //CTRL + Home Key
//Add Eventhandler:
["RangerfinderData", {_this call FUNC(recieveRangefinderData)}] call EFUNC(common,addEventHandler);
//Global Variables to default:
2015-03-11 07:06:07 +00:00
GVAR(gpsPositionASL) = [0,0,0];
2015-03-09 15:46:59 +00:00
GVAR(mapAutoTrackPosition) = true;
GVAR(mapShowTexture) = false;
GVAR(mapPosition) = [-999, -999];
GVAR(mapZoom) = 0.075;
GVAR(currentApplicationPage) = APP_MODE_NULL;
GVAR(currentShowMode) = DISPLAY_MODE_CLOSED;
2015-03-11 02:48:57 +00:00
//User Settings
GVAR(settingUseMils) = false;
GVAR(settingShowAllWaypointsOnMap) = true;
2015-03-09 15:46:59 +00:00
GVAR(newWaypointPosition) = [];
GVAR(currentWaypoint) = -1;
GVAR(rangeFinderPositionASL) = [];
2015-03-09 18:52:15 +00:00
2015-03-09 15:46:59 +00:00
GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset");
2015-04-17 20:45:00 +00:00
private ["_worldMapLong", "_worldMapLat", "_zone", "_band", "_squareID"];
2015-03-09 15:46:59 +00:00
//Calculate the map's MGRS:
_worldMapLong = getNumber (configFile >> "CfgWorlds" >> worldName >> "longitude");
_worldMapLat = getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude");
//Pull UTM grid from world's long/lat
_zone = 1 + (floor ((_worldMapLong + 180) / 6));
_band = "Z";
if (_worldMapLat <= -80) then {
_band = "A";
} else {
if (_worldMapLat < 84) then {
_band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_worldMapLat / 8) + 10)), 1];
};
};
//calculating square ID from long/lat is a pain in the ass, just fake it unless someone wants to actualy do this
_squareID = if ((count worldName) > 2) then {toUpper(worldName select [0,2])} else {"XG"};
GVAR(mgrsGridZoneDesignator) = format ["%1%2 %3", _zone, _band, _squareID];