1
0
Fork 0

Remove another deprecated command, and fix things up so that dialogs

reload properly on a reinit.
This commit is contained in:
david 2003-01-21 15:44:21 +00:00
parent 87a84efbb0
commit d819c42184
6 changed files with 43 additions and 36 deletions

View file

@ -115,7 +115,7 @@ GUIInfo::~GUIInfo ()
// Implementation of FGDialog.
////////////////////////////////////////////////////////////////////////
FGDialog::FGDialog (SGPropertyNode_ptr props)
FGDialog::FGDialog (SGPropertyNode * props)
: _object(0)
{
display(props);
@ -189,7 +189,7 @@ FGDialog::applyValues ()
}
void
FGDialog::display (SGPropertyNode_ptr props)
FGDialog::display (SGPropertyNode * props)
{
if (_object != 0) {
SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");

View file

@ -40,7 +40,7 @@ public:
*
* @param props A property tree describing the dialog.
*/
FGDialog (SGPropertyNode_ptr props);
FGDialog (SGPropertyNode * props);
/**
@ -97,7 +97,7 @@ private:
FGDialog (const FGDialog &);
// Show the dialog.
void display (SGPropertyNode_ptr props);
void display (SGPropertyNode * props);
// Build the dialog or a subobject of it.
puObject * makeObject (SGPropertyNode * props,

View file

@ -58,15 +58,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
}
#endif // TR_HIRES_SNAP
extern void dumpSnapShot (puObject *);
static bool
do_snapshot_dialog (const SGPropertyNode * arg)
{
dumpSnapShot(0);
return true;
}
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
extern void printScreen (puObject *);
static bool
@ -215,7 +206,6 @@ static struct {
#if defined(TR_HIRES_SNAP)
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
#endif
{ "old-snapshot-dialog", do_snapshot_dialog },
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
{ "old-print-dialog", do_print_dialog },
#endif
@ -359,7 +349,7 @@ FGMenuBar::fireItem (puObject * item)
}
void
FGMenuBar::make_menu (SGPropertyNode_ptr node)
FGMenuBar::make_menu (SGPropertyNode * node)
{
const char * name = strdup(node->getStringValue("label"));
vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");

View file

@ -88,7 +88,7 @@ public:
private:
// Make a single menu.
void make_menu (SGPropertyNode_ptr node);
void make_menu (SGPropertyNode * node);
// Make the top-level menubar.
void make_menubar ();

View file

@ -26,7 +26,7 @@ NewGUI::NewGUI ()
NewGUI::~NewGUI ()
{
delete _menubar;
clear();
}
void
@ -46,13 +46,8 @@ void
NewGUI::reinit ()
{
unbind();
#if !defined(FG_OLD_MENUBAR)
delete _menubar;
clear();
_menubar = new FGMenuBar;
#endif
_dialog_props.clear();
init();
bind();
}
@ -133,6 +128,18 @@ NewGUI::setMenuBarVisible (bool visible)
_menubar->hide();
}
void
NewGUI::clear ()
{
delete _menubar;
_menubar = 0;
map<string,SGPropertyNode *>::iterator it;
for (it = _dialog_props.begin(); it != _dialog_props.end(); it++)
delete it->second;
_dialog_props.clear();
}
void
NewGUI::readDir (const char * path)
{
@ -144,32 +151,39 @@ NewGUI::readDir (const char * path)
return;
}
ulDirEnt * dirEnt = ulReadDir(dir);
while (dirEnt != 0) {
for (ulDirEnt * dirEnt = ulReadDir(dir);
dirEnt != 0;
dirEnt = ulReadDir(dir)) {
char subpath[1024];
ulMakePath(subpath, path, dirEnt->d_name);
if (dirEnt->d_isdir && dirEnt->d_name[0] != '.') {
readDir(subpath);
if (dirEnt->d_isdir) {
if (dirEnt->d_name[0] != '.')
readDir(subpath);
} else {
SGPropertyNode_ptr props = new SGPropertyNode;
SGPropertyNode * props = new SGPropertyNode;
try {
readProperties(subpath, props);
} catch (const sg_exception &ex) {
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing GUI file "
SG_LOG(SG_INPUT, SG_ALERT, "Error parsing dialog "
<< subpath);
delete props;
continue;
}
if (!props->hasValue("name")) {
SG_LOG(SG_INPUT, SG_WARN, "GUI file " << subpath
SG_LOG(SG_INPUT, SG_WARN, "dialog " << subpath
<< " has no name; skipping.");
} else {
string name = props->getStringValue("name");
SG_LOG(SG_INPUT, SG_BULK, "Saving GUI node " << name);
_dialog_props[name] = props;
delete props;
continue;
}
string name = props->getStringValue("name");
SG_LOG(SG_INPUT, SG_BULK, "Saving dialog " << name);
if (_dialog_props[name] != 0)
delete _dialog_props[name];
_dialog_props[name] = props;
}
dirEnt = ulReadDir(dir);
}
ulCloseDir(dir);
}

View file

@ -142,12 +142,15 @@ protected:
private:
// Free all allocated memory.
void clear ();
// Read all the configuration files in a directory.
void readDir (const char * path);
FGMenuBar * _menubar;
FGDialog * _active_dialog;
map<string,SGPropertyNode_ptr> _dialog_props;
map<string,SGPropertyNode *> _dialog_props;
};