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.setValue("");
input.setValue("");
var list = cmdarg().getNode("list");
var cmd = routem.getNode("input", 1);
var route = routem.getNode("route", 1);
var sel_index = func {
var s = selection.getValue();
selection.setValue("");
return s == "" ? -1 : split(':', s)[0] - 1;
}
var clear = func {
cmd.setValue("@clear");
}
var insert = func {
cmd.setValue("@insert" ~ sel_index() ~ ":" ~ input.getValue());
input.setValue("");
}
var remove = func {
var pos = sel_index();
cmd.setValue("@delete" ~ (pos > 0 ? pos : 0));
}
var load = func {
file_selector.open();
}
var route_changed = func {
list.removeChildren("value");
var wp = route.getChildren("wp");
forindex (var i; wp) {
var id = wp[i].getNode("id").getValue();
var lon = wp[i].getNode("longitude-deg").getValue();
var lat = wp[i].getNode("latitude-deg").getValue();
var alt = wp[i].getNode("altitude-m").getValue();
var entry = sprintf("%d: %-5s %3.4f lon %3.4f lat ",
i + 1, id, lon, lat);
if (alt > -9990) {
if (ft) {
entry ~= sprintf("%.0f ft", alt / 0.3048);
} else {
entry ~= sprintf("%.0f m", alt);
}
}
list.getChild("value", i, 1).setValue(entry);
}
fgcommand("dialog-update", props.Node.new({"object-name": "list",
"dialog-name": "route-manager"}));
}
var lst = setlistener("/autopilot/route-manager/route/num", route_changed, 1);
var load_route = func(path) {
routem.getNode("file-path", 1).setValue(path.getValue());
cmd.setValue("@load");
gui.dialog_update("route-manager");
}
var file_selector = gui.FileSelector.new(load_route, "Load flight-plan", "Load");
var activate_fp = func {
cmd.setValue("@activate");
}
var departureRunways = dlg.getNode("departure-runways", 1);
var destRunways = dlg.getNode("destination-runways", 1);
var updateRunways = func {
gui.dialog_apply("route-manager", "departure-airport");
gui.dialog_apply("route-manager", "destination-airport");
var depIcao = routem.getNode("departure").getNode("airport").getValue();
departureRunways.removeChildren("value");
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;
}
}
var destIcao = routem.getNode("destination").getNode("airport").getValue();
destRunways.removeChildren("value");
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;
}
}
gui.dialog_update("route-manager");
}
removelistener(lst);
file_selector.del();
hbox
1
1
hbox
80
departure-airport
60
/autopilot/route-manager/departure/airport
%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
hbox
80
destination-airport
60
/autopilot/route-manager/destination/airport
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
hbox
80
alt-airport
fill
true
150
/autopilot/route-manager/alternate/airport
hbox
80
cruise-speed
fill
true
150
/autopilot/route-manager/cruise/speed-kts
80
cruise-alt
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