route-manager
vbox
true
var ft = getprop("/sim/startup/units") == "feet";
var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1);
var selection = dlg.getNode("selection", 1);
var input = dlg.getNode("input", 1);
var routem = props.globals.getNode("/autopilot/route-manager", 1);
selection.setIntValue(-1);
input.setValue("");
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());
}
var clear = func {
cmd.setValue("@clear");
}
var insert = func {
var insertIndex = sel_index();
if (insertIndex >= 0) {
# when selection index is valid, insert *after* the waypoint
insertIndex = insertIndex + 1;
}
cmd.setValue("@insert" ~ insertIndex ~ ":" ~ input.getValue());
input.setValue("");
if (insertIndex >= 0) {
selection.setValue(insertIndex);
gui.dialog_update("route-manager");
}
}
var remove = func {
cmd.setValue("@delete" ~ sel_index());
}
var route = func {
cmd.setValue("@route" ~ sel_index());
}
var jump_to = func {
cmd.setValue("@jump" ~ sel_index());
}
var load_route = func(path) {
routem.getNode("file-path", 1).setValue(path.getValue());
cmd.setValue("@load");
gui.dialog_update("route-manager");
}
var save_route = func(path) {
routem.getNode("file-path", 1).setValue(path.getValue());
cmd.setValue("@save");
gui.dialog_update("route-manager");
}
var file_selector = gui.FileSelector.new(load_route, "Load flight-plan", "Load");
var save_selector = gui.FileSelector.new(save_route, "Save flight-plan", "Save");
var activate_fp = func {
cmd.setValue("@activate");
}
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 = dep.getNode("airport").getValue();
departureRunways.removeChildren("value");
var currentRunway = dep.getNode("runway").getValue();
var foundCurrent = 0;
var apt = airportinfo(depIcao);
if (apt != nil) {
var i=0;
foreach (var rwy; keys(apt.runways)) {
departureRunways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
i += 1;
if (rwy == currentRunway) {
foundCurrent = 1;
}
}
}
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) {
var i=0;
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();
file_selector.del();
save_selector.del();
hbox
1
1
hbox
80
departure-airport
60
/autopilot/route-manager/departure/airport
true
dialog-apply
departure-airport
nasal
%s
/autopilot/route-manager/departure/name
true
true
fill
departure-runway
60
/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
hbox
80
destination-airport
60
/autopilot/route-manager/destination/airport
true
dialog-apply
destination-airport
nasal
true
%s
/autopilot/route-manager/destination/name
true
fill
destination-runway
60
/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
hbox
80
cruise-speed
true
fill
true
150
/autopilot/route-manager/cruise/speed-kts
80
cruise-alt
true
fill
true
150
/autopilot/route-manager/cruise/altitude-ft
hbox
2
Target: %s
/autopilot/route-manager/wp[0]/id
true
Dist: %.2f nm
/autopilot/route-manager/wp[0]/dist
true
ETA: %s
/autopilot/route-manager/wp[0]/eta
true
list
fill
fill
true
150
/sim/gui/dialogs/route-manager/selection
dialog-apply
list
hbox
4
60
input
fill
true
220
/sim/gui/dialogs/route-manager/input
1
0.5
0.5
0.5
hbox
fill
6
true