Remove another deprecated command, and fix things up so that dialogs
reload properly on a reinit.
This commit is contained in:
parent
87a84efbb0
commit
d819c42184
6 changed files with 43 additions and 36 deletions
|
@ -115,7 +115,7 @@ GUIInfo::~GUIInfo ()
|
||||||
// Implementation of FGDialog.
|
// Implementation of FGDialog.
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
FGDialog::FGDialog (SGPropertyNode_ptr props)
|
FGDialog::FGDialog (SGPropertyNode * props)
|
||||||
: _object(0)
|
: _object(0)
|
||||||
{
|
{
|
||||||
display(props);
|
display(props);
|
||||||
|
@ -189,7 +189,7 @@ FGDialog::applyValues ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGDialog::display (SGPropertyNode_ptr props)
|
FGDialog::display (SGPropertyNode * props)
|
||||||
{
|
{
|
||||||
if (_object != 0) {
|
if (_object != 0) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");
|
SG_LOG(SG_GENERAL, SG_ALERT, "This widget is already active");
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
*
|
*
|
||||||
* @param props A property tree describing the dialog.
|
* @param props A property tree describing the dialog.
|
||||||
*/
|
*/
|
||||||
FGDialog (SGPropertyNode_ptr props);
|
FGDialog (SGPropertyNode * props);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,7 +97,7 @@ private:
|
||||||
FGDialog (const FGDialog &);
|
FGDialog (const FGDialog &);
|
||||||
|
|
||||||
// Show the dialog.
|
// Show the dialog.
|
||||||
void display (SGPropertyNode_ptr props);
|
void display (SGPropertyNode * props);
|
||||||
|
|
||||||
// Build the dialog or a subobject of it.
|
// Build the dialog or a subobject of it.
|
||||||
puObject * makeObject (SGPropertyNode * props,
|
puObject * makeObject (SGPropertyNode * props,
|
||||||
|
|
|
@ -58,15 +58,6 @@ do_hires_snapshot_dialog (const SGPropertyNode * arg)
|
||||||
}
|
}
|
||||||
#endif // TR_HIRES_SNAP
|
#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__)
|
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
|
||||||
extern void printScreen (puObject *);
|
extern void printScreen (puObject *);
|
||||||
static bool
|
static bool
|
||||||
|
@ -215,7 +206,6 @@ static struct {
|
||||||
#if defined(TR_HIRES_SNAP)
|
#if defined(TR_HIRES_SNAP)
|
||||||
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
|
{ "old-hires-snapshot-dialog", do_hires_snapshot_dialog },
|
||||||
#endif
|
#endif
|
||||||
{ "old-snapshot-dialog", do_snapshot_dialog },
|
|
||||||
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
|
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
|
||||||
{ "old-print-dialog", do_print_dialog },
|
{ "old-print-dialog", do_print_dialog },
|
||||||
#endif
|
#endif
|
||||||
|
@ -359,7 +349,7 @@ FGMenuBar::fireItem (puObject * item)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGMenuBar::make_menu (SGPropertyNode_ptr node)
|
FGMenuBar::make_menu (SGPropertyNode * node)
|
||||||
{
|
{
|
||||||
const char * name = strdup(node->getStringValue("label"));
|
const char * name = strdup(node->getStringValue("label"));
|
||||||
vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");
|
vector<SGPropertyNode_ptr> item_nodes = node->getChildren("item");
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Make a single menu.
|
// Make a single menu.
|
||||||
void make_menu (SGPropertyNode_ptr node);
|
void make_menu (SGPropertyNode * node);
|
||||||
|
|
||||||
// Make the top-level menubar.
|
// Make the top-level menubar.
|
||||||
void make_menubar ();
|
void make_menubar ();
|
||||||
|
|
|
@ -26,7 +26,7 @@ NewGUI::NewGUI ()
|
||||||
|
|
||||||
NewGUI::~NewGUI ()
|
NewGUI::~NewGUI ()
|
||||||
{
|
{
|
||||||
delete _menubar;
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -46,13 +46,8 @@ void
|
||||||
NewGUI::reinit ()
|
NewGUI::reinit ()
|
||||||
{
|
{
|
||||||
unbind();
|
unbind();
|
||||||
|
clear();
|
||||||
#if !defined(FG_OLD_MENUBAR)
|
|
||||||
delete _menubar;
|
|
||||||
_menubar = new FGMenuBar;
|
_menubar = new FGMenuBar;
|
||||||
#endif
|
|
||||||
_dialog_props.clear();
|
|
||||||
|
|
||||||
init();
|
init();
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
@ -133,6 +128,18 @@ NewGUI::setMenuBarVisible (bool visible)
|
||||||
_menubar->hide();
|
_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
|
void
|
||||||
NewGUI::readDir (const char * path)
|
NewGUI::readDir (const char * path)
|
||||||
{
|
{
|
||||||
|
@ -144,32 +151,39 @@ NewGUI::readDir (const char * path)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ulDirEnt * dirEnt = ulReadDir(dir);
|
for (ulDirEnt * dirEnt = ulReadDir(dir);
|
||||||
while (dirEnt != 0) {
|
dirEnt != 0;
|
||||||
|
dirEnt = ulReadDir(dir)) {
|
||||||
|
|
||||||
char subpath[1024];
|
char subpath[1024];
|
||||||
|
|
||||||
ulMakePath(subpath, path, dirEnt->d_name);
|
ulMakePath(subpath, path, dirEnt->d_name);
|
||||||
|
|
||||||
if (dirEnt->d_isdir && dirEnt->d_name[0] != '.') {
|
if (dirEnt->d_isdir) {
|
||||||
readDir(subpath);
|
if (dirEnt->d_name[0] != '.')
|
||||||
|
readDir(subpath);
|
||||||
} else {
|
} else {
|
||||||
SGPropertyNode_ptr props = new SGPropertyNode;
|
SGPropertyNode * props = new SGPropertyNode;
|
||||||
try {
|
try {
|
||||||
readProperties(subpath, props);
|
readProperties(subpath, props);
|
||||||
} catch (const sg_exception &ex) {
|
} 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);
|
<< subpath);
|
||||||
|
delete props;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (!props->hasValue("name")) {
|
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.");
|
<< " has no name; skipping.");
|
||||||
} else {
|
delete props;
|
||||||
string name = props->getStringValue("name");
|
continue;
|
||||||
SG_LOG(SG_INPUT, SG_BULK, "Saving GUI node " << name);
|
|
||||||
_dialog_props[name] = props;
|
|
||||||
}
|
}
|
||||||
|
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);
|
ulCloseDir(dir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,12 +142,15 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// Free all allocated memory.
|
||||||
|
void clear ();
|
||||||
|
|
||||||
// Read all the configuration files in a directory.
|
// Read all the configuration files in a directory.
|
||||||
void readDir (const char * path);
|
void readDir (const char * path);
|
||||||
|
|
||||||
FGMenuBar * _menubar;
|
FGMenuBar * _menubar;
|
||||||
FGDialog * _active_dialog;
|
FGDialog * _active_dialog;
|
||||||
map<string,SGPropertyNode_ptr> _dialog_props;
|
map<string,SGPropertyNode *> _dialog_props;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue