1
0
Fork 0

removal of yet more stuff, left over from development; further simplification;

requires to remove some constness, though (we are adding listeners!);
If I continue like that, nothing will be left.  :-)
This commit is contained in:
mfranz 2005-12-06 19:51:31 +00:00
parent e35911e45a
commit c10f583c11
2 changed files with 16 additions and 23 deletions

View file

@ -4,7 +4,6 @@
#include <string.h> #include <string.h>
#include <iostream> #include <iostream>
#include <sstream>
#include <plib/pu.h> #include <plib/pu.h>
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
@ -292,7 +291,7 @@ FGMenuBar::make_menubar ()
* contents, whether they are representing a 'legal' menubar structure. * contents, whether they are representing a 'legal' menubar structure.
*/ */
void void
FGMenuBar::make_menubar(const SGPropertyNode * props) FGMenuBar::make_menubar(SGPropertyNode * props)
{ {
// Just in case. // Just in case.
destroy_menubar(); destroy_menubar();
@ -374,10 +373,8 @@ FGMenuBar::add_enabled_listener(SGPropertyNode * node)
} }
void void
FGMenuBar::make_map(const SGPropertyNode * node) FGMenuBar::make_map(SGPropertyNode * node)
{ {
string base = node->getPath();
int menu_index = 0; int menu_index = 0;
for (puObject *obj = ((puGroup *)_menuBar)->getFirstChild(); for (puObject *obj = ((puGroup *)_menuBar)->getFirstChild();
obj; obj = obj->getNextObject()) { obj; obj = obj->getNextObject()) {
@ -387,19 +384,16 @@ FGMenuBar::make_map(const SGPropertyNode * node)
if (!(obj->getType() & PUCLASS_ONESHOT)) if (!(obj->getType() & PUCLASS_ONESHOT))
continue; continue;
std::ostringstream menu; SGPropertyNode *menu = node->getNode("menu", menu_index, false);
menu << base << "/menu[" << menu_index << "]"; if (!menu) {
SGPropertyNode *prop = fgGetNode(menu.str().c_str()); SG_LOG(SG_GENERAL, SG_WARN, "<menu> without node: "
if (!prop) { << node->getPath() << "/menu[" << menu_index << ']');
SG_LOG(SG_GENERAL, SG_WARN, "menu without node: " << menu.str());
continue; continue;
} }
// push "menu" entry _entries[menu->getPath()] = obj;
_entries[prop->getPath()] = obj; add_enabled_listener(menu);
add_enabled_listener(prop);
// push "item" entries
puPopupMenu *popup = (puPopupMenu *)obj->getUserData(); puPopupMenu *popup = (puPopupMenu *)obj->getUserData();
if (!popup) if (!popup)
continue; continue;
@ -412,15 +406,14 @@ FGMenuBar::make_map(const SGPropertyNode * node)
e.push_back(me); e.push_back(me);
for (unsigned int i = 0; i < e.size(); i++) { for (unsigned int i = 0; i < e.size(); i++) {
std::ostringstream item; SGPropertyNode *item = menu->getNode("item", e.size() - i - 1, false);
item << menu.str() << "/item[" << (e.size() - i - 1) << "]"; if (!item) {
prop = fgGetNode(item.str().c_str()); SG_LOG(SG_GENERAL, SG_WARN, "menu <item> without node: "
if (!prop) { << menu->getPath() << "/item[" << i << ']');
SG_LOG(SG_GENERAL, SG_WARN, "item without node: " << item.str());
continue; continue;
} }
_entries[prop->getPath()] = e[i]; _entries[item->getPath()] = e[i];
add_enabled_listener(prop); add_enabled_listener(item);
} }
menu_index++; menu_index++;
} }

View file

@ -87,7 +87,7 @@ public:
/** /**
* create a menubar based on a PropertyList within the PropertyTree * 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 (); void make_menubar ();
// Create a property-path -> puObject map for menu node // 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. // Add <enabled> listener that enables/disables menu entries.
void add_enabled_listener(SGPropertyNode * node); void add_enabled_listener(SGPropertyNode * node);