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 runway_string = "";
var runways = info.runways;
avail_runways.removeChildren("value");
avail_parking.removeChildren("value");
var runway_keys = sort(keys(runways), string.icmp);
var i = 0;
foreach(var rwy; runway_keys) {
runway_string = runway_string ~ rwy ~ " ";
longest_runway = math.max(longest_runway, runways[rwy].length * 3.28);
avail_runways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
i += 1;
}
i = 0;
foreach (var park; info.parking()) {
avail_parking.getNode("value[" ~ i ~ "]", 1).setValue(park.name);
i += 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");
gui.dialog_update("airports", "parking-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
260
fill
fill
true
/sim/gui/dialogs/airports/list
dialog-apply
airport-list
nasal
hbox
fill
1
metar
fill
true
260
60
1
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
/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
parking-list
4
2
85
/sim/gui/dialogs/airports/use_parkpos
/sim/gui/dialogs/airports/selected-airport/parkpos
false
sim/gui/dialogs/airports/available-parking
dialog-apply
parking-list
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
vbox
top
0
0
/sim/gui/dialogs/airports/display-mode
0
vbox
top
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
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
hbox
5
true
true
true