Skip to content

Commit

Permalink
MicroDAGR - Select newly created WP in List (#10457)
Browse files Browse the repository at this point in the history
Co-authored-by: Fratee <elia.frate@gmail.com>
  • Loading branch information
mrschick and Fratee authored Nov 2, 2024
1 parent ff30851 commit ff05b9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions addons/microdagr/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ GVAR(settingShowAllWaypointsOnMap) = true;
GVAR(newWaypointPosition) = [];
GVAR(currentWaypoint) = -1;
GVAR(rangeFinderPositionASL) = [];
GVAR(prevWaypointsCount) = 0;

GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(common,MGRS_data) select 0, EGVAR(common,MGRS_data) select 1];
4 changes: 2 additions & 2 deletions addons/microdagr/functions/fnc_saveCurrentAndSetNewMode.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private _display = uiNamespace getVariable [[QGVAR(RscTitleDisplay), QGVAR(Dialo

if (isNull _display) exitWith {LOG("No Display");};

if (GVAR(currentApplicationPage) == 2) then {
if (GVAR(currentApplicationPage) == APP_MODE_MAP) then {
private _theMap = [_display displayCtrl IDC_MAPDETAILS, _display displayCtrl IDC_MAPPLAIN] select (!GVAR(mapShowTexture));
private _mapCtrlPos = ctrlPosition _theMap;

Expand All @@ -32,7 +32,7 @@ if (GVAR(currentApplicationPage) == 2) then {
GVAR(mapZoom) = (ctrlMapScale _theMap) * _mapSize;

//Hit button again, toggle map modes:
if (_newMode == 2) then {
if (_newMode == APP_MODE_MAP) then {
if (GVAR(mapShowTexture)) then {
GVAR(mapShowTexture) = false;
} else {
Expand Down
9 changes: 8 additions & 1 deletion addons/microdagr/functions/fnc_updateDisplay.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,20 @@ case (APP_MODE_WAYPOINTS): {
_wpListBox lbSetTextRight [_forEachIndex, (format ["%1km", _2dDistanceKm toFixed GVAR(waypointPrecision)])];
} forEach _waypoints;

_currentIndex = (_currentIndex max 0) min ((count _waypoints) - 1);
// Select last created waypoint
private _currWaypointsCount = count _waypoints;
if (_currWaypointsCount > (GVAR(prevWaypointsCount))) then {
_currentIndex = _currWaypointsCount - 1;
} else {
_currentIndex = (_currentIndex max 0) min (_currWaypointsCount - 1);
};
if ((lbCurSel _wpListBox) != _currentIndex) then {
_wpListBox lbSetCurSel _currentIndex;
};

//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);
GVAR(prevWaypointsCount) = _currWaypointsCount;
};

case (APP_MODE_SETUP): {
Expand Down

0 comments on commit ff05b9b

Please sign in to comment.