diff --git a/gui/dialogs/route-manager.xml b/gui/dialogs/route-manager.xml index f5449f121..f0ad2d1ca 100644 --- a/gui/dialogs/route-manager.xml +++ b/gui/dialogs/route-manager.xml @@ -30,6 +30,8 @@ command interface /autopilot/route-manager/input: var list = cmdarg().getNode("list"); var cmd = routem.getNode("input", 1); var route = routem.getNode("route", 1); + var dep = routem.getNode("departure", 1); + var dest = routem.getNode("destination", 1); var sel_index = func { return int(selection.getValue()); @@ -59,8 +61,8 @@ command interface /autopilot/route-manager/input: cmd.setValue("@delete" ~ sel_index()); } - var auto_route = func { - cmd.setValue(); + var route = func { + cmd.setValue("@route" ~ sel_index()); } var jump_to = func { @@ -88,10 +90,15 @@ command interface /autopilot/route-manager/input: var departureRunways = dlg.getNode("departure-runways", 1); var destRunways = dlg.getNode("destination-runways", 1); - + var sids = dlg.getNode("sids", 1); + var stars = dlg.getNode("stars", 1); + var updateRunways = func { - var depIcao = routem.getNode("departure").getNode("airport").getValue(); + var depIcao = dep.getNode("airport").getValue(); departureRunways.removeChildren("value"); + + var currentRunway = dep.getNode("runway").getValue(); + var foundCurrent = 0; var apt = airportinfo(depIcao); if (apt != nil) { @@ -99,11 +106,20 @@ command interface /autopilot/route-manager/input: foreach (var rwy; keys(apt.runways)) { departureRunways.getNode("value[" ~ i ~ "]", 1).setValue(rwy); i += 1; + if (rwy == currentRunway) { + foundCurrent = 1; + } } } - var destIcao = routem.getNode("destination").getNode("airport").getValue(); + if (!foundCurrent) { + dep.getNode("runway").clearValue(); + } + + var destIcao = dest.getNode("airport").getValue(); destRunways.removeChildren("value"); + currentRunway = dest.getNode("runway").getValue(); + foundCurrent = 0; var apt = airportinfo(destIcao); if (apt != nil) { @@ -111,11 +127,68 @@ command interface /autopilot/route-manager/input: foreach (var rwy; keys(apt.runways)) { destRunways.getNode("value[" ~ i ~ "]", 1).setValue(rwy); i += 1; + if (rwy == currentRunway) { + foundCurrent = 1; + } } } + if (!foundCurrent) { + dest.getNode("runway").clearValue(); + } + + print("updated runways"); gui.dialog_update("route-manager"); } + + var updateSIDs = func { + sids.removeChildren("value"); + var depIcao = dep.getNode("airport").getValue(); + var rwy = dep.getNode("runway").getValue(); + var apt = airportinfo(depIcao); + if (apt == nil or apt.runways[rwy] == nil) { + dep.getNode("sid").clearValue(); + gui.dialog_update("route-manager", "sid"); + return; + } + + sids.getNode("value[0]", 1).setValue("(none)"); + var i=1; + foreach (var s; apt.runways[rwy].sids) { + sids.getNode("value[" ~ i ~ "]", 1).setValue(s); + i += 1; + } + + gui.dialog_update("route-manager", "sid"); + } + + var updateSTARs = func { + stars.removeChildren("value"); + var icao = dest.getNode("airport").getValue(); + var rwy = dest.getNode("runway").getValue(); + var apt = airportinfo(icao); + if (apt == nil or apt.runways[rwy] == nil) { + dest.getNode("star").clearValue(); + gui.dialog_update("route-manager", "star"); + return; + } + + var i=1; + stars.getNode("value[0]", 1).setValue("(none)"); + foreach (var s; apt.runways[rwy].stars) { + stars.getNode("value[" ~ i ~ "]", 1).setValue(s); + i += 1; + } + + gui.dialog_update("route-manager", "star"); + } + + # initialise departure values based on current position + cmd.setValue("@posinit"); + + updateRunways(); + updateSIDs(); + updateSTARs(); @@ -189,6 +262,31 @@ command interface /autopilot/route-manager/input: /autopilot/route-manager/departure/runway false /sim/gui/dialogs/route-manager/departure-runways + + + dialog-apply + departure-runway + + + nasal + + + + + + + + + sid + 100 + /autopilot/route-manager/departure/sid + false + /sim/gui/dialogs/route-manager/sids + + + dialog-apply + sid + @@ -229,6 +327,32 @@ command interface /autopilot/route-manager/input: /autopilot/route-manager/destination/runway false /sim/gui/dialogs/route-manager/destination-runways + + + dialog-apply + destination-runway + + + + nasal + + + + + + + + + star + 100 + /autopilot/route-manager/destination/star + false + /sim/gui/dialogs/route-manager/stars + + + dialog-apply + star +