- const char *dialog_name = "atc-freq-search";
- SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
- if (!dlg)
- return;
-
- _gui->closeDialog(dialog_name);
-
- SGPropertyNode_ptr button_group = getNamedNode(dlg, "quick-buttons");
- // remove all dynamic airport/ATC buttons
- button_group->removeChildren("button");
-
- AirportsWithATC filt;
- FGPositionedList results = FGPositioned::findWithinRange(globals->get_aircraft_position(), 50.0, &filt);
- FGPositioned::sortByRange(results, globals->get_aircraft_position());
- for (unsigned int r=0; (r<results.size()) && (r < 6); ++r) {
-
- SGPropertyNode *entry = button_group->getNode("button", r, true);
- copyProperties(button_group->getNode("button-template", true), entry);
- entry->removeChildren("enabled");
- entry->setStringValue("legend", results[r]->ident());
- entry->setStringValue("binding[0]/icao", results[r]->ident());
- }
-
- // (un)hide message saying no things in range
- SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
- range_error->setBoolValue("visible", !results.empty());
-
- _gui->showDialog(dialog_name);
+ const char *dialog_name = "atc-freq-search";
+ SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
+ if (!dlg)
+ return;
+
+ _gui->closeDialog(dialog_name);
+
+ SGPropertyNode_ptr button_group = getNamedNode(dlg, "quick-buttons");
+ // remove all dynamic airport/ATC buttons
+ button_group->removeChildren("button");
+
+ AirportsWithATC filt;
+ FGPositionedList results = FGPositioned::findWithinRange(globals->get_aircraft_position(), 50.0, &filt);
+ FGPositioned::sortByRange(results, globals->get_aircraft_position());
+ for (unsigned int r=0; (r<results.size()) && (r < 6); ++r) {
+
+ SGPropertyNode *entry = button_group->getNode("button", r, true);
+ copyProperties(button_group->getNode("button-template", true), entry);
+ entry->removeChildren("enabled");
+ entry->setStringValue("legend", results[r]->ident());
+ entry->setStringValue("binding[0]/icao", results[r]->ident());
+ }
+
+ // (un)hide message saying no things in range
+ SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
+ range_error->setBoolValue("visible", !results.empty());
+
+ _gui->showDialog(dialog_name);
- const char *dialog_name = "atc-freq-display";
- SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
- if (!dlg)
- return;
-
- _gui->closeDialog(dialog_name);
-
- SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
- // remove all frequency entries
- freq_group->removeChildren("group");
-
- std::string uident(ident);
- atcUppercase(uident);
- string label;
-
- const FGAirport *a = fgFindAirportID(uident);
- if (!a) {
- label = "Airport " + ident + " not found in database.";
- mkDialog(label.c_str());
- return;
- }
-
- // set title
- label = uident + " Frequencies";
- dlg->setStringValue("text/label", label.c_str());
-
- const flightgear::CommStationList& comms(a->commStations());
- if (comms.empty()) {
- label = "No frequencies found for airport " + uident;
- mkDialog(label.c_str());
- return;
- }
-
- for (unsigned int c=0; c < comms.size(); ++c) {
- flightgear::CommStation* comm = comms[c];
-
- // add frequency line (modified copy of <group-template>)
- SGPropertyNode *entry = freq_group->getNode("group", c, true);
- copyProperties(freq_group->getNode("group-template", true), entry);
- entry->removeChildren("enabled");
-
- entry->setStringValue("text[0]/label", comm->ident());
-
- char buf[8];
- snprintf(buf, 8, "%.2f", comm->freqMHz());
- if(buf[5] == '3') buf[5] = '2';
- if(buf[5] == '8') buf[5] = '7';
- buf[7] = '\0';
-
- entry->setStringValue("text[1]/label", buf);
- }
-
- _gui->showDialog(dialog_name);
+ const char *dialog_name = "atc-freq-display";
+ SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
+ if (!dlg)
+ return;
+
+ _gui->closeDialog(dialog_name);
+
+ SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
+ // remove all frequency entries
+ freq_group->removeChildren("group");
+
+ std::string uident(ident);
+ atcUppercase(uident);
+ string label;
+
+ const FGAirport *a = fgFindAirportID(uident);
+ if (!a) {
+ label = "Airport " + ident + " not found in database.";
+ mkDialog(label.c_str());
+ return;
+ }
+
+ // set title
+ label = uident + " Frequencies";
+ dlg->setStringValue("text/label", label.c_str());
+
+ const flightgear::CommStationList& comms(a->commStations());
+ if (comms.empty()) {
+ label = "No frequencies found for airport " + uident;
+ mkDialog(label.c_str());
+ return;
+ }
+
+ for (unsigned int c=0; c < comms.size(); ++c) {
+ flightgear::CommStation* comm = comms[c];
+
+ // add frequency line (modified copy of <group-template>)
+ SGPropertyNode *entry = freq_group->getNode("group", c, true);
+ copyProperties(freq_group->getNode("group-template", true), entry);
+ entry->removeChildren("enabled");
+
+ entry->setStringValue("text[0]/label", comm->ident());
+
+ char buf[8];
+ snprintf(buf, 8, "%.2f", comm->freqMHz());
+ if(buf[5] == '3') buf[5] = '2';
+ if(buf[5] == '8') buf[5] = '7';
+ buf[7] = '\0';
+
+ entry->setStringValue("text[1]/label", buf);
+ }
+
+ _gui->showDialog(dialog_name);
// loop over all entries that should fill up the dialog; use 10 items for now...
BOOST_FOREACH(const std::string& i, commands) {
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
// loop over all entries that should fill up the dialog; use 10 items for now...
BOOST_FOREACH(const std::string& i, commands) {
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
- entry->removeChildren("enabled");
- entry->setStringValue("property", buf);
- entry->setIntValue("keynum", '1' + commandNr);
- if (commandNr == 0)
- entry->setBoolValue("default", true);
-
- snprintf(buf, bufsize, "%d", 1 + commandNr);
- string legend = string(buf) + i; //"; // + current->menuentry;
- entry->setStringValue("legend", legend.c_str());
- entry->setIntValue("binding/value", commandNr);
+ entry->removeChildren("enabled");
+ entry->setStringValue("property", buf);
+ entry->setIntValue("keynum", '1' + commandNr);
+ if (commandNr == 0)
+ entry->setBoolValue("default", true);
+
+ snprintf(buf, bufsize, "%d", 1 + commandNr);
+ string legend = string(buf) + i; //"; // + current->menuentry;
+ entry->setStringValue("legend", legend.c_str());
+ entry->setIntValue("binding/value", commandNr);