airports
vbox
true
3
hbox
1
1
1
0) {
# Airport has one or more frequencies assigned to it.
var freqs = {};
var comms = info.comms();
foreach (var c; comms) {
var f = sprintf("%.3f", c.frequency);
if (freqs[c.ident] == nil) {
freqs[c.ident] = f;
} else {
freqs[c.ident] = freqs[c.ident] ~ " " ~ f;
}
}
foreach (var c; sort(keys(freqs), string.icmp)) {
setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/label", c);
setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/value", freqs[c]);
fcount += 1;
}
}
while (fcount < 13) {
# zero remaining comms channels
setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/label", "");
setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/value", "");
fcount += 1;
}
var longest_runway = 0;
var runways = info.runways;
avail_runways.removeChildren("value");
var runway_keys = sort(keys(runways), string.icmp);
var i = 0;
foreach(var rwy; runway_keys) {
var r = runways[rwy];
longest_runway = math.max(longest_runway, r.length * 3.28);
avail_runways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/label", rwy);
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/length-hdg",
sprintf("%d'/%03d deg", r.length * 3.28, r.heading));
if (r.ils != nil) {
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/ils", sprintf("%.3fMhz", r.ils.frequency / 100));
} else {
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/ils", "");
}
i += 1;
if (i == MAX_RUNWAYS)
break;
}
while (i < MAX_RUNWAYS) {
# zero remaining runway data
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/label", "");
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/length-hdg", "");
setprop("sim/gui/dialogs/airports/selected-airport/runway[" ~ i ~ "]/ils", "");
i += 1;
}
# Update the list of available parking positions
avail_parking = {};
foreach (var park; info.parking()) {
avail_parking[park.name] = 1;
}
setprop("/sim/gui/dialogs/airports/selected-airport/longest-runway", longest_runway);
var airport_pos = geo.Coord.new();
airport_pos.set_latlon(info.lat, info.lon);
var pos = geo.aircraft_position();
var dst = pos.distance_to(airport_pos) / 1852.0;
var crs = pos.course_to(airport_pos);
setprop("/sim/gui/dialogs/airports/selected-airport/distance-nm", dst);
setprop("/sim/gui/dialogs/airports/selected-airport/course-deg", crs);
gui.dialog_update("airports", "runway-list");
}
var listbox = func {
airport_id = pop(split(" ", airportlist.getValue()));
airport_id = substr(airport_id, 1, size(airport_id) - 2); # strip parentheses
update_info();
}
var apply = func {
setprop("/sim/presets/airport-id", airport_id);
setprop("/sim/presets/longitude-deg", -9999);
setprop("/sim/presets/latitude-deg", -9999);
setprop("/sim/presets/altitude-ft", -9999);
setprop("/sim/presets/airspeed-kt", 0);
setprop("/sim/presets/offset-distance-nm", 0);
setprop("/sim/presets/offset-azimuth-deg", 0);
setprop("/sim/presets/glideslope-deg", 0);
setprop("/sim/presets/heading-deg", 0);
if (mode["bestrunway"].getBoolValue()) {
setprop("/sim/presets/runway", "");
setprop("/sim/presets/parkpos", "");
} else if (mode["runway"].getBoolValue()) {
setprop("/sim/presets/runway", getprop("/sim/gui/dialogs/airports/selected-airport/rwy"));
setprop("/sim/presets/parkpos", "");
} else {
setprop("/sim/presets/runway", "");
setprop("/sim/presets/parkpos", getprop("/sim/gui/dialogs/airports/selected-airport/parkpos"));
}
}
canvas.register_callback(update_info); # FIXME: this is a workaround to run dialog-specific code in the canvas block
]]>
fgcommand("clear-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar",
"station": airport_id}));
map.cleanup_listeners(); #TODO: We should be setting a signal when closing the dialog, so that cleanup code can be invoked automatically
hbox
4
fill
vbox
top
hbox
4
input
120
fill
true
/sim/gui/dialogs/airports/list
dialog-apply
input
dialog-update
airport-list
table
0
0
0
/sim/gui/dialogs/airports/mode
100nm
close-airport-list
260
260
fill
fill
true
/sim/gui/dialogs/airports/list
/sim/gui/dialogs/airports/close-airports
dialog-apply
close-airport-list
nasal
0
0
/sim/gui/dialogs/airports/mode
search
airport-list
260
220
fill
fill
true
/sim/gui/dialogs/airports/list
dialog-apply
airport-list
nasal
hbox
fill
1
metar
fill
true
260
70
15
false
true
true
/sim/gui/dialogs/airports/selected-airport/metar/data
vbox
top
hbox
fill
0
0
2
1
table
center
2
0
/sim/gui/dialogs/airports/use_best_runway
true
nasal
2
1
right
/sim/gui/dialogs/airports/use_best_runway
2
2
right
/sim/gui/dialogs/airports/use_best_runway
3
0
/sim/gui/dialogs/airports/use_runway
true
nasal
3
1
right
/sim/gui/dialogs/airports/use_runway
runway-list
3
2
85
left
/sim/gui/dialogs/airports/use_runway
/sim/gui/dialogs/airports/selected-airport/rwy
false
sim/gui/dialogs/airports/available-runways
dialog-apply
runway-list
4
0
/sim/gui/dialogs/airports/use_parkpos
true
nasal
4
1
right
/sim/gui/dialogs/airports/use_parkpos
4
2
parking-list
120
fill
true
/sim/gui/dialogs/airports/selected-airport/parkpos
dialog-apply
parking-list
nasal
dialog-update
parking-list-valid
5
1
2
parking-list-valid
left
/sim/gui/dialogs/airports/selected-airport/parkpos-invalid
vbox
fill
top
0
hbox
left
2
table
fill
fill
0
vbox
top
0
0
/sim/gui/dialogs/airports/display-mode
1
vbox
hbox
fill
0
1
canvas-control
hbox
table
top
0
0
/sim/gui/dialogs/airports/display-mode
0
0
0
table
top
hbox
fill
0
0
2
1
1
0
right
1
1
left
true
/sim/gui/dialogs/airports/selected-airport/name
2
0
right
2
1
left
true
/sim/gui/dialogs/airports/selected-airport/id
3
0
right
3
1
left
true
/sim/gui/dialogs/airports/selected-airport/location
4
0
right
4
1
left
true
%.0f ft
/sim/gui/dialogs/airports/selected-airport/elevation-ft
5
0
right
5
1
left
true
%.0f ft
/sim/gui/dialogs/airports/selected-airport/longest-runway
6
0
right
6
1
left
true
%.1f nm
/sim/gui/dialogs/airports/selected-airport/distance-nm
7
0
right
7
1
left
true
%.0f deg
/sim/gui/dialogs/airports/selected-airport/course-deg
0
1
table
fill
2
hbox
fill
0
0
2
1
1
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[0]/label
1
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[0]/value
2
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[1]/label
2
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[1]/value
3
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[2]/label
3
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[2]/value
4
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[3]/label
4
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[3]/value
5
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[4]/label
5
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[4]/value
6
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[5]/label
6
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[5]/value
7
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[6]/label
7
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[6]/value
8
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[7]/label
8
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[7]/value
9
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[8]/label
9
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[8]/value
10
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[9]/label
10
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[9]/value
11
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[10]/label
11
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[10]/value
12
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[11]/label
12
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[11]/value
13
0
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[12]/label
13
1
left
true
/sim/gui/dialogs/airports/selected-airport/comms/freq[12]/value
1
0
2
table
fill
2
hbox
fill
0
0
4
1
1
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[0]/label
1
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[0]/length-hdg
1
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[0]/ils
2
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[1]/label
2
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[1]/length-hdg
2
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[1]/ils
3
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[2]/label
3
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[2]/length-hdg
3
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[2]/ils
4
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[3]/label
4
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[3]/length-hdg
4
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[3]/ils
5
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[4]/label
5
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[4]/length-hdg
5
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[4]/ils
6
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[5]/label
6
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[5]/length-hdg
6
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[5]/ils
7
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[6]/label
7
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[6]/length-hdg
7
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[6]/ils
8
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[7]/label
8
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[7]/length-hdg
8
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[7]/ils
9
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[8]/label
9
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[8]/length-hdg
9
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[8]/ils
10
0
left
true
/sim/gui/dialogs/airports/selected-airport/runway[9]/label
10
1
left
true
/sim/gui/dialogs/airports/selected-airport/runway[9]/length-hdg
10
2
left
true
/sim/gui/dialogs/airports/selected-airport/runway[9]/ils
hbox
5
true
true
true