ACE3/addons/microdagr/functions/fnc_updateDisplay.sqf

198 lines
9.7 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2016-07-14 01:32:30 +00:00
/*
2015-03-09 15:46:59 +00:00
* Author: PabstMirror
2015-03-11 07:06:07 +00:00
* Updates the display (several times a second) called from the pfeh
2015-03-09 15:46:59 +00:00
*
* Arguments:
2015-08-26 03:31:33 +00:00
* None
2015-03-09 15:46:59 +00:00
*
* Return Value:
2015-08-26 03:31:33 +00:00
* None
2015-03-09 15:46:59 +00:00
*
* Example:
2015-03-11 07:06:07 +00:00
* [] call ace_microdagr_fnc_updateDisplay
2015-03-09 15:46:59 +00:00
*
2015-03-11 07:06:07 +00:00
* Public: No
2015-03-09 15:46:59 +00:00
*/
disableSerialization;
private _display = uiNamespace getVariable [[QGVAR(RscTitleDisplay), QGVAR(DialogDisplay)] select (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG), displayNull];
2015-08-26 03:31:33 +00:00
2015-03-09 18:52:15 +00:00
if (isNull _display) exitWith {ERROR("No Display");};
2015-03-09 15:46:59 +00:00
2015-06-21 17:25:16 +00:00
//Fade "shell" at night
private _daylight = [] call EFUNC(common,ambientBrightness);
2015-06-21 17:25:16 +00:00
(_display displayCtrl IDC_MICRODAGRSHELL) ctrlSetTextColor [_daylight, _daylight, _daylight, 1];
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_CLOCKTEXT) ctrlSetText ([daytime, "HH:MM"] call bis_fnc_timeToString);
private _waypoints = [] call FUNC(deviceGetWaypoints);
2015-03-09 18:52:15 +00:00
2015-03-09 15:46:59 +00:00
switch (GVAR(currentApplicationPage)) do {
2015-03-09 18:52:15 +00:00
case (APP_MODE_INFODISPLAY): {
2015-03-09 15:46:59 +00:00
//Easting/Northing:
private _posString = [getPos ACE_player] call EFUNC(common,getMapGridFromPos);
private _eastingText = (_posString select 0) + "e";
private _northingText = (_posString select 1) + "n";
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODEDISPLAY_EASTING) ctrlSetText _eastingText;
(_display displayCtrl IDC_MODEDISPLAY_NORTHING) ctrlSetText _northingText;
//Elevation:
private _numASL = ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude);
private _aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber;
2015-03-09 15:46:59 +00:00
_aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"};
(_display displayCtrl IDC_MODEDISPLAY_ELEVATIONNUM) ctrlSetText _aboveSeaLevelText;
//Heading:
2015-03-11 02:48:57 +00:00
_compassAngleText = if (GVAR(settingUseMils)) then {
2016-03-08 18:21:28 +00:00
[(floor ((6400 / 360) * (([ACE_player] call CBA_fnc_headDir) select 0))), 4, 0] call CBA_fnc_formatNumber;
2015-03-11 02:48:57 +00:00
} else {
2016-07-14 01:32:30 +00:00
([([ACE_player] call CBA_fnc_headDir) select 0, 3, 1] call CBA_fnc_formatNumber) + "°" //degree symbol is in UTF-8
2015-03-11 02:48:57 +00:00
};
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODEDISPLAY_HEADINGNUM) ctrlSetText _compassAngleText;
//Speed:
2015-08-26 03:31:33 +00:00
(_display displayCtrl IDC_MODEDISPLAY_SPEEDNUM) ctrlSetText format ["%1kph", (round (speed (vehicle ACE_player)))];;
2015-03-09 15:46:59 +00:00
if (GVAR(currentWaypoint) == -1) then {
private _yearString = (date select 0);
private _monthSring = localize (["error","str_january","str_february","str_march","str_april","str_may","str_june","str_july","str_august","str_september","str_october","str_november","str_december"] select (date select 1));
private _dayString = if ((date select 2) < 10) then {"0" + str (date select 2)} else {str (date select 2)};
2015-03-12 17:28:52 +00:00
(_display displayCtrl IDC_MODEDISPLAY_TIMEDISPLAYGREEN1) ctrlSetText format ["%1-%2-%3", _yearString, _monthSring, _dayString]; //"18-Feb-2010";
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODEDISPLAY_TIMEDISPLAYGREEN2) ctrlSetText ([daytime, "HH:MM:SS"] call bis_fnc_timeToString);
} else {
private _targetPosName = "";
private _targetPosLocationASL = [];
2015-03-09 15:46:59 +00:00
_bearingText = "----";
_rangeText = "----";
_aboveSeaLevelText = "----";
if (GVAR(currentWaypoint) == -2) then {
if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then {
private _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos);
_targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1];
2015-03-09 15:46:59 +00:00
_targetPosLocationASL = GVAR(rangeFinderPositionASL);
};
} else {
2015-03-09 18:52:15 +00:00
if (GVAR(currentWaypoint) > ((count _waypoints) - 1)) exitWith {ERROR("bounds");};
_targetPosName = (_waypoints select GVAR(currentWaypoint)) select 0;
_targetPosLocationASL = (_waypoints select GVAR(currentWaypoint)) select 1;
2015-03-09 15:46:59 +00:00
};
if (!(_targetPosLocationASL isEqualTo [])) then {
private _bearing = [(getPosASL ACE_player), _targetPosLocationASL] call BIS_fnc_dirTo;
2015-03-11 02:48:57 +00:00
_bearingText = if (GVAR(settingUseMils)) then {
[(floor ((6400 / 360) * (_bearing))), 4, 0] call CBA_fnc_formatNumber;
} else {
2016-07-14 01:32:30 +00:00
([_bearing, 3, 1] call CBA_fnc_formatNumber) + "°" //degree symbol is in UTF-8
2015-03-11 02:48:57 +00:00
};
private _2dDistanceKm = ((getPosASL ACE_player) distance2D _targetPosLocationASL) / 1000;
_rangeText = format ["%1km", _2dDistanceKm toFixed 3];
private _numASL = (_targetPosLocationASL select 2) + EGVAR(common,mapAltitude);
2015-03-09 15:46:59 +00:00
_aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber;
_aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"};
};
(_display displayCtrl IDC_MODEDISPLAY_TRACKNUM) ctrlSetText _bearingText;
(_display displayCtrl IDC_MODEDISPLAY_TARGETRANGENUM) ctrlSetText _rangeText;
(_display displayCtrl IDC_MODEDISPLAY_TARGETELEVATIONNUM) ctrlSetText _aboveSeaLevelText;
(_display displayCtrl IDC_MODEDISPLAY_TARGETNAME) ctrlSetText _targetPosName;
};
};
2015-03-09 18:52:15 +00:00
case (APP_MODE_COMPASS): {
2015-03-09 15:46:59 +00:00
//Heading:
private _compassAngleText = if (GVAR(settingUseMils)) then {
2016-03-08 18:21:28 +00:00
[(floor ((6400 / 360) * (([ACE_player] call CBA_fnc_headDir) select 0))), 4, 0] call CBA_fnc_formatNumber;
2015-03-11 02:48:57 +00:00
} else {
2016-07-14 01:32:30 +00:00
([([ACE_player] call CBA_fnc_headDir) select 0, 3, 1] call CBA_fnc_formatNumber) + "°" //degree symbol is in UTF-8
2015-03-11 02:48:57 +00:00
};
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODECOMPASS_HEADING) ctrlSetText _compassAngleText;
//Speed:
private _SpeedText = format ["%1kph", (round (speed (vehicle ACE_player)))];;
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODECOMPASS_SPEED) ctrlSetText _SpeedText;
if (GVAR(currentWaypoint) == -1) then {
(_display displayCtrl IDC_MODECOMPASS_BEARING) ctrlSetText "";
(_display displayCtrl IDC_MODECOMPASS_RANGE) ctrlSetText "";
(_display displayCtrl IDC_MODECOMPASS_TARGET) ctrlSetText "";
} else {
private _targetPosName = "";
private _targetPosLocationASL = [];
2015-03-09 15:46:59 +00:00
if (GVAR(currentWaypoint) == -2) then {
if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then {
private _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos);
_targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1];
2015-03-09 15:46:59 +00:00
_targetPosLocationASL = GVAR(rangeFinderPositionASL);
};
} else {
2015-03-09 18:52:15 +00:00
if (GVAR(currentWaypoint) > ((count _waypoints - 1))) exitWith {ERROR("bounds");};
_targetPosName = (_waypoints select GVAR(currentWaypoint)) select 0;
_targetPosLocationASL = (_waypoints select GVAR(currentWaypoint)) select 1;
2015-03-09 15:46:59 +00:00
};
_bearingText = "---";
2015-03-09 15:46:59 +00:00
_rangeText = "---";
if (!(_targetPosLocationASL isEqualTo [])) then {
private _bearing = [(getPosASL ACE_player), _targetPosLocationASL] call BIS_fnc_dirTo;
2015-03-11 02:48:57 +00:00
_bearingText = if (GVAR(settingUseMils)) then {
[(floor ((6400 / 360) * (_bearing))), 4, 0] call CBA_fnc_formatNumber;
} else {
2016-07-14 01:32:30 +00:00
([_bearing, 3, 1] call CBA_fnc_formatNumber) + "°" //degree symbol is in UTF-8
2015-03-11 02:48:57 +00:00
};
private _2dDistanceKm = ((getPosASL ACE_player) distance2D _targetPosLocationASL) / 1000;
_rangeText = format ["%1km", _2dDistanceKm toFixed 3];
2015-03-09 15:46:59 +00:00
};
2015-03-11 02:48:57 +00:00
(_display displayCtrl IDC_MODECOMPASS_BEARING) ctrlSetText _bearingText;
2015-03-09 15:46:59 +00:00
(_display displayCtrl IDC_MODECOMPASS_RANGE) ctrlSetText _rangeText;
(_display displayCtrl IDC_MODECOMPASS_TARGET) ctrlSetText _targetPosName;
};
};
case (APP_MODE_WAYPOINTS): {
private _wpListBox = _display displayCtrl IDC_MODEWAYPOINTS_LISTOFWAYPOINTS;
private _currentIndex = lbCurSel _wpListBox;
2015-03-11 02:48:57 +00:00
2015-03-09 15:46:59 +00:00
lbClear _wpListBox;
{
2015-08-26 16:00:59 +00:00
_x params ["_wpName", "_wpPos"];
2015-03-09 15:46:59 +00:00
_wpListBox lbAdd _wpName;
private _2dDistanceKm = ((getPosASL ACE_player) distance2D _wpPos) / 1000;
_wpListBox lbSetTextRight [_forEachIndex, (format ["%1km", _2dDistanceKm toFixed 3])];
2015-03-09 18:52:15 +00:00
} forEach _waypoints;
2015-03-09 15:46:59 +00:00
2015-03-09 18:52:15 +00:00
_currentIndex = (_currentIndex max 0) min (count _waypoints);
2015-03-09 15:46:59 +00:00
_wpListBox lbSetCurSel _currentIndex;
2016-03-08 18:21:28 +00:00
//Reset focus to a dummy ctrl (top button), otherwise HOME/POS1 key goes to top of listBox and has keybind blocked
ctrlSetFocus (_display displayCtrl IDC_TOPMENUBUTTON);
2015-03-09 15:46:59 +00:00
};
2015-03-11 02:48:57 +00:00
case (APP_MODE_SETUP): {
private _settingListBox = _display displayCtrl IDC_MODESETTINGS;
2015-03-11 02:48:57 +00:00
lbClear _settingListBox;
2015-05-28 19:59:04 +00:00
_settingListBox lbAdd (localize LSTRING(settingUseMils));
2015-03-11 02:48:57 +00:00
if (GVAR(settingUseMils)) then {
2015-05-28 19:59:04 +00:00
_settingListBox lbSetTextRight [0, (localize LSTRING(settingMils))];
2015-03-11 02:48:57 +00:00
} else {
2015-05-28 19:59:04 +00:00
_settingListBox lbSetTextRight [0, (localize LSTRING(settingDegrees))];
2015-03-11 02:48:57 +00:00
};
2015-05-28 19:59:04 +00:00
_settingListBox lbAdd (localize LSTRING(settingShowWP));
2015-03-11 02:48:57 +00:00
if (GVAR(settingShowAllWaypointsOnMap)) then {
2015-05-28 19:59:04 +00:00
_settingListBox lbSetTextRight [1, (localize LSTRING(settingOn))];
2015-03-11 02:48:57 +00:00
} else {
2015-05-28 19:59:04 +00:00
_settingListBox lbSetTextRight [1, (localize LSTRING(settingOff))];
2015-03-11 02:48:57 +00:00
};
2016-03-08 18:21:28 +00:00
//Reset focus to a dummy ctrl (top button), otherwise HOME/POS1 key goes to top of listBox and has keybind blocked
ctrlSetFocus (_display displayCtrl IDC_TOPMENUBUTTON);
2015-03-11 02:48:57 +00:00
};
2015-03-09 15:46:59 +00:00
};