| 1 |
<?xml version="1.0"?> |
| 2 |
<PropertyList> |
| 3 |
<name>location-in-air</name> |
| 4 |
<layout>vbox</layout> |
| 5 |
<halign>left</halign> |
| 6 |
|
| 7 |
<nasal> |
| 8 |
<open> |
| 9 |
var p = props.globals.getNode("/sim/gui/dialogs/location-in-air/", 1); |
| 10 |
|
| 11 |
if (getprop("/sim/presets/carrier") != nil and getprop("/sim/presets/carrier") != ""){ |
| 12 |
setprop("/sim/gui/dialogs/location-in-air/carrier-active",1); |
| 13 |
setprop("/sim/gui/dialogs/location-in-air/airport",0); |
| 14 |
} else { |
| 15 |
setprop("/sim/gui/dialogs/location-in-air/carrier-active",0); |
| 16 |
setprop("/sim/gui/dialogs/location-in-air/airport",1); |
| 17 |
} |
| 18 |
|
| 19 |
var dlg_root = cmdarg(); |
| 20 |
var mode = { |
| 21 |
airport: p.getNode("airport", 1), |
| 22 |
lonlat: p.getNode("lonlat", 1), |
| 23 |
vor: p.getNode("vor", 1), |
| 24 |
ndb: p.getNode("ndb", 1), |
| 25 |
fix: p.getNode("fix", 1), |
| 26 |
carrier: p.getNode("carrier-active", 1), |
| 27 |
}; |
| 28 |
|
| 29 |
var set_radio = func(m) { |
| 30 |
foreach (var k; keys(mode)) { |
| 31 |
mode[k].setBoolValue(m == k); |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
var initialized = 0; |
| 36 |
foreach (var k; keys(mode)) { |
| 37 |
if (mode[k].getType() == "NONE") { |
| 38 |
mode[k].setBoolValue(0); |
| 39 |
} |
| 40 |
initialized += mode[k].getBoolValue(); |
| 41 |
} |
| 42 |
if (!initialized) { |
| 43 |
set_radio("airport"); |
| 44 |
} |
| 45 |
var pickNearest = func(type,propname,freqpropname) { |
| 46 |
|
| 47 |
var found = navinfo(type,getprop(propname)); |
| 48 |
if( found == nil or size(found) == 0 ) { |
| 49 |
logrint(LOG_WARN, type, " ", getprop(propname), " NOT found"); |
| 50 |
setprop(propname, ""); |
| 51 |
setprop(freqpropname, ""); |
| 52 |
return; |
| 53 |
} |
| 54 |
setprop(propname, found[0].id); |
| 55 |
setprop(freqpropname, found[0].frequency / 100.0); |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
var populateCarrierCombo = func() { |
| 60 |
# Fill the carrier-selection combo box with a list of available carriers |
| 61 |
var combo = gui.findElementByName( dlg_root, "carrier-selection" ); |
| 62 |
var carriers = props.globals.getNode( "/ai/models" ); |
| 63 |
|
| 64 |
combo.removeChildren("value"); |
| 65 |
if (carriers == nil) |
| 66 |
return; |
| 67 |
|
| 68 |
foreach (var carrier; carriers.getChildren("carrier")) { |
| 69 |
nameNode = carrier.getNode("name"); |
| 70 |
if(nameNode != nil and nameNode.getValue() != nil) |
| 71 |
combo.addChild("value").setValue(nameNode.getValue()); |
| 72 |
} |
| 73 |
}; |
| 74 |
|
| 75 |
var populateCarrierPositionCombo = func() { |
| 76 |
# Fill the carrier-position-select combo box with the special values for |
| 77 |
# final approach and abeam in-air positions, plus any catapults or parking |
| 78 |
# positions available. |
| 79 |
var combo = gui.findElementByName( dlg_root, "carrier-position-selection" ); |
| 80 |
var carriers = props.globals.getNode( "/ai/models" ); |
| 81 |
|
| 82 |
# Clear the box, as we may have selected a new carrier from the carrier selection |
| 83 |
combo.removeChildren("value"); |
| 84 |
combo.addChild("value").setValue("FLOLS"); |
| 85 |
combo.addChild("value").setValue("Abeam"); |
| 86 |
|
| 87 |
if (carriers == nil) |
| 88 |
return; |
| 89 |
|
| 90 |
foreach (var carrier; carriers.getChildren("carrier")) { |
| 91 |
if (carrier.getNode("name", 1).getValue() == getprop("/sim/presets/carrier")) { |
| 92 |
foreach (var parkpos; carrier.getChildren("parking-pos")) { |
| 93 |
combo.addChild("value").setValue(parkpos.getNode("name", 1).getValue()); |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
populateCarrierCombo(); |
| 100 |
populateCarrierPositionCombo(); |
| 101 |
|
| 102 |
</open> |
| 103 |
|
| 104 |
<close># just kept for educational purposes :-)</close> |
| 105 |
</nasal> |
| 106 |
|
| 107 |
<group> |
| 108 |
<layout>hbox</layout> |
| 109 |
|
| 110 |
<text> |
| 111 |
<label>Position Aircraft In Air</label> |
| 112 |
</text> |
| 113 |
|
| 114 |
<empty> |
| 115 |
<stretch>1</stretch> |
| 116 |
</empty> |
| 117 |
|
| 118 |
<button> |
| 119 |
<legend>X</legend> |
| 120 |
<key>Esc</key> |
| 121 |
<pref-width>20</pref-width> |
| 122 |
<pref-height>20</pref-height> |
| 123 |
<binding> |
| 124 |
<command>dialog-close</command> |
| 125 |
</binding> |
| 126 |
</button> |
| 127 |
</group> |
| 128 |
|
| 129 |
<hrule /> |
| 130 |
|
| 131 |
<group> |
| 132 |
<layout>table</layout> |
| 133 |
<group> |
| 134 |
<default-padding>6</default-padding> |
| 135 |
<row>0</row> |
| 136 |
<col>1</col> |
| 137 |
<layout>vbox</layout> |
| 138 |
<radio> |
| 139 |
<live>true</live> |
| 140 |
<halign>left</halign> |
| 141 |
<label>Airport:</label> |
| 142 |
<property>/sim/gui/dialogs/location-in-air/airport</property> |
| 143 |
<binding> |
| 144 |
<command>dialog-apply</command> |
| 145 |
</binding> |
| 146 |
<binding> |
| 147 |
<command>nasal</command> |
| 148 |
<script>set_radio("airport")</script> |
| 149 |
</binding> |
| 150 |
</radio> |
| 151 |
|
| 152 |
<radio> |
| 153 |
<label>Position:</label> |
| 154 |
<halign>left</halign> |
| 155 |
<live>true</live> |
| 156 |
<property>/sim/gui/dialogs/location-in-air/lonlat</property> |
| 157 |
<binding> |
| 158 |
<command>dialog-apply</command> |
| 159 |
</binding> |
| 160 |
<binding> |
| 161 |
<command>nasal</command> |
| 162 |
<script>set_radio("lonlat")</script> |
| 163 |
</binding> |
| 164 |
</radio> |
| 165 |
|
| 166 |
<radio> |
| 167 |
<label>VOR:</label> |
| 168 |
<halign>left</halign> |
| 169 |
<live>true</live> |
| 170 |
<property>/sim/gui/dialogs/location-in-air/vor</property> |
| 171 |
<binding> |
| 172 |
<command>dialog-apply</command> |
| 173 |
</binding> |
| 174 |
<binding> |
| 175 |
<command>nasal</command> |
| 176 |
<script>set_radio("vor")</script> |
| 177 |
</binding> |
| 178 |
</radio> |
| 179 |
|
| 180 |
<radio> |
| 181 |
<live>true</live> |
| 182 |
<halign>left</halign> |
| 183 |
<label>NDB:</label> |
| 184 |
|
| 185 |
<property>/sim/gui/dialogs/location-in-air/ndb</property> |
| 186 |
<binding> |
| 187 |
<command>dialog-apply</command> |
| 188 |
</binding> |
| 189 |
<binding> |
| 190 |
<command>nasal</command> |
| 191 |
<script>set_radio("ndb")</script> |
| 192 |
</binding> |
| 193 |
</radio> |
| 194 |
|
| 195 |
|
| 196 |
<radio> |
| 197 |
<label>Fix:</label> |
| 198 |
<live>true</live> |
| 199 |
<property>/sim/gui/dialogs/location-in-air/fix</property> |
| 200 |
<halign>left</halign> |
| 201 |
|
| 202 |
<binding> |
| 203 |
<command>dialog-apply</command> |
| 204 |
</binding> |
| 205 |
<binding> |
| 206 |
<command>nasal</command> |
| 207 |
<script>set_radio("fix")</script> |
| 208 |
</binding> |
| 209 |
</radio> |
| 210 |
|
| 211 |
<radio> |
| 212 |
<live>true</live> |
| 213 |
<label>Aircraft Carrier:</label> |
| 214 |
<property>/sim/gui/dialogs/location-in-air/carrier-active</property> |
| 215 |
<halign>left</halign> |
| 216 |
|
| 217 |
<binding> |
| 218 |
<command>dialog-apply</command> |
| 219 |
</binding> |
| 220 |
<binding> |
| 221 |
<command>nasal</command> |
| 222 |
<script>set_radio("carrier")</script> |
| 223 |
</binding> |
| 224 |
</radio> |
| 225 |
</group> |
| 226 |
<group> |
| 227 |
<layout>table</layout> |
| 228 |
<row>0</row> |
| 229 |
<col>2</col> |
| 230 |
<visible> |
| 231 |
<property>/sim/gui/dialogs/location-in-air/airport</property> |
| 232 |
</visible> |
| 233 |
<text> |
| 234 |
<row>0</row> |
| 235 |
<col>0</col> |
| 236 |
<halign>right</halign> |
| 237 |
<label>Airport:</label> |
| 238 |
</text> |
| 239 |
<input> |
| 240 |
<row>0</row> |
| 241 |
<col>1</col> |
| 242 |
<property>/sim/presets/airport-id</property> |
| 243 |
<binding> |
| 244 |
<command>nasal</command> |
| 245 |
<script>set_radio("airport")</script> |
| 246 |
</binding> |
| 247 |
</input> |
| 248 |
<text> |
| 249 |
<row>1</row> |
| 250 |
<col>0</col> |
| 251 |
<halign>right</halign> |
| 252 |
<label> Runway:</label> |
| 253 |
</text> |
| 254 |
<input> |
| 255 |
<row>1</row> |
| 256 |
<col>1</col> |
| 257 |
<property>/sim/presets/runway</property> |
| 258 |
<binding> |
| 259 |
<command>nasal</command> |
| 260 |
<script>set_radio("airport")</script> |
| 261 |
</binding> |
| 262 |
</input> |
| 263 |
</group> |
| 264 |
|
| 265 |
<group> |
| 266 |
<row>0</row> |
| 267 |
<col>2</col> |
| 268 |
<layout>table</layout> |
| 269 |
<visible> |
| 270 |
<property>/sim/gui/dialogs/location-in-air/lonlat</property> |
| 271 |
</visible> |
| 272 |
<text> |
| 273 |
<row>0</row> |
| 274 |
<col>0</col> |
| 275 |
<halign>right</halign> |
| 276 |
<label>Longitude:</label> |
| 277 |
</text> |
| 278 |
<input> |
| 279 |
<row>0</row> |
| 280 |
<col>1</col> |
| 281 |
<property>/sim/presets/longitude-deg</property> |
| 282 |
<binding> |
| 283 |
<command>nasal</command> |
| 284 |
<script>set_radio("lonlat")</script> |
| 285 |
</binding> |
| 286 |
</input> |
| 287 |
<text> |
| 288 |
<row>1</row> |
| 289 |
<col>0</col> |
| 290 |
<halign>right</halign> |
| 291 |
<label> Latitude:</label> |
| 292 |
</text> |
| 293 |
<input> |
| 294 |
<row>1</row> |
| 295 |
<col>1</col> |
| 296 |
<property>/sim/presets/latitude-deg</property> |
| 297 |
<binding> |
| 298 |
<command>nasal</command> |
| 299 |
<script>set_radio("lonlat")</script> |
| 300 |
</binding> |
| 301 |
</input> |
| 302 |
</group> |
| 303 |
|
| 304 |
<group> |
| 305 |
<row>0</row> |
| 306 |
<col>2</col> |
| 307 |
<layout>table</layout> |
| 308 |
<visible> |
| 309 |
<property>/sim/gui/dialogs/location-in-air/vor</property> |
| 310 |
</visible> |
| 311 |
<text> |
| 312 |
<row>0</row> |
| 313 |
<col>0</col> |
| 314 |
<halign>right</halign> |
| 315 |
<label>VOR:</label> |
| 316 |
</text> |
| 317 |
<input> |
| 318 |
<row>0</row> |
| 319 |
<col>1</col> |
| 320 |
<property>/sim/presets/vor-id</property> |
| 321 |
<binding> |
| 322 |
<command>nasal</command> |
| 323 |
<script>set_radio("vor")</script> |
| 324 |
</binding> |
| 325 |
</input> |
| 326 |
|
| 327 |
</group> |
| 328 |
|
| 329 |
|
| 330 |
<group> |
| 331 |
<row>0</row> |
| 332 |
<col>2</col> |
| 333 |
<layout>table</layout> |
| 334 |
<visible> |
| 335 |
<property>/sim/gui/dialogs/location-in-air/ndb</property> |
| 336 |
</visible> |
| 337 |
<text> |
| 338 |
<row>0</row> |
| 339 |
<col>0</col> |
| 340 |
<halign>right</halign> |
| 341 |
<label>NDB:</label> |
| 342 |
</text> |
| 343 |
<input> |
| 344 |
<row>0</row> |
| 345 |
<col>1</col> |
| 346 |
<property>/sim/presets/ndb-id</property> |
| 347 |
<binding> |
| 348 |
<command>nasal</command> |
| 349 |
<script>set_radio("ndb")</script> |
| 350 |
</binding> |
| 351 |
</input> |
| 352 |
</group> |
| 353 |
|
| 354 |
<group> |
| 355 |
<row>0</row> |
| 356 |
<col>2</col> |
| 357 |
<layout>table</layout> |
| 358 |
<visible> |
| 359 |
<property>/sim/gui/dialogs/location-in-air/fix</property> |
| 360 |
</visible> |
| 361 |
<text> |
| 362 |
<row>0</row> |
| 363 |
<col>0</col> |
| 364 |
<halign>right</halign> |
| 365 |
<label>Fix:</label> |
| 366 |
</text> |
| 367 |
<input> |
| 368 |
<row>0</row> |
| 369 |
<col>1</col> |
| 370 |
<property>/sim/presets/fix</property> |
| 371 |
<binding> |
| 372 |
<command>nasal</command> |
| 373 |
<script>set_radio("fix")</script> |
| 374 |
</binding> |
| 375 |
</input> |
| 376 |
</group> |
| 377 |
|
| 378 |
<group> |
| 379 |
<row>0</row> |
| 380 |
<col>2</col> |
| 381 |
<layout>table</layout> |
| 382 |
<visible> |
| 383 |
<property>/sim/gui/dialogs/location-in-air/carrier-active</property> |
| 384 |
</visible> |
| 385 |
<text> |
| 386 |
<row>0</row> |
| 387 |
<col>0</col> |
| 388 |
<halign>right</halign> |
| 389 |
<label>Carrier:</label> |
| 390 |
</text> |
| 391 |
<combo> |
| 392 |
<name>carrier-selection</name> |
| 393 |
<row>0</row> |
| 394 |
<col>1</col> |
| 395 |
<property>/sim/presets/carrier</property> |
| 396 |
<binding> |
| 397 |
<command>dialog-apply</command> |
| 398 |
<object-name>carrier-selection</object-name> |
| 399 |
</binding> |
| 400 |
<binding> |
| 401 |
<command>nasal</command> |
| 402 |
<script>populateCarrierPositionCombo();</script> |
| 403 |
</binding> |
| 404 |
</combo> |
| 405 |
<text> |
| 406 |
<row>1</row> |
| 407 |
<col>0</col> |
| 408 |
<halign>right</halign> |
| 409 |
<label>Position:</label> |
| 410 |
</text> |
| 411 |
<combo> |
| 412 |
<name>carrier-position-selection</name> |
| 413 |
<row>1</row> |
| 414 |
<col>1</col> |
| 415 |
<property>/sim/presets/carrier-position</property> |
| 416 |
<binding> |
| 417 |
<command>dialog-apply</command> |
| 418 |
<object-name>carrier-position-selection</object-name> |
| 419 |
</binding> |
| 420 |
</combo> |
| 421 |
</group> |
| 422 |
</group> |
| 423 |
|
| 424 |
<hrule/> |
| 425 |
|
| 426 |
<text> |
| 427 |
<label>Relative Position</label> |
| 428 |
</text> |
| 429 |
|
| 430 |
<group> |
| 431 |
<layout>hbox</layout> |
| 432 |
|
| 433 |
<group> |
| 434 |
<layout>table</layout> |
| 435 |
<text> |
| 436 |
<row>0</row><col>0</col> |
| 437 |
<halign>right</halign> |
| 438 |
<label> Distance (nm):</label> |
| 439 |
<enable><not><property>/sim/gui/dialogs/location-in-air/lonlat</property></not></enable> |
| 440 |
</text> |
| 441 |
<input> |
| 442 |
<row>0</row><col>1</col> |
| 443 |
<property>/sim/presets/offset-distance-nm</property> |
| 444 |
<enable><not><property>/sim/gui/dialogs/location-in-air/lonlat</property></not></enable> |
| 445 |
</input> |
| 446 |
|
| 447 |
<text> |
| 448 |
<row>0</row><col>2</col> |
| 449 |
<halign>right</halign> |
| 450 |
<label>Azimuth (deg):</label> |
| 451 |
<enable><not><property>/sim/gui/dialogs/location-in-air/lonlat</property></not></enable> |
| 452 |
</text> |
| 453 |
<input> |
| 454 |
<row>0</row><col>3</col> |
| 455 |
<property>/sim/presets/offset-azimuth-deg</property> |
| 456 |
<enable><not><property>/sim/gui/dialogs/location-in-air/lonlat</property></not></enable> |
| 457 |
</input> |
| 458 |
|
| 459 |
<text> |
| 460 |
<row>1</row><col>0</col> |
| 461 |
<halign>right</halign> |
| 462 |
<label>Altitude (ft):</label> |
| 463 |
</text> |
| 464 |
<input> |
| 465 |
<row>1</row><col>1</col> |
| 466 |
<property>/sim/presets/altitude-ft</property> |
| 467 |
</input> |
| 468 |
|
| 469 |
<text> |
| 470 |
<row>1</row><col>2</col> |
| 471 |
<halign>right</halign> |
| 472 |
<label> Glidepath (deg):</label> |
| 473 |
</text> |
| 474 |
<input> |
| 475 |
<row>1</row><col>3</col> |
| 476 |
<property>/sim/presets/glideslope-deg</property> |
| 477 |
</input> |
| 478 |
|
| 479 |
<text> |
| 480 |
<row>2</row><col>0</col> |
| 481 |
<halign>right</halign> |
| 482 |
<label>Airspeed (kt):</label> |
| 483 |
</text> |
| 484 |
<input> |
| 485 |
<row>2</row><col>1</col> |
| 486 |
<property>/sim/presets/airspeed-kt</property> |
| 487 |
</input> |
| 488 |
|
| 489 |
<text> |
| 490 |
<row>2</row><col>2</col> |
| 491 |
<halign>right</halign> |
| 492 |
<label>Heading (deg):</label> |
| 493 |
<enable><not><property>/sim/gui/dialogs/location-in-air/airport</property></not></enable> |
| 494 |
</text> |
| 495 |
<input> |
| 496 |
<row>2</row><col>3</col> |
| 497 |
<enable><not><property>/sim/gui/dialogs/location-in-air/airport</property></not></enable> |
| 498 |
<property>/sim/presets/heading-deg</property> |
| 499 |
</input> |
| 500 |
</group> |
| 501 |
|
| 502 |
|
| 503 |
<group> |
| 504 |
<layout>vbox</layout> |
| 505 |
<default-padding>1</default-padding> |
| 506 |
<text> |
| 507 |
<label> </label> |
| 508 |
</text> |
| 509 |
</group> |
| 510 |
|
| 511 |
</group> |
| 512 |
|
| 513 |
<hrule/> |
| 514 |
|
| 515 |
<group> |
| 516 |
<layout>hbox</layout> |
| 517 |
<default-padding>10</default-padding> |
| 518 |
|
| 519 |
<button> |
| 520 |
<legend>OK</legend> |
| 521 |
<default>true</default> |
| 522 |
<equal>true</equal> |
| 523 |
<binding> |
| 524 |
<command>dialog-apply</command> |
| 525 |
</binding> |
| 526 |
<binding> |
| 527 |
<command>nasal</command> |
| 528 |
<script> |
| 529 |
|
| 530 |
if (mode.carrier.getBoolValue()) { |
| 531 |
setprop("/sim/presets/airport-id", ""); |
| 532 |
setprop("/sim/presets/runway", ""); |
| 533 |
setprop("/sim/presets/runway-requested", 0); |
| 534 |
} |
| 535 |
else if (!mode.airport.getBoolValue()) { |
| 536 |
setprop("/sim/presets/carrier", ""); |
| 537 |
setprop("/sim/presets/parkpos", ""); |
| 538 |
setprop("/sim/presets/airport-id", ""); |
| 539 |
setprop("/sim/presets/runway", ""); |
| 540 |
setprop("/sim/presets/runway-requested", 0); |
| 541 |
} else { |
| 542 |
setprop("/sim/presets/carrier", ""); |
| 543 |
setprop("/sim/presets/heading-deg", 9999); |
| 544 |
var runway = getprop("/sim/presets/runway"); |
| 545 |
if (runway != "") { |
| 546 |
setprop("/sim/presets/runway-requested", 1); |
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
if (!mode.lonlat.getBoolValue()) { |
| 551 |
setprop("/sim/presets/longitude-deg", -9999); |
| 552 |
setprop("/sim/presets/latitude-deg", -9999); |
| 553 |
} |
| 554 |
|
| 555 |
if (!mode.vor.getBoolValue()) { |
| 556 |
setprop("/sim/presets/vor-id", ""); |
| 557 |
} else { |
| 558 |
pickNearest("vor","/sim/presets/vor-id","/sim/presets/vor-freq"); |
| 559 |
} |
| 560 |
|
| 561 |
if (!mode.ndb.getBoolValue()) { |
| 562 |
setprop("/sim/presets/ndb-id", ""); |
| 563 |
} else { |
| 564 |
pickNearest("ndb","/sim/presets/ndb-id","/sim/presets/ndb-freq"); |
| 565 |
} |
| 566 |
|
| 567 |
if (!mode.fix.getBoolValue()) { |
| 568 |
setprop("/sim/presets/fix", ""); |
| 569 |
} |
| 570 |
|
| 571 |
var speedRequested = getprop("/sim/presets/airspeed-kt"); |
| 572 |
if (speedRequested > 0) { |
| 573 |
setprop("/sim/presets/speed-set", "knots"); |
| 574 |
} |
| 575 |
|
| 576 |
</script> |
| 577 |
</binding> |
| 578 |
<binding> |
| 579 |
<command>reposition</command> |
| 580 |
</binding> |
| 581 |
<binding> |
| 582 |
<command>nasal</command> |
| 583 |
<script> |
| 584 |
ac = getprop("/sim/aircraft"); |
| 585 |
if (ac == "ufo") { return } |
| 586 |
|
| 587 |
var eng = props.globals.getNode("/controls/engines"); |
| 588 |
if (eng != nil) { |
| 589 |
foreach (c; eng.getChildren("engine")) { |
| 590 |
c.getNode("magnetos", 1).setIntValue(3); |
| 591 |
c.getNode("throttle", 1).setDoubleValue(0.5); |
| 592 |
} |
| 593 |
} |
| 594 |
</script> |
| 595 |
</binding> |
| 596 |
<binding> |
| 597 |
<command>dialog-close</command> |
| 598 |
</binding> |
| 599 |
</button> |
| 600 |
|
| 601 |
<button> |
| 602 |
<legend>Cancel</legend> |
| 603 |
<equal>true</equal> |
| 604 |
<key>Esc</key> |
| 605 |
<binding> |
| 606 |
<command>dialog-close</command> |
| 607 |
</binding> |
| 608 |
</button> |
| 609 |
</group> |
| 610 |
</PropertyList> |