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 = {"AVAILABLE":1}; 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 MAX_RUNWAYS = 28; # number of entries at KEDW var DIALOG = cmdarg(); var listeners = []; ## "prologue" currently required by the canvas-generic-map var dialog_name ="airports"; #TODO: use substr() and cmdarg() to get this dynamically var dialog_property = func(p) return "/sim/gui/dialogs/airports/"~p; #TODO: generalize using cmdarg var DIALOG_CANVAS = gui.findElementByName(DIALOG, "airport-selection"); var displayMode = getprop("/sim/gui/dialogs/airports/display-mode"); if ((displayMode != 0) and (displayMode != 1)) { setprop("/sim/gui/dialogs/airports/display-mode", 0); } var displayTaxiways = getprop("/sim/gui/dialogs/airports/display-taxiways"); if ((displayTaxiways != 0) and (displayTaxiways != 1)) { setprop("/sim/gui/dialogs/airports/display-taxiways", 1); } var displayParking = getprop("/sim/gui/dialogs/airports/display-parking"); if ((displayParking != 0) and (displayParking != 1)) { setprop("/sim/gui/dialogs/airports/display-parking", 0); } var displayTower = getprop("/sim/gui/dialogs/airports/display-tower"); if ((displayTower != 0) and (displayTower != 1)) { setprop("/sim/gui/dialogs/airports/display-tower", 1); } var showHelipads = getprop("/sim/gui/dialogs/airports/show-helipads"); if ((showHelipads != 0) and (showHelipads != 1)) { setprop("/sim/gui/dialogs/airports/show-helipads", 0); } var dlg = props.globals.getNode("/sim/gui/dialogs/airports", 1); var avail_runways = dlg.getNode("available-runways", 1); var avail_parking = {}; # Start with the closest airport var airport_id = airportinfo().id; update_info(open = 1); # Retrieve METAR fgcommand("request-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar", "station": airport_id})); dlg.getNode("list", 1).setValue(""); var airportlist = dlg.getNode("list"); var mode = { runway: dlg.getNode("use_runway", 1), bestrunway: dlg.getNode("use_best_runway", 1), parkpos: dlg.getNode("use_parkpos", 1) }; var set_radio = func(m) { foreach (k; keys(mode)) { mode[k].setBoolValue(m == k); } } var initialized = 0; foreach (k; keys(mode)) { if (mode[k].getType() == "NONE" or initialized) { mode[k].setBoolValue(0); } else { initialized += mode[k].getBoolValue(); } } if (!initialized) { set_radio("bestrunway"); } 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", 9999.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 true vbox top true 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 00 /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 00 /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 20 /sim/gui/dialogs/airports/use_best_runway true nasal 21 right /sim/gui/dialogs/airports/use_best_runway 22 right /sim/gui/dialogs/airports/use_best_runway 30 /sim/gui/dialogs/airports/use_runway true nasal 31 right /sim/gui/dialogs/airports/use_runway runway-list 32 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 40 /sim/gui/dialogs/airports/use_parkpos true nasal 41 right /sim/gui/dialogs/airports/use_parkpos 42 parking-list 120 fill true /sim/gui/dialogs/airports/selected-airport/parkpos dialog-apply parking-list nasal dialog-update parking-list-valid 51 2 parking-list-valid left /sim/gui/dialogs/airports/selected-airport/parkpos-invalid vbox fill top 0 true hbox left 2 table fill fill 0 vbox top 0 0 /sim/gui/dialogs/airports/display-mode 1 vbox hbox fill 0 1 canvas-map fill fill true 600 400 0) { AirportChart.setScreenRange(math.min(range*range_step, 10000)); } else { AirportChart.setScreenRange(math.max(range/range_step, 100)); } setprop("/sim/gui/dialogs/airports/zoom-range", AirportChart.getScreenRange()); }); if ((getprop("/sim/gui/dialogs/airports/selected-airport/lat") != nil) and (getprop("/sim/gui/dialogs/airports/selected-airport/lon") != nil) ) { # If we've got some values from a previous instantiation of the dialog # then use them to display the correct position, consistent with the # rest of the dialog. AirportChart.getController().setPosition( getprop("/sim/gui/dialogs/airports/selected-airport/lat"), getprop("/sim/gui/dialogs/airports/selected-airport/lon")); } ]]> 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