From 1d6cfbf6b73d215ab147150b926cdbb5018d61e3 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 9 Mar 2015 13:52:15 -0500 Subject: [PATCH] Various Changes --- addons/microdagr/CfgVehicles.hpp | 32 +++++ addons/microdagr/CfgWeapons.hpp | 2 - addons/microdagr/XEH_clientInit.sqf | 4 +- addons/microdagr/XEH_preInit.sqf | 5 + addons/microdagr/config.cpp | 10 ++ .../functions/fnc_appMarkKeypadEntry.sqf | 12 +- .../fnc_appWaypointsButtonDeleteWP.sqf | 15 +-- .../functions/fnc_appWaypointsButtonSetWP.sqf | 5 +- .../functions/fnc_deviceAddWaypoint.sqf | 24 ++++ .../functions/fnc_deviceDeleteWaypoint.sqf | 27 ++++ .../functions/fnc_deviceGetWaypoints.sqf | 20 +++ .../functions/fnc_dialogClosedEH.sqf | 4 +- .../microdagr/functions/fnc_mapOnDrawEH.sqf | 6 +- .../microdagr/functions/fnc_moduleMapFill.sqf | 26 ++++ .../microdagr/functions/fnc_openDisplay.sqf | 117 +++++++++++------- .../fnc_saveCurrentAndSetNewMode.sqf | 28 ++++- .../functions/fnc_showApplicationPage.sqf | 18 +-- .../microdagr/functions/fnc_updateDisplay.sqf | 36 +++--- addons/microdagr/gui.hpp | 21 ++-- addons/microdagr/script_component.hpp | 5 + 20 files changed, 317 insertions(+), 100 deletions(-) create mode 100644 addons/microdagr/CfgVehicles.hpp create mode 100644 addons/microdagr/functions/fnc_deviceAddWaypoint.sqf create mode 100644 addons/microdagr/functions/fnc_deviceDeleteWaypoint.sqf create mode 100644 addons/microdagr/functions/fnc_deviceGetWaypoints.sqf create mode 100644 addons/microdagr/functions/fnc_moduleMapFill.sqf diff --git a/addons/microdagr/CfgVehicles.hpp b/addons/microdagr/CfgVehicles.hpp new file mode 100644 index 0000000000..7b2dcd132f --- /dev/null +++ b/addons/microdagr/CfgVehicles.hpp @@ -0,0 +1,32 @@ +class CfgVehicles { + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits {}; + class ModuleDescription {}; + }; + class GVAR(dagrModule): Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "MicroDAGR Map Fill"; + function = QFUNC(moduleMapFill); + scope = 2; + isGlobal = 1; + // icon = QUOTE(PATHTOF(ui\IconLock_ca.paa)); + functionPriority = 0; + class Arguments { + class MapDataAvailable { + displayName = "MicroDAGR Map Fill"; // Argument label + description = "How much map data is filled on MicroDAGRs "; // Tooltip description + typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" + class values { + class None {name = "Full Satellite + Buildings"; value = MAP_DETAIL_SAT; default = 1;}; + class Side {name = "Topographical + Roads"; value = MAP_DETAIL_TOPOROADS;}; + class Unique {name = "None (Cannot use map view)"; value = MAP_DETAIL_NONE;}; + }; + }; + }; + class ModuleDescription: ModuleDescription { + description = "Controls how muchdata is filled in the microDAGR items. Less data restricts the map view to show less on the minimap.
Source: microDAGR.pbo"; + }; + }; +}; diff --git a/addons/microdagr/CfgWeapons.hpp b/addons/microdagr/CfgWeapons.hpp index 524082c7df..73615ea6b6 100644 --- a/addons/microdagr/CfgWeapons.hpp +++ b/addons/microdagr/CfgWeapons.hpp @@ -8,8 +8,6 @@ class CfgWeapons { displayName = "$STR_ACE_microdagr_itemName"; descriptionShort = "$STR_ACE_microdagr_itemDescription"; picture = QUOTE(PATHTOF(images\microDAGR_item.paa)); - icon = "iconObject_circle"; - mapSize = 0.034; class ItemInfo: InventoryItem_Base_F { mass = 2; }; diff --git a/addons/microdagr/XEH_clientInit.sqf b/addons/microdagr/XEH_clientInit.sqf index cb4b39c151..4e22ce90b0 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -12,6 +12,7 @@ if (!hasInterface) exitWith {}; // Conditions: specific if (!("ACE_microDAGR" in (items ace_player))) exitWith {false}; + systemChat "Toggle Button Press"; [] call FUNC(openDisplay); true; }, @@ -26,6 +27,7 @@ if (!hasInterface) exitWith {}; // Conditions: specific if (!("ACE_microDAGR" in (items ace_player))) exitWith {false}; + systemChat "Close Button Press"; [DISPLAY_MODE_CLOSED] call FUNC(openDisplay); true; }, @@ -46,7 +48,7 @@ GVAR(currentShowMode) = DISPLAY_MODE_CLOSED; GVAR(newWaypointPosition) = []; GVAR(currentWaypoint) = -1; GVAR(rangeFinderPositionASL) = []; -GVAR(waypointList) = [["Alpha Base", [4000, 4000, 69]], ["Bravo Base", [5000, 5000, 0]]]; + GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset"); diff --git a/addons/microdagr/XEH_preInit.sqf b/addons/microdagr/XEH_preInit.sqf index 9f4c068566..9cd95f7602 100644 --- a/addons/microdagr/XEH_preInit.sqf +++ b/addons/microdagr/XEH_preInit.sqf @@ -6,10 +6,15 @@ PREP(appMarkKeypadEntry); PREP(appMenuButtonConnectRangefinder); PREP(appWaypointsButtonDeleteWP); PREP(appWaypointsButtonSetWP); +PREP(canShow); +PREP(deviceAddWaypoint); +PREP(deviceDeleteWaypoint); +PREP(deviceGetWaypoints); PREP(dialogClosedEH); PREP(mapDoubleTapEH); PREP(mapOnDrawEH); PREP(modeMapButtons); +PREP(moduleMapFill); PREP(openDisplay); PREP(recieveRangefinderData); PREP(saveCurrentAndSetNewMode); diff --git a/addons/microdagr/config.cpp b/addons/microdagr/config.cpp index c7b685bc0f..39380d7a2e 100644 --- a/addons/microdagr/config.cpp +++ b/addons/microdagr/config.cpp @@ -7,10 +7,20 @@ class CfgPatches { requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"ace_common"}; author[] = {"PabstMirror"}; + authorUrl = "https://github.com/PabstMirror/"; VERSION_CONFIG; }; }; #include "CfgEventHandlers.hpp" #include "CfgWeapons.hpp" +#include "CfgVehicles.hpp" #include "gui.hpp" + +class ACE_Settings { + class GVAR(MapDataAvailable) { + value = 2; + typeName = "SCALAR"; + isClientSetable = 0; + }; +}; diff --git a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf index 3df54aa780..8adeecf200 100644 --- a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf +++ b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf @@ -20,11 +20,13 @@ PARAMS_1(_keypadButton); disableSerialization; -_display = (uiNamespace getVariable ["testGPS", displayNull]); -if (isNull _display) then { - _display = (uiNamespace getVariable ["testGPS_T", displayNull]); +_display = displayNull; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + _display = (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull]); +} else { + _display = (uiNamespace getVariable [QGVAR(RscTitleDisplay), displayNull]); }; -if (isNull _display) exitWith {}; +if (isNull _display) exitWith {ERROR("No Display");}; if (GVAR(currentApplicationPage) != APP_MODE_MARK) exitWith {}; @@ -37,7 +39,7 @@ case ("ok"): { GVAR(newWaypointPosition) = _actualPos; [APP_MODE_MARK] call FUNC(saveCurrentAndSetNewMode); } else { - GVAR(waypointList) pushBack [_editText, GVAR(newWaypointPosition)]; + [_editText, GVAR(newWaypointPosition)] call FUNC(deviceAddWaypoint); [APP_MODE_WAYPOINTS] call FUNC(saveCurrentAndSetNewMode); }; }; diff --git a/addons/microdagr/functions/fnc_appWaypointsButtonDeleteWP.sqf b/addons/microdagr/functions/fnc_appWaypointsButtonDeleteWP.sqf index bac1ae1a1a..ab24630d81 100644 --- a/addons/microdagr/functions/fnc_appWaypointsButtonDeleteWP.sqf +++ b/addons/microdagr/functions/fnc_appWaypointsButtonDeleteWP.sqf @@ -18,19 +18,20 @@ #include "script_component.hpp" disableSerialization; -_display = (uiNamespace getVariable ["testGPS", displayNull]); -if (isNull _display) then { _display = (uiNamespace getVariable ["testGPS_T", displayNull]);}; -if (isNull _display) exitWith {}; +_display = displayNull; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + _display = (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull]); +} else { + _display = (uiNamespace getVariable [QGVAR(RscTitleDisplay), displayNull]); +}; +if (isNull _display) exitWith {ERROR("No Display");}; _wpIndex = lbCurSel (_display displayCtrl IDC_MODEWAYPOINTS_LISTOFWAYPOINTS); -if ((_wpIndex < 0) || (_wpIndex > ((count GVAR(waypointList)) - 1))) exitWith { - ERROR("out of bounds wp"); -}; //If it's our currentWP then deactivate if (GVAR(currentWaypoint) == _wpIndex) then {GVAR(currentWaypoint) = -1}; //Delete from list: -GVAR(waypointList) deleteAt _wpIndex; +[_wpIndex] call FUNC(deviceDeleteWaypoint); //Update list now: [] call FUNC(updateDisplay); diff --git a/addons/microdagr/functions/fnc_appWaypointsButtonSetWP.sqf b/addons/microdagr/functions/fnc_appWaypointsButtonSetWP.sqf index 17e9562eff..b322c4f7f8 100644 --- a/addons/microdagr/functions/fnc_appWaypointsButtonSetWP.sqf +++ b/addons/microdagr/functions/fnc_appWaypointsButtonSetWP.sqf @@ -21,7 +21,10 @@ disableSerialization; _wpButton = _this select 0; _wpListBox = (ctrlParent _wpButton) displayCtrl 144501; _newWpIndex = lbCurSel _wpListBox; -if ((_newWpIndex < 0) || (_newWpIndex > ((count GVAR(waypointList)) - 1))) exitWith { +_waypoints = [] call FUNC(deviceGetWaypoints); + + +if ((_newWpIndex < 0) || (_newWpIndex > ((count _waypoints) - 1))) exitWith { GVAR(currentWaypoint) = -1; ERROR("out of bounds wp"); }; diff --git a/addons/microdagr/functions/fnc_deviceAddWaypoint.sqf b/addons/microdagr/functions/fnc_deviceAddWaypoint.sqf new file mode 100644 index 0000000000..3548c521fd --- /dev/null +++ b/addons/microdagr/functions/fnc_deviceAddWaypoint.sqf @@ -0,0 +1,24 @@ +/* + * Author: PabstMirror + * Takes some arguments and returns something or other. + * + * Arguments: + * 0: The first argument + * 1: The second argument + * 2: Third Optional Argument + * + * Return Value: + * The return value + * + * Example: + * _bool = ["something", player] call ace_common_fnc_imanexample + * + * Public: Yes + */ +#include "script_component.hpp" + +PARAMS_2(_waypointName,_waypointPosASL); + +_waypoints = ace_player getVariable [QGVAR(waypoints), []]; +_waypoints pushBack [_waypointName, _waypointPosASL]; +ace_player setVariable [QGVAR(waypoints), _waypoints]; diff --git a/addons/microdagr/functions/fnc_deviceDeleteWaypoint.sqf b/addons/microdagr/functions/fnc_deviceDeleteWaypoint.sqf new file mode 100644 index 0000000000..33848820d6 --- /dev/null +++ b/addons/microdagr/functions/fnc_deviceDeleteWaypoint.sqf @@ -0,0 +1,27 @@ +/* + * Author: PabstMirror + * Takes some arguments and returns something or other. + * + * Arguments: + * 0: The first argument + * 1: The second argument + * 2: Third Optional Argument + * + * Return Value: + * The return value + * + * Example: + * _bool = ["something", player] call ace_common_fnc_imanexample + * + * Public: Yes + */ +#include "script_component.hpp" + +PARAMS_1(_wpIndex); + +_waypoints = ace_player getVariable [QGVAR(waypoints), []]; + +if ((_wpIndex < 0) || (_wpIndex > ((count _waypoints) - 1))) exitWith {ERROR("out of bounds wp");}; + +_waypoints deleteAt _wpIndex; +ace_player setVariable [QGVAR(waypoints), _waypoints]; diff --git a/addons/microdagr/functions/fnc_deviceGetWaypoints.sqf b/addons/microdagr/functions/fnc_deviceGetWaypoints.sqf new file mode 100644 index 0000000000..7d2b74abed --- /dev/null +++ b/addons/microdagr/functions/fnc_deviceGetWaypoints.sqf @@ -0,0 +1,20 @@ +/* + * Author: PabstMirror + * Takes some arguments and returns something or other. + * + * Arguments: + * 0: The first argument + * 1: The second argument + * 2: Third Optional Argument + * + * Return Value: + * The return value + * + * Example: + * _bool = ["something", player] call ace_common_fnc_imanexample + * + * Public: Yes + */ +#include "script_component.hpp" + +(ace_player getVariable [QGVAR(waypoints), []]) diff --git a/addons/microdagr/functions/fnc_dialogClosedEH.sqf b/addons/microdagr/functions/fnc_dialogClosedEH.sqf index 5355a9797e..a3c404e56a 100644 --- a/addons/microdagr/functions/fnc_dialogClosedEH.sqf +++ b/addons/microdagr/functions/fnc_dialogClosedEH.sqf @@ -18,7 +18,7 @@ #include "script_component.hpp" systemChat "Debug: dialog closed"; -if (GVAR(currentShowMode) == 2) then { - [-1] call FUNC(saveCurrentAndSetNewMode);; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + [-1] call FUNC(saveCurrentAndSetNewMode); [DISPLAY_MODE_DISPLAY] call FUNC(openDisplay); }; diff --git a/addons/microdagr/functions/fnc_mapOnDrawEH.sqf b/addons/microdagr/functions/fnc_mapOnDrawEH.sqf index c91f18cd2c..e0474e31c9 100644 --- a/addons/microdagr/functions/fnc_mapOnDrawEH.sqf +++ b/addons/microdagr/functions/fnc_mapOnDrawEH.sqf @@ -20,6 +20,8 @@ _theMap = _this select 0; _mapSize = (ctrlPosition _theMap) select 3; +_waypoints = [] call FUNC(deviceGetWaypoints); + if (GVAR(currentApplicationPage) == 1) then { _theMap ctrlMapAnimAdd [0, DUMMY_ZOOM, DUMMY_POS]; ctrlMapAnimCommit _theMap; @@ -34,7 +36,9 @@ if (GVAR(currentApplicationPage) == 1) then { _targetPos = GVAR(rangeFinderPositionASL); }; } else { - _targetPos = (GVAR(waypointList) select GVAR(currentWaypoint)) select 1; + if (GVAR(currentWaypoint) < (count _waypoints)) then { + _targetPos = (_waypoints select GVAR(currentWaypoint)) select 1; + }; }; if ((count _targetPos) == 3) then { _relBearing = [ace_player, _targetPos] call BIS_fnc_relativeDirTo; diff --git a/addons/microdagr/functions/fnc_moduleMapFill.sqf b/addons/microdagr/functions/fnc_moduleMapFill.sqf new file mode 100644 index 0000000000..4a6d33bb19 --- /dev/null +++ b/addons/microdagr/functions/fnc_moduleMapFill.sqf @@ -0,0 +1,26 @@ +/* + * Author: PabstMirror + * Takes some arguments and returns something or other. + * + * Arguments: + * 0:logic + * 1: synced units-not used + * 2: Module Activated + * + * Return Value: + * The return value + * + * Example: + * _bool = ["something", player] call ace_common_fnc_imanexample + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_3(_logic,_syncedUnits,_activated); + +if (!_activated) exitWith {WARNING("Module Placed but not active");}; + +if (isServer) then { + [_logic, QGVAR(MapDataAvailable), "MapDataAvailable"] call EFUNC(common,readSettingFromModule); +}; diff --git a/addons/microdagr/functions/fnc_openDisplay.sqf b/addons/microdagr/functions/fnc_openDisplay.sqf index 1bd0553203..6a64eec129 100644 --- a/addons/microdagr/functions/fnc_openDisplay.sqf +++ b/addons/microdagr/functions/fnc_openDisplay.sqf @@ -17,56 +17,87 @@ */ #include "script_component.hpp" -_this spawn { - _swap = if (GVAR(currentShowMode) == DISPLAY_MODE_DISPLAY) then {DISPLAY_MODE_DIALOG} else {DISPLAY_MODE_DISPLAY}; - DEFAULT_PARAM(0,_newDisplayShowMode,_swap); - GVAR(currentShowMode) = _newDisplayShowMode; +DEFAULT_PARAM(0,_newDisplayShowMode,-1); +_oldShowMode = GVAR(currentShowMode); - systemChat format ["New ShowMode: %1", GVAR(currentShowMode)]; +if (_newDisplayShowMode == -1) then { + if (_oldShowMode in [DISPLAY_MODE_DISPLAY, DISPLAY_MODE_HIDDEN]) then {_newDisplayShowMode = DISPLAY_MODE_DIALOG}; + if (_oldShowMode in [DISPLAY_MODE_DIALOG, DISPLAY_MODE_CLOSED]) then {_newDisplayShowMode = DISPLAY_MODE_DISPLAY}; +}; - disableSerialization; +if ((_newDisplayShowMode == DISPLAY_MODE_DISPLAY) && {!([DISPLAY_MODE_DISPLAY] call FUNC(canShow))}) then {_newDisplayShowMode = DISPLAY_MODE_HIDDEN}; +if ((_newDisplayShowMode == DISPLAY_MODE_DIALOG) && {!([DISPLAY_MODE_DIALOG] call FUNC(canShow))}) then {_newDisplayShowMode = DISPLAY_MODE_HIDDEN}; - //On first-startup - if (GVAR(currentApplicationPage) == APP_MODE_NULL) then { - GVAR(currentApplicationPage) = APP_MODE_MARK; - GVAR(mapPosition) = getPos ace_player; +GVAR(currentShowMode) = _newDisplayShowMode; + +disableSerialization; + +//On first-startup +if (GVAR(currentApplicationPage) == APP_MODE_NULL) then { + GVAR(currentApplicationPage) = APP_MODE_INFO; + GVAR(mapPosition) = getPos ace_player; +}; + +systemChat format ["%1 to %2 from %3", _oldShowMode, GVAR(currentShowMode), _this]; + + +if (GVAR(currentShowMode) in [DISPLAY_MODE_CLOSED, DISPLAY_MODE_HIDDEN]) then { + systemChat "Closing"; + + //If Dialog is open, back it up before closing: + if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then { + [-1] call FUNC(saveCurrentAndSetNewMode); + closeDialog 0; }; - - - _display = displayNull; - if (_newDisplayShowMode == 0) then { - systemChat "Closing"; - if (dialog && {!isNull (uiNamespace getVariable ["testGPS", displayNull])}) then { + + //Close the display: + (QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; +} else { + if (GVAR(currentShowMode) == DISPLAY_MODE_DISPLAY) then { + systemChat "Opening Display"; + //If Dialog is open, back it up before closing: + if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then { [-1] call FUNC(saveCurrentAndSetNewMode); closeDialog 0; }; - ("testGPS_T" call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; + //Open the display: + (QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutRsc [QGVAR(TheRscTitleDisplay), "PLAIN", 0, true]; } else { - if (_newDisplayShowMode == 1) then { - systemChat "Opening Display"; - if (dialog && {!isNull (uiNamespace getVariable ["testGPS", displayNull])}) then { - systemChat "backing up"; - [-1] call FUNC(saveCurrentAndSetNewMode); - closeDialog 0; - }; - ("testGPS_T" call BIS_fnc_rscLayer) cutRsc ["testGPS_T", "PLAIN", 0, true]; - _display = (uiNamespace getVariable ["testGPS_T", displayNull]); - } else { - systemChat "Opening Dialog"; - ("testGPS_T" call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; - createDialog "testGPS"; - _display = (uiNamespace getVariable ["testGPS", displayNull]); - }; - }; - - [] call FUNC(showApplicationPage); - - waitUntil { - if (isNull _display) exitWith {true}; - [] call FUNC(updateDisplay); - GVAR(gpsPositionASL) = getPosAsl player; - GVAR(compassDirection) = getDir player; - sleep 0.1; - false; + systemChat "Opening Dialog"; + //Close the display: + (QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"]; + //Open the dialog: + createDialog QGVAR(TheDialog); }; }; + +[] call FUNC(showApplicationPage); + +if ((_oldShowMode == DISPLAY_MODE_CLOSED) && {GVAR(currentShowMode) != DISPLAY_MODE_CLOSED}) then { + //Start a pfeh to update display and handle hiding display + + [{ + disableSerialization; + PARAMS_2(_args,_pfID); + EXPLODE_1_PVT(_args,_player); + + if ((ace_player != _player) || {!("ACE_microDAGR" in (items ace_player))} || {GVAR(currentShowMode) == DISPLAY_MODE_CLOSED}) then { + GVAR(currentShowMode) = DISPLAY_MODE_CLOSED; + [_pfID] call CBA_fnc_removePerFrameHandler; + } else { + GVAR(gpsPositionASL) = getPosAsl player; + + if (GVAR(currentShowMode) == DISPLAY_MODE_HIDDEN) then { + if ([DISPLAY_MODE_DISPLAY] call FUNC(canShow)) then { + [DISPLAY_MODE_DISPLAY] call FUNC(openDisplay); + }; + } else { + if ([GVAR(currentShowMode)] call FUNC(canShow)) then { + [] call FUNC(updateDisplay); + } else { + [DISPLAY_MODE_HIDDEN] call FUNC(openDisplay); + }; + }; + }; + }, 0.1, [ace_player]] call CBA_fnc_addPerFrameHandler; +}; diff --git a/addons/microdagr/functions/fnc_saveCurrentAndSetNewMode.sqf b/addons/microdagr/functions/fnc_saveCurrentAndSetNewMode.sqf index f5ea35bc21..339e7b42d3 100644 --- a/addons/microdagr/functions/fnc_saveCurrentAndSetNewMode.sqf +++ b/addons/microdagr/functions/fnc_saveCurrentAndSetNewMode.sqf @@ -21,9 +21,13 @@ PARAMS_1(_newMode); systemChat format ["Switching App To %1", _newMode]; disableSerialization; -_display = (uiNamespace getVariable ["testGPS", displayNull]); -if (isNull _display) then { _display = (uiNamespace getVariable ["testGPS_T", displayNull]);}; -if (isNull _display) exitWith {}; +_display = displayNull; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + _display = (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull]); +} else { + _display = (uiNamespace getVariable [QGVAR(RscTitleDisplay), displayNull]); +}; +if (isNull _display) exitWith {ERROR("No Display");}; if (GVAR(currentApplicationPage) == 2) then { _theMap = if (!GVAR(mapShowTexture)) then {_display displayCtrl IDC_MAPPLAIN} else {_display displayCtrl IDC_MAPDETAILS}; @@ -32,12 +36,28 @@ if (GVAR(currentApplicationPage) == 2) then { _centerPos = [((_pos select 0) + (_pos select 2) / 2), ((_pos select 1) + (_pos select 3) / 2)]; GVAR(mapPosition) = _theMap ctrlMapScreenToWorld _centerPos; GVAR(mapZoom) = (ctrlMapScale _theMap) * _mapSize; + //Hit button again, toggle map modes: if (_newMode == 2) then { - GVAR(mapShowTexture) = !GVAR(mapShowTexture); + if (GVAR(mapShowTexture)) then { + GVAR(mapShowTexture) = false; + } else { + if (GVAR(MapDataAvailable) == MAP_DETAIL_SAT) then { + GVAR(mapShowTexture) = true; + }; + }; }; }; + +//Can't switch to map if no map loaded +if (_newMode == APP_MODE_MAP) then { + if (GVAR(MapDataAvailable) == MAP_DETAIL_NONE) then { + _newMode = -1; + }; +}; + if (_newMode != -1) then { GVAR(currentApplicationPage) = _newMode; [] call FUNC(showApplicationPage); }; + diff --git a/addons/microdagr/functions/fnc_showApplicationPage.sqf b/addons/microdagr/functions/fnc_showApplicationPage.sqf index f6d0086481..97b32be0ff 100644 --- a/addons/microdagr/functions/fnc_showApplicationPage.sqf +++ b/addons/microdagr/functions/fnc_showApplicationPage.sqf @@ -18,16 +18,18 @@ #include "script_component.hpp" disableSerialization; -_display = (uiNamespace getVariable ["testGPS", displayNull]); -_isControl = true; -if (isNull _display) then { - _display = (uiNamespace getVariable ["testGPS_T", displayNull]); - _isControl = false; +_display = displayNull; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + _display = (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull]); +} else { + _display = (uiNamespace getVariable [QGVAR(RscTitleDisplay), displayNull]); }; -if (isNull _display) exitWith {}; +if (isNull _display) exitWith {ERROR("No Display");}; -//Fade "shell" at night +systemChat format ["Showing %1 on %2", GVAR(currentApplicationPage), _display]; + +//Fade "shell" at night: TODO: find beter amibent light code _daylight = (1 - cos (daytime * 360/24)) / 2; (_display displayCtrl IDC_MICRODAGRSHELL) ctrlSetTextColor [_daylight, _daylight, _daylight, 1]; @@ -102,6 +104,8 @@ if (GVAR(currentApplicationPage) == APP_MODE_MARK) then { //Mode: Waypoints (_display displayCtrl IDC_MODEWAYPOINTS) ctrlShow (GVAR(currentApplicationPage) == APP_MODE_WAYPOINTS); +systemChat format ["WP %1 on %2", (GVAR(currentApplicationPage) == APP_MODE_WAYPOINTS), _display]; + //Button's pushed: if (GVAR(currentApplicationPage) == 0) then { diff --git a/addons/microdagr/functions/fnc_updateDisplay.sqf b/addons/microdagr/functions/fnc_updateDisplay.sqf index b12ce693a3..7b8f8e6790 100644 --- a/addons/microdagr/functions/fnc_updateDisplay.sqf +++ b/addons/microdagr/functions/fnc_updateDisplay.sqf @@ -18,18 +18,20 @@ #include "script_component.hpp" disableSerialization; -_display = (uiNamespace getVariable ["testGPS", displayNull]); -_isControl = true; -if (isNull _display) then { - _display = (uiNamespace getVariable ["testGPS_T", displayNull]); - _isControl = false; +_display = displayNull; +if (GVAR(currentShowMode) == DISPLAY_MODE_DIALOG) then { + _display = (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull]); +} else { + _display = (uiNamespace getVariable [QGVAR(RscTitleDisplay), displayNull]); }; -if (isNull _display) exitWith {}; +if (isNull _display) exitWith {ERROR("No Display");}; (_display displayCtrl IDC_CLOCKTEXT) ctrlSetText ([daytime, "HH:MM"] call bis_fnc_timeToString); +_waypoints = [] call FUNC(deviceGetWaypoints); + switch (GVAR(currentApplicationPage)) do { -case (0): { +case (APP_MODE_INFODISPLAY): { //Easting/Northing: _posString = mapGridPosition ACE_player; _eastingText = ""; @@ -74,9 +76,9 @@ case (0): { _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { - if (GVAR(currentWaypoint) > ((count GVAR(waypointList) - 1))) exitWith {ERROR("bounds");}; - _targetPosName = (GVAR(waypointList) select GVAR(currentWaypoint)) select 0; - _targetPosLocationASL = (GVAR(waypointList) select GVAR(currentWaypoint)) select 1; + if (GVAR(currentWaypoint) > ((count _waypoints) - 1)) exitWith {ERROR("bounds");}; + _targetPosName = (_waypoints select GVAR(currentWaypoint)) select 0; + _targetPosLocationASL = (_waypoints select GVAR(currentWaypoint)) select 1; }; if (!(_targetPosLocationASL isEqualTo [])) then { @@ -100,7 +102,7 @@ case (0): { //bullshit gps accuracy: EHE: +03.7FOM: 1

}; -case (1): { +case (APP_MODE_COMPASS): { //Heading: _compassAngleText = [(floor (getDir ace_player)), 3, 1] call CBA_fnc_formatNumber; _compassAngleText = _compassAngleText + "°M"; //degree symbol is in UTF-8 @@ -126,9 +128,9 @@ case (1): { _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { - if (GVAR(currentWaypoint) > ((count GVAR(waypointList) - 1))) exitWith {ERROR("bounds");}; - _targetPosName = (GVAR(waypointList) select GVAR(currentWaypoint)) select 0; - _targetPosLocationASL = (GVAR(waypointList) select GVAR(currentWaypoint)) select 1; + if (GVAR(currentWaypoint) > ((count _waypoints - 1))) exitWith {ERROR("bounds");}; + _targetPosName = (_waypoints select GVAR(currentWaypoint)) select 0; + _targetPosLocationASL = (_waypoints select GVAR(currentWaypoint)) select 1; }; _bearing = "---"; @@ -150,16 +152,16 @@ case (1): { case (APP_MODE_WAYPOINTS): { _wpListBox = _display displayCtrl IDC_MODEWAYPOINTS_LISTOFWAYPOINTS; _currentIndex = lbCurSel _wpListBox; - + lbClear _wpListBox; { EXPLODE_2_PVT(_x,_wpName,_wpPos); _wpListBox lbAdd _wpName; _2dDistanceKm = ((GVAR(gpsPositionASL) select [0,2]) distance (_wpPos select [0,2])) / 1000; _wpListBox lbSetTextRight [_forEachIndex, (format ["%1km", ([_2dDistanceKm, 1, 1] call CBA_fnc_formatNumber)])]; - } forEach GVAR(waypointList); + } forEach _waypoints; - _currentIndex = (_currentIndex max 0) min (count GVAR(waypointList)); + _currentIndex = (_currentIndex max 0) min (count _waypoints); _wpListBox lbSetCurSel _currentIndex; }; }; diff --git a/addons/microdagr/gui.hpp b/addons/microdagr/gui.hpp index ec52d4bee8..75e3810ca5 100644 --- a/addons/microdagr/gui.hpp +++ b/addons/microdagr/gui.hpp @@ -6,12 +6,12 @@ class RscActiveText; class RscText; class RscPicture; class RscMapControl { - class hospital; - class church; - class lighthouse; - class power; - class fuelstation; - class transmitter; + class hospital; + class church; + class lighthouse; + class power; + class fuelstation; + class transmitter; }; class RscMapControlEmpty; class RscControlsGroupNoScrollbars; @@ -36,6 +36,7 @@ class GVAR(RscActiveTextPicture): RscActiveText { class GVAR(RscText): RscText { font = "EtelkaMonospacePro"; + //Design note: I think less contrast in font color makes it look more natural and less "eye catching" colorText[] = {0.75,0.75,0.75,1}; }; @@ -45,13 +46,13 @@ class GVAR(RscText): RscText { #define W_PART(num) QUOTE((num) * (safeZoneH / 64)) #define H_PART(num) QUOTE((num) * (safeZoneH / 36)) -class testGPS { +class GVAR(TheDialog) { idd = -1; movingEnable = 1; duration = 9999999; fadein = 0; fadeout = 0; - onLoad = "uiNamespace setVariable ['testGPS', _this select 0];"; //@todo cbaify this + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(DialogDisplay)),_this select 0)];); onUnload = QUOTE([] call FUNC(dialogClosedEH)); #include "gui_controls.hpp" @@ -70,13 +71,13 @@ class testGPS { #define H_PART(num) QUOTE((num) / 25 * PROFILE_H) class RscTitles { - class testGPS_T { + class GVAR(TheRscTitleDisplay) { idd = -1; movingEnable = 1; duration = 9999999; fadein = 0; fadeout = 0; - onLoad = "uiNamespace setVariable ['testGPS_T', _this select 0];"; //@todo cbaify this + onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(RscTitleDisplay)),_this select 0)];); #include "gui_controls.hpp" }; diff --git a/addons/microdagr/script_component.hpp b/addons/microdagr/script_component.hpp index 28b0d33cb0..7c89c7b780 100644 --- a/addons/microdagr/script_component.hpp +++ b/addons/microdagr/script_component.hpp @@ -14,6 +14,10 @@ #define DUMMY_POS [-1,-1] #define DUMMY_ZOOM 0.1 +#define MAP_DETAIL_NONE 0 +#define MAP_DETAIL_TOPOROADS 1 +#define MAP_DETAIL_SAT 2 + #define APP_MODE_NULL -1 #define APP_MODE_INFODISPLAY 0 #define APP_MODE_COMPASS 1 @@ -26,6 +30,7 @@ #define DISPLAY_MODE_CLOSED 0 #define DISPLAY_MODE_DISPLAY 1 #define DISPLAY_MODE_DIALOG 2 +#define DISPLAY_MODE_HIDDEN 3 #define IDC_RANGEFINDERCONNECTEDICON 77700 #define IDC_CLOCKTEXT 77701