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;
var infoAboutRunways = []; # list of strings for display
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);
var rwyInfo = sprintf("%5s %12d' / %03d deg", rwy, r.length * 3.28,
r.heading);
if (r.ils != nil) {
rwyInfo = sprintf("%s %20.3f Mhz", rwyInfo,
r.ils.frequency / 100);
}
append(infoAboutRunways, rwyInfo);
i += 1;
if (i == MAX_RUNWAYS)
break;
}
var runwayInfoNode = dlg.getNode("selected-airport/runways-info", 1);
runwayInfoNode.setValue(string.join("\n", infoAboutRunways));
fgcommand("dialog-update", props.Node.new({"object-name": "runways-info", "dialog-name": "airports"}));
# 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", "");
setprop("/sim/presets/runway-requested", 0);
} else if (mode["runway"].getBoolValue()) {
setprop("/sim/presets/runway", getprop("/sim/gui/dialogs/airports/selected-airport/rwy"));
setprop("/sim/presets/parkpos", "");
setprop("/sim/presets/runway-requested", 1);
} 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
]]>
hbox
4
fill
vbox
top
hbox
4
input
120
fill
true
/sim/gui/dialogs/airports/list
dialog-apply
input
show-helipads
/sim/gui/dialogs/airports/show-helipads
dialog-apply
show-helipads
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
hbox
left
/sim/gui/dialogs/map-canvas/draw-DME
true
property-toggle
nasal
dialog-apply
left
/sim/gui/dialogs/map-canvas/draw-PARKING
true
dialog-apply
property-toggle
1
zoomdisplay
Zoom %d
/sim/gui/dialogs/airports/zoom-range
true
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
1
1
0
runways-info
runways-info
fill
true
260
250
15
false
false
/sim/gui/dialogs/airports/selected-airport/runways-info
hbox
5
true
true
true