]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui_funcs.cxx
Support for multiple data dirs.
[flightgear.git] / src / GUI / gui_funcs.cxx
index 6cd2a95bf4d15953e3bb5439f50a047f42dfce2a..2a084dad679dde1b94be538768099eaca2ef9f5b 100644 (file)
 #  include <config.h>
 #endif
 
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
 #include <simgear/compiler.h>
 
 #include <fstream>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/fg_os.hxx>
-#include <Main/renderer.hxx>
-#include <Main/viewmgr.hxx>
-#include <Main/WindowSystemAdapter.hxx>
-#include <Main/CameraGroup.hxx>
+#include <Viewer/renderer.hxx>
+#include <Viewer/viewmgr.hxx>
+#include <Viewer/WindowSystemAdapter.hxx>
+#include <Viewer/CameraGroup.hxx>
 #include <GUI/new_gui.hxx>
 
 
 #  include <shellapi.h>
 #endif
 
+#ifdef SG_MAC
+# include "FGCocoaMenuBar.hxx" // for cocoaOpenUrl
+#endif
+
 #include "gui.h"
 
 using std::string;
@@ -161,10 +169,11 @@ void helpCb()
     openBrowser( "Docs/index.html" );
 }
 
-bool openBrowser(string address)
+bool openBrowser(const std::string& aAddress)
 {
     bool ok = true;
-
+    string address(aAddress);
+    
     // do not resolve addresses with given protocol, i.e. "http://...", "ftp://..."
     if (address.find("://")==string::npos)
     {
@@ -182,19 +191,13 @@ bool openBrowser(string address)
         }
     }
 
-#ifndef _WIN32
-
-    string command = globals->get_browser();
-    string::size_type pos;
-    if ((pos = command.find("%u", 0)) != string::npos)
-        command.replace(pos, 2, address);
-    else
-        command += " " + address;
-
-    command += " &";
-    ok = (system( command.c_str() ) == 0);
-
-#else // _WIN32
+#ifdef SG_MAC
+  if (address.find("://")==string::npos) {
+    address = "file://" + address;
+  }
+  
+  cocoaOpenUrl(address);
+#elif defined _WIN32
 
     // Look for favorite browser
     char win32_name[1024];
@@ -205,7 +208,17 @@ bool openBrowser(string address)
 # endif
     ShellExecute ( NULL, "open", win32_name, NULL, NULL,
                    SW_SHOWNORMAL ) ;
+#else
+    // Linux, BSD, SGI etc
+    string command = globals->get_browser();
+    string::size_type pos;
+    if ((pos = command.find("%u", 0)) != string::npos)
+        command.replace(pos, 2, address);
+    else
+        command += " \"" + address +"\"";
 
+    command += " &";
+    ok = (system( command.c_str() ) == 0);
 #endif
 
     mkDialog("The file is shown in your web browser window.");
@@ -221,12 +234,11 @@ void fgHiResDump()
     char *filename = new char [24];
     static int count = 1;
 
-    static const SGPropertyNode *master_freeze
-        = fgGetNode("/sim/freeze/master");
+    SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", true);
+        master_freeze->setBoolValue(true);
     }
 
     fgSetBool("/sim/menubar/visibility", false);
@@ -407,7 +419,7 @@ void fgHiResDump()
     fgSetBool("/sim/menubar/visibility", menu_status);
 
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", false);
+        master_freeze->setBoolValue(false);
     }
 }
 #endif // #if defined( TR_HIRES_SNAP)
@@ -468,13 +480,13 @@ namespace
 
             string dir = fgGetString("/sim/paths/screenshot-dir");
             if (dir.empty())
-                dir = fgGetString("/sim/fg-current");
+                dir = SGPath::desktop().str();
 
             _path.set(dir + '/');
             if (_path.create_dir( 0755 )) {
                 SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
                         << dir << "'. Trying home directory.");
-                dir = fgGetString("/sim/fg-home");
+                dir = globals->get_fg_home();
             }
 
             char filename[24];
@@ -549,11 +561,11 @@ bool fgDumpSnapShot ()
     return GUISnapShotOperation::start();
 #else
     // obsolete code => remove when new code is stable
-    static SGConstPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master");
+    SGPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", true);
+        master_freeze->setBoolValue(true);
     }
 
     int mouse = fgGetMouseCursor();
@@ -579,7 +591,7 @@ bool fgDumpSnapShot ()
     if (path.create_dir( 0755 )) {
         SG_LOG(SG_GENERAL, SG_ALERT, "Cannot create screenshot directory '"
                 << dir << "'. Trying home directory.");
-        dir = fgGetString("/sim/fg-home");
+        dir = globals->get_fg_home();
     }
 
     char filename[24];
@@ -605,7 +617,7 @@ bool fgDumpSnapShot ()
     fgSetMouseCursor(mouse);
 
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", false);
+        master_freeze->setBoolValue(false);
     }
     return result;
 #endif
@@ -618,12 +630,11 @@ void fgDumpSceneGraph()
     string message;
     static int count = 1;
 
-    static const SGPropertyNode *master_freeze
-       = fgGetNode("/sim/freeze/master");
+    SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", true);
+        master_freeze->setBoolValue(true);
     }
 
     while (count < 1000) {
@@ -649,7 +660,7 @@ void fgDumpSceneGraph()
     delete [] filename;
 
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", false);
+        master_freeze->setBoolValue(false);
     }
 }
 
@@ -661,12 +672,11 @@ void fgDumpTerrainBranch()
     string message;
     static int count = 1;
 
-    static const SGPropertyNode *master_freeze
-       = fgGetNode("/sim/freeze/master");
+    SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", true);
+        master_freeze->setBoolValue(true);
     }
 
     while (count < 1000) {
@@ -692,26 +702,22 @@ void fgDumpTerrainBranch()
     delete [] filename;
 
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", false);
+        master_freeze->setBoolValue(false);
     }
 }
 
 void fgPrintVisibleSceneInfoCommand()
 {
-    static const SGPropertyNode *master_freeze
-        = fgGetNode("/sim/freeze/master");
+    SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", true);
+        master_freeze->setBoolValue(true);
     }
 
     flightgear::printVisibleSceneInfo(globals->get_renderer());
 
     if ( !freeze ) {
-        fgSetBool("/sim/freeze/master", false);
+        master_freeze->setBoolValue(false);
     }
 }
-
-    
-