location-in-air
vbox
left
var p = props.globals.getNode("/sim/gui/dialogs/location-in-air/", 1);
if (getprop("/sim/presets/carrier") != nil and getprop("/sim/presets/carrier") != ""){
setprop("/sim/gui/dialogs/location-in-air/carrier-active",1);
setprop("/sim/gui/dialogs/location-in-air/airport",0);
} else {
setprop("/sim/gui/dialogs/location-in-air/carrier-active",0);
setprop("/sim/gui/dialogs/location-in-air/airport",1);
}
var dlg_root = cmdarg();
var mode = {
airport: p.getNode("airport", 1),
lonlat: p.getNode("lonlat", 1),
vor: p.getNode("vor", 1),
ndb: p.getNode("ndb", 1),
fix: p.getNode("fix", 1),
carrier: p.getNode("carrier-active", 1),
};
var set_radio = func(m) {
foreach (var k; keys(mode)) {
mode[k].setBoolValue(m == k);
}
};
var initialized = 0;
foreach (var k; keys(mode)) {
if (mode[k].getType() == "NONE") {
mode[k].setBoolValue(0);
}
initialized += mode[k].getBoolValue();
}
if (!initialized) {
set_radio("airport");
}
var pickNearest = func(type,propname,freqpropname) {
var found = navinfo(type,getprop(propname));
if( found == nil or size(found) == 0 ) {
logrint(LOG_WARN, type, " ", getprop(propname), " NOT found");
setprop(propname, "");
setprop(freqpropname, "");
return;
}
setprop(propname, found[0].id);
setprop(freqpropname, found[0].frequency / 100.0);
}
var populateCarrierCombo = func() {
# Fill the carrier-selection combo box with a list of available carriers
var combo = gui.findElementByName( dlg_root, "carrier-selection" );
var carriers = props.globals.getNode( "/ai/models" );
combo.removeChildren("value");
if (carriers == nil)
return;
foreach (var carrier; carriers.getChildren("carrier")) {
nameNode = carrier.getNode("name");
if(nameNode != nil and nameNode.getValue() != nil)
combo.addChild("value").setValue(nameNode.getValue());
}
};
var populateCarrierPositionCombo = func() {
# Fill the carrier-position-select combo box with the special values for
# final approach and abeam in-air positions, plus any catapults or parking
# positions available.
var combo = gui.findElementByName( dlg_root, "carrier-position-selection" );
var carriers = props.globals.getNode( "/ai/models" );
# Clear the box, as we may have selected a new carrier from the carrier selection
combo.removeChildren("value");
combo.addChild("value").setValue("FLOLS");
combo.addChild("value").setValue("Abeam");
if (carriers == nil)
return;
foreach (var carrier; carriers.getChildren("carrier")) {
if (carrier.getNode("name", 1).getValue() == getprop("/sim/presets/carrier")) {
foreach (var parkpos; carrier.getChildren("parking-pos")) {
combo.addChild("value").setValue(parkpos.getNode("name", 1).getValue());
}
}
}
};
populateCarrierCombo();
populateCarrierPositionCombo();
# just kept for educational purposes :-)
hbox
1
1
table
6
0
1
vbox
true
left
/sim/gui/dialogs/location-in-air/airport
dialog-apply
nasal
left
true
/sim/gui/dialogs/location-in-air/lonlat
dialog-apply
nasal
left
true
/sim/gui/dialogs/location-in-air/vor
dialog-apply
nasal
true
left
/sim/gui/dialogs/location-in-air/ndb
dialog-apply
nasal
true
/sim/gui/dialogs/location-in-air/fix
left
dialog-apply
nasal
true
/sim/gui/dialogs/location-in-air/carrier-active
left
dialog-apply
nasal
table
0
2
/sim/gui/dialogs/location-in-air/airport
0
0
right
0
1
/sim/presets/airport-id
nasal
1
0
right
1
1
/sim/presets/runway
nasal
0
2
table
/sim/gui/dialogs/location-in-air/lonlat
0
0
right
0
1
/sim/presets/longitude-deg
nasal
1
0
right
1
1
/sim/presets/latitude-deg
nasal
0
2
table
/sim/gui/dialogs/location-in-air/vor
0
0
right
0
1
/sim/presets/vor-id
nasal
0
2
table
/sim/gui/dialogs/location-in-air/ndb
0
0
right
0
1
/sim/presets/ndb-id
nasal
0
2
table
/sim/gui/dialogs/location-in-air/fix
0
0
right
0
1
/sim/presets/fix
nasal
0
2
table
/sim/gui/dialogs/location-in-air/carrier-active
0
0
right
carrier-selection
0
1
/sim/presets/carrier
dialog-apply
carrier-selection
nasal
1
0
right
carrier-position-selection
1
1
/sim/presets/carrier-position
dialog-apply
carrier-position-selection
hbox
table
0
0
right
/sim/gui/dialogs/location-in-air/lonlat
0
1
/sim/presets/offset-distance-nm
/sim/gui/dialogs/location-in-air/lonlat
0
2
right
/sim/gui/dialogs/location-in-air/lonlat
0
3
/sim/presets/offset-azimuth-deg
/sim/gui/dialogs/location-in-air/lonlat
1
0
right
1
1
/sim/presets/altitude-ft
1
2
right
1
3
/sim/presets/glideslope-deg
2
0
right
2
1
/sim/presets/airspeed-kt
2
2
right
/sim/gui/dialogs/location-in-air/airport
2
3
/sim/gui/dialogs/location-in-air/airport
/sim/presets/heading-deg
vbox
1
hbox
10