]> git.mxchange.org Git - flightgear.git/commitdiff
newgui.[ch]xx: implement FGDialog *NewGUI::getDialog(cont string&)
authormfranz <mfranz>
Fri, 28 Apr 2006 10:27:54 +0000 (10:27 +0000)
committermfranz <mfranz>
Fri, 28 Apr 2006 10:27:54 +0000 (10:27 +0000)
fg_command.cxx: add possibility to "dialog-apply" or "dialog-update"
                an arbitrary active (= open) dialog or widget

src/GUI/new_gui.cxx
src/GUI/new_gui.hxx
src/Main/fg_commands.cxx

index 03f9f68cc4068e0ed0bcccb536b5f4bd87ac14b6..cbccde54159184ff228b94d5ee0b32840205a936 100644 (file)
@@ -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;
 }
 
index 1ccd5662d62299f843d15bcff2022ac586691da8..f00bf72bf7d879c126851cb0dc9523ca5e5183b1 100644 (file)
@@ -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;
index 358f03269a96c25e1a2d171b065d59a4753f1ab6..710f929a0f9c80576acc59bcb5d621b75a26712b 100644 (file)
@@ -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");