]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/atcdialog.cxx
fix trx and rx heights and improve calculations
[flightgear.git] / src / ATC / atcdialog.cxx
index 3ab9e28d7f2fd77df5380ce759193fb97aa30e04..eb9533fbb692726b6d5b6aba720e5b75cff56635 100644 (file)
 FGATCDialogNew *currentATCDialog;
 
 static bool doATCDialog(const SGPropertyNode* arg) {
-        cerr << "Running doATCDialog" << endl;
+        //cerr << "Running doATCDialog" << endl;
        currentATCDialog->PopupDialog();
        return(true);
 }
 
 FGATCDialogNew::FGATCDialogNew()
 {
-  dialogVisible = false;
+  dialogVisible = true;
 }
 
 FGATCDialogNew::~FGATCDialogNew()
@@ -60,7 +60,7 @@ void FGATCDialogNew::init() {
 
        // initialize properties polled in Update()
        //globals->get_props()->setStringValue("/sim/atc/freq-airport", "");
-       //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1);
+       globals->get_props()->setIntValue("/sim/atc/transmission-num", -1);
 }
 
 
@@ -86,9 +86,25 @@ static SGPropertyNode *getNamedNode(SGPropertyNode *prop, const char *name) {
       return 0;
 }
 
+void FGATCDialogNew::addEntry(int nr, string txt) {
+    commands.clear();
+    commands.push_back(txt);
+    commands.push_back(string("Toggle ground network visibility"));
+}
+
+void FGATCDialogNew::removeEntry(int nr) {
+    commands.clear();
+}
+
+
 
 void FGATCDialogNew::PopupDialog() {
-    double onBoardRadioFreq0 =
+    dialogVisible = !dialogVisible;
+    return;
+}
+
+void FGATCDialogNew::update(double dt) {
+ double onBoardRadioFreq0 =
         fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
     double onBoardRadioFreq1 =
         fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
@@ -105,22 +121,24 @@ void FGATCDialogNew::PopupDialog() {
 
     const int bufsize = 32;
     char buf[bufsize];
+    int commandNr = 0;
     // loop over all entries that should fill up the dialog; use 10 items for now...
-    for (int i = 0; i < 10; i++) {
-        snprintf(buf, bufsize, "/sim/atc/opt[%d]", i);
+    for (StringVecIterator i = commands.begin(); i != commands.end(); i++) {
+        snprintf(buf, bufsize, "/sim/atc/opt[%d]", commandNr);
             fgSetBool(buf, false);
-        SGPropertyNode *entry = button_group->getNode("button", i, true);
+        SGPropertyNode *entry = button_group->getNode("button", commandNr, true);
         copyProperties(button_group->getNode("button-template", true), entry);
        entry->removeChildren("enabled", true);
        entry->setStringValue("property", buf);
-       entry->setIntValue("keynum", '1' + i);
-       if (i == 0)
+       entry->setIntValue("keynum", '1' + commandNr);
+       if (commandNr == 0)
            entry->setBoolValue("default", true);
 
-       snprintf(buf, bufsize, "%d", i + 1);
-       string legend = string(buf) + ". test"; // + current->menuentry;
+       snprintf(buf, bufsize, "%d", 1 + commandNr);
+       string legend = string(buf) + (*i); //"; // + current->menuentry;
        entry->setStringValue("legend", legend.c_str());
-       entry->setIntValue("binding/value", i);
+       entry->setIntValue("binding/value", commandNr);
+        commandNr++;
        //current++;
     }
 
@@ -129,16 +147,14 @@ void FGATCDialogNew::PopupDialog() {
     } else {
         _gui->showDialog(dialog_name);
     }
-    dialogVisible = !dialogVisible;
+    //dialogVisible = !dialogVisible;
     return;
-}
-
-void FGATCDialogNew::update(double dt) {
+    /*
     static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true);
     int n = trans_num->getIntValue();
     if (n >= 0) {
         trans_num->setIntValue(-1);
            // PopupCallback(n);
         cerr << "Selected transmission message" << n << endl;
-    }
+    } */
 }
\ No newline at end of file