Reformatting.
This commit is contained in:
parent
98682c0c68
commit
1dc7d4cf11
1 changed files with 127 additions and 127 deletions
|
@ -48,147 +48,147 @@ using std::string;
|
||||||
|
|
||||||
static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name)
|
static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name)
|
||||||
{
|
{
|
||||||
SGPropertyNode* p;
|
SGPropertyNode* p;
|
||||||
|
|
||||||
for (int i = 0; i < prop->nChildren(); i++)
|
for (int i = 0; i < prop->nChildren(); i++)
|
||||||
if ((p = getNamedNode(prop->getChild(i), name)))
|
if ((p = getNamedNode(prop->getChild(i), name)))
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
if (!strcmp(prop->getStringValue("name"), name))
|
if (!strcmp(prop->getStringValue("name"), name))
|
||||||
return prop;
|
return prop;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void atcUppercase(string &s) {
|
static void atcUppercase(string &s) {
|
||||||
for(unsigned int i=0; i<s.size(); ++i) {
|
for(unsigned int i=0; i<s.size(); ++i) {
|
||||||
s[i] = toupper(s[i]);
|
s[i] = toupper(s[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AirportsWithATC : public FGAirport::AirportFilter
|
class AirportsWithATC : public FGAirport::AirportFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual FGPositioned::Type maxType() const {
|
virtual FGPositioned::Type maxType() const {
|
||||||
return FGPositioned::SEAPORT;
|
return FGPositioned::SEAPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool passAirport(FGAirport* aApt) const
|
virtual bool passAirport(FGAirport* aApt) const
|
||||||
{
|
{
|
||||||
return (!aApt->commStations().empty());
|
return (!aApt->commStations().empty());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void FGATCDialogNew::frequencySearch()
|
void FGATCDialogNew::frequencySearch()
|
||||||
{
|
{
|
||||||
const char *dialog_name = "atc-freq-search";
|
const char *dialog_name = "atc-freq-search";
|
||||||
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
||||||
if (!dlg)
|
if (!dlg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_gui->closeDialog(dialog_name);
|
_gui->closeDialog(dialog_name);
|
||||||
|
|
||||||
SGPropertyNode_ptr button_group = getNamedNode(dlg, "quick-buttons");
|
SGPropertyNode_ptr button_group = getNamedNode(dlg, "quick-buttons");
|
||||||
// remove all dynamic airport/ATC buttons
|
// remove all dynamic airport/ATC buttons
|
||||||
button_group->removeChildren("button");
|
button_group->removeChildren("button");
|
||||||
|
|
||||||
AirportsWithATC filt;
|
AirportsWithATC filt;
|
||||||
FGPositionedList results = FGPositioned::findWithinRange(globals->get_aircraft_position(), 50.0, &filt);
|
FGPositionedList results = FGPositioned::findWithinRange(globals->get_aircraft_position(), 50.0, &filt);
|
||||||
FGPositioned::sortByRange(results, globals->get_aircraft_position());
|
FGPositioned::sortByRange(results, globals->get_aircraft_position());
|
||||||
for (unsigned int r=0; (r<results.size()) && (r < 6); ++r) {
|
for (unsigned int r=0; (r<results.size()) && (r < 6); ++r) {
|
||||||
|
|
||||||
SGPropertyNode *entry = button_group->getNode("button", r, true);
|
SGPropertyNode *entry = button_group->getNode("button", r, true);
|
||||||
copyProperties(button_group->getNode("button-template", true), entry);
|
copyProperties(button_group->getNode("button-template", true), entry);
|
||||||
entry->removeChildren("enabled");
|
entry->removeChildren("enabled");
|
||||||
entry->setStringValue("legend", results[r]->ident());
|
entry->setStringValue("legend", results[r]->ident());
|
||||||
entry->setStringValue("binding[0]/icao", results[r]->ident());
|
entry->setStringValue("binding[0]/icao", results[r]->ident());
|
||||||
}
|
}
|
||||||
|
|
||||||
// (un)hide message saying no things in range
|
// (un)hide message saying no things in range
|
||||||
SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
|
SGPropertyNode_ptr range_error = getNamedNode(dlg, "no-atc-in-range");
|
||||||
range_error->setBoolValue("visible", !results.empty());
|
range_error->setBoolValue("visible", !results.empty());
|
||||||
|
|
||||||
_gui->showDialog(dialog_name);
|
_gui->showDialog(dialog_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGATCDialogNew::frequencyDisplay(const std::string& ident)
|
void FGATCDialogNew::frequencyDisplay(const std::string& ident)
|
||||||
{
|
{
|
||||||
const char *dialog_name = "atc-freq-display";
|
const char *dialog_name = "atc-freq-display";
|
||||||
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
||||||
if (!dlg)
|
if (!dlg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_gui->closeDialog(dialog_name);
|
_gui->closeDialog(dialog_name);
|
||||||
|
|
||||||
SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
|
SGPropertyNode_ptr freq_group = getNamedNode(dlg, "frequency-list");
|
||||||
// remove all frequency entries
|
// remove all frequency entries
|
||||||
freq_group->removeChildren("group");
|
freq_group->removeChildren("group");
|
||||||
|
|
||||||
std::string uident(ident);
|
std::string uident(ident);
|
||||||
atcUppercase(uident);
|
atcUppercase(uident);
|
||||||
string label;
|
string label;
|
||||||
|
|
||||||
const FGAirport *a = fgFindAirportID(uident);
|
const FGAirport *a = fgFindAirportID(uident);
|
||||||
if (!a) {
|
if (!a) {
|
||||||
label = "Airport " + ident + " not found in database.";
|
label = "Airport " + ident + " not found in database.";
|
||||||
mkDialog(label.c_str());
|
mkDialog(label.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set title
|
// set title
|
||||||
label = uident + " Frequencies";
|
label = uident + " Frequencies";
|
||||||
dlg->setStringValue("text/label", label.c_str());
|
dlg->setStringValue("text/label", label.c_str());
|
||||||
|
|
||||||
const flightgear::CommStationList& comms(a->commStations());
|
const flightgear::CommStationList& comms(a->commStations());
|
||||||
if (comms.empty()) {
|
if (comms.empty()) {
|
||||||
label = "No frequencies found for airport " + uident;
|
label = "No frequencies found for airport " + uident;
|
||||||
mkDialog(label.c_str());
|
mkDialog(label.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int c=0; c < comms.size(); ++c) {
|
for (unsigned int c=0; c < comms.size(); ++c) {
|
||||||
flightgear::CommStation* comm = comms[c];
|
flightgear::CommStation* comm = comms[c];
|
||||||
|
|
||||||
// add frequency line (modified copy of <group-template>)
|
// add frequency line (modified copy of <group-template>)
|
||||||
SGPropertyNode *entry = freq_group->getNode("group", c, true);
|
SGPropertyNode *entry = freq_group->getNode("group", c, true);
|
||||||
copyProperties(freq_group->getNode("group-template", true), entry);
|
copyProperties(freq_group->getNode("group-template", true), entry);
|
||||||
entry->removeChildren("enabled");
|
entry->removeChildren("enabled");
|
||||||
|
|
||||||
entry->setStringValue("text[0]/label", comm->ident());
|
entry->setStringValue("text[0]/label", comm->ident());
|
||||||
|
|
||||||
char buf[8];
|
char buf[8];
|
||||||
snprintf(buf, 8, "%.2f", comm->freqMHz());
|
snprintf(buf, 8, "%.2f", comm->freqMHz());
|
||||||
if(buf[5] == '3') buf[5] = '2';
|
if(buf[5] == '3') buf[5] = '2';
|
||||||
if(buf[5] == '8') buf[5] = '7';
|
if(buf[5] == '8') buf[5] = '7';
|
||||||
buf[7] = '\0';
|
buf[7] = '\0';
|
||||||
|
|
||||||
entry->setStringValue("text[1]/label", buf);
|
entry->setStringValue("text[1]/label", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
_gui->showDialog(dialog_name);
|
_gui->showDialog(dialog_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doFrequencySearch( const SGPropertyNode* )
|
static bool doFrequencySearch( const SGPropertyNode* )
|
||||||
{
|
{
|
||||||
FGATCDialogNew::instance()->frequencySearch();
|
FGATCDialogNew::instance()->frequencySearch();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool doFrequencyDisplay( const SGPropertyNode* args )
|
static bool doFrequencyDisplay( const SGPropertyNode* args )
|
||||||
{
|
{
|
||||||
std::string icao = args->getStringValue("icao");
|
std::string icao = args->getStringValue("icao");
|
||||||
if (icao.empty()) {
|
if (icao.empty()) {
|
||||||
icao = fgGetString("/sim/atc/freq-airport");
|
icao = fgGetString("/sim/atc/freq-airport");
|
||||||
}
|
}
|
||||||
|
|
||||||
FGATCDialogNew::instance()->frequencyDisplay(icao);
|
FGATCDialogNew::instance()->frequencyDisplay(icao);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FGATCDialogNew * FGATCDialogNew::_instance = NULL;
|
FGATCDialogNew * FGATCDialogNew::_instance = NULL;
|
||||||
|
|
||||||
FGATCDialogNew::FGATCDialogNew()
|
FGATCDialogNew::FGATCDialogNew()
|
||||||
: _gui(NULL),
|
: _gui(NULL),
|
||||||
dialogVisible(true)
|
dialogVisible(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ void FGATCDialogNew::update(double dt) {
|
||||||
const char *dialog_name = "atc-dialog";
|
const char *dialog_name = "atc-dialog";
|
||||||
_gui = (NewGUI *)globals->get_subsystem("gui");
|
_gui = (NewGUI *)globals->get_subsystem("gui");
|
||||||
if (!_gui) {
|
if (!_gui) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
|
||||||
|
@ -265,21 +265,21 @@ void FGATCDialogNew::update(double dt) {
|
||||||
// loop over all entries that should fill up the dialog; use 10 items for now...
|
// loop over all entries that should fill up the dialog; use 10 items for now...
|
||||||
BOOST_FOREACH(const std::string& i, commands) {
|
BOOST_FOREACH(const std::string& i, commands) {
|
||||||
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
|
snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
|
||||||
fgSetBool(buf, false);
|
fgSetBool(buf, false);
|
||||||
SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
|
SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
|
||||||
copyProperties(button_group->getNode("button-template", true), entry);
|
copyProperties(button_group->getNode("button-template", true), entry);
|
||||||
entry->removeChildren("enabled");
|
entry->removeChildren("enabled");
|
||||||
entry->setStringValue("property", buf);
|
entry->setStringValue("property", buf);
|
||||||
entry->setIntValue("keynum", '1' + commandNr);
|
entry->setIntValue("keynum", '1' + commandNr);
|
||||||
if (commandNr == 0)
|
if (commandNr == 0)
|
||||||
entry->setBoolValue("default", true);
|
entry->setBoolValue("default", true);
|
||||||
|
|
||||||
snprintf(buf, bufsize, "%d", 1 + commandNr);
|
snprintf(buf, bufsize, "%d", 1 + commandNr);
|
||||||
string legend = string(buf) + i; //"; // + current->menuentry;
|
string legend = string(buf) + i; //"; // + current->menuentry;
|
||||||
entry->setStringValue("legend", legend.c_str());
|
entry->setStringValue("legend", legend.c_str());
|
||||||
entry->setIntValue("binding/value", commandNr);
|
entry->setIntValue("binding/value", commandNr);
|
||||||
commandNr++;
|
commandNr++;
|
||||||
//current++;
|
//current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialogVisible) {
|
if (dialogVisible) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue