From: mfranz Date: Fri, 28 Apr 2006 10:27:54 +0000 (+0000) Subject: newgui.[ch]xx: implement FGDialog *NewGUI::getDialog(cont string&) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eb19c2650d4713a70454d56104b47da47ad14cd6;p=flightgear.git newgui.[ch]xx: implement FGDialog *NewGUI::getDialog(cont string&) fg_command.cxx: add possibility to "dialog-apply" or "dialog-update" an arbitrary active (= open) dialog or widget --- diff --git a/src/GUI/new_gui.cxx b/src/GUI/new_gui.cxx index 03f9f68cc..cbccde541 100644 --- a/src/GUI/new_gui.cxx +++ b/src/GUI/new_gui.cxx @@ -171,7 +171,17 @@ NewGUI::getDialogProperties (const string &name) if(_dialog_props.find(name) != _dialog_props.end()) return _dialog_props[name]; - SG_LOG(SG_GENERAL, SG_ALERT, "dialog '" << name << "' missing"); + SG_LOG(SG_GENERAL, SG_DEBUG, "dialog '" << name << "' missing"); + return 0; +} + +FGDialog * +NewGUI::getDialog (const string &name) +{ + if(_active_dialogs.find(name) != _active_dialogs.end()) + return _active_dialogs[name]; + + SG_LOG(SG_GENERAL, SG_DEBUG, "dialog '" << name << "' missing"); return 0; } diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index 1ccd5662d..f00bf72bf 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -165,6 +165,15 @@ public: */ virtual FGDialog * getActiveDialog (); + + /** + * Get the named dialog if active. + * + * @return The named dialog, or 0 if it isn't active. + */ + virtual FGDialog * getDialog (const string &name); + + virtual FGColor *getColor (const char * name) const { _citt_t it = _colors.find(name); return (it != _colors.end()) ? it->second : NULL; diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index 358f03269..710f929a0 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -1097,7 +1097,12 @@ static bool do_dialog_update (const SGPropertyNode * arg) { NewGUI * gui = (NewGUI *)globals->get_subsystem("gui"); - FGDialog * dialog = gui->getActiveDialog(); + FGDialog * dialog; + if (arg->hasValue("dialog-name")) + dialog = gui->getDialog(arg->getStringValue("dialog-name")); + else + dialog = gui->getActiveDialog(); + if (dialog != 0) { if (arg->hasValue("object-name")) { dialog->updateValue(arg->getStringValue("object-name")); @@ -1120,7 +1125,12 @@ static bool do_dialog_apply (const SGPropertyNode * arg) { NewGUI * gui = (NewGUI *)globals->get_subsystem("gui"); - FGDialog * dialog = gui->getActiveDialog(); + FGDialog * dialog; + if (arg->hasValue("dialog-name")) + dialog = gui->getDialog(arg->getStringValue("dialog-name")); + else + dialog = gui->getActiveDialog(); + if (dialog != 0) { if (arg->hasValue("object-name")) { const char * name = arg->getStringValue("object-name");