]> git.mxchange.org Git - flightgear.git/commitdiff
removal of yet more stuff, left over from development; further simplification;
authormfranz <mfranz>
Tue, 6 Dec 2005 19:51:31 +0000 (19:51 +0000)
committermfranz <mfranz>
Tue, 6 Dec 2005 19:51:31 +0000 (19:51 +0000)
requires to remove some constness, though (we are adding listeners!);
If I continue like that, nothing will be left.  :-)

src/GUI/menubar.cxx
src/GUI/menubar.hxx

index 04dc676340b2bd010e980b2b045e027ed314c614..fa3d69d56ba8f111eff7bd80a853de87a391b908 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <string.h>
 #include <iostream>
-#include <sstream>
 #include <plib/pu.h>
 #include <simgear/debug/logstream.hxx>
 
@@ -292,7 +291,7 @@ FGMenuBar::make_menubar ()
  * contents, whether they are representing a 'legal' menubar structure.
  */
 void
-FGMenuBar::make_menubar(const SGPropertyNode * props) 
+FGMenuBar::make_menubar(SGPropertyNode * props) 
 {    
     // Just in case.
     destroy_menubar();
@@ -374,10 +373,8 @@ FGMenuBar::add_enabled_listener(SGPropertyNode * node)
 }
 
 void
-FGMenuBar::make_map(const SGPropertyNode * node)
+FGMenuBar::make_map(SGPropertyNode * node)
 {
-    string base = node->getPath();
-
     int menu_index = 0;
     for (puObject *obj = ((puGroup *)_menuBar)->getFirstChild();
             obj; obj = obj->getNextObject()) {
@@ -387,19 +384,16 @@ FGMenuBar::make_map(const SGPropertyNode * node)
         if (!(obj->getType() & PUCLASS_ONESHOT))
             continue;
 
-        std::ostringstream menu;
-        menu << base << "/menu[" << menu_index << "]";
-        SGPropertyNode *prop = fgGetNode(menu.str().c_str());
-        if (!prop) {
-            SG_LOG(SG_GENERAL, SG_WARN, "menu without node: " << menu.str());
+        SGPropertyNode *menu = node->getNode("menu", menu_index, false);
+        if (!menu) {
+            SG_LOG(SG_GENERAL, SG_WARN, "<menu> without node: "
+                    << node->getPath() << "/menu[" << menu_index << ']');
             continue;
         }
 
-        // push "menu" entry
-        _entries[prop->getPath()] = obj;
-        add_enabled_listener(prop);
+        _entries[menu->getPath()] = obj;
+        add_enabled_listener(menu);
 
-        // push "item" entries
         puPopupMenu *popup = (puPopupMenu *)obj->getUserData();
         if (!popup)
             continue;
@@ -412,15 +406,14 @@ FGMenuBar::make_map(const SGPropertyNode * node)
             e.push_back(me);
 
         for (unsigned int i = 0; i < e.size(); i++) {
-            std::ostringstream item;
-            item << menu.str() << "/item[" << (e.size() - i - 1) << "]";
-            prop = fgGetNode(item.str().c_str());
-            if (!prop) {
-                SG_LOG(SG_GENERAL, SG_WARN, "item without node: " << item.str());
+            SGPropertyNode *item = menu->getNode("item", e.size() - i - 1, false);
+            if (!item) {
+                SG_LOG(SG_GENERAL, SG_WARN, "menu <item> without node: "
+                        << menu->getPath() << "/item[" << i << ']');
                 continue;
             }
-            _entries[prop->getPath()] = e[i];
-            add_enabled_listener(prop);
+            _entries[item->getPath()] = e[i];
+            add_enabled_listener(item);
         }
         menu_index++;
     }
index 9830ebbbbc6821181c379d1b6934dec5b514437e..a22a77f58433fc91b44840b40581c8ffae24046b 100644 (file)
@@ -87,7 +87,7 @@ public:
     /**
      * create a menubar based on a PropertyList within the PropertyTree
      */
-    void make_menubar (const SGPropertyNode * props);
+    void make_menubar (SGPropertyNode * props);
 
 
     /**
@@ -110,7 +110,7 @@ private:
     void make_menubar ();
 
     // Create a property-path -> puObject map for menu node
-    void make_map(const SGPropertyNode * node);
+    void make_map(SGPropertyNode * node);
 
     // Add <enabled> listener that enables/disables menu entries.
     void add_enabled_listener(SGPropertyNode * node);