]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui.cxx
Sync with latest JSBSim CVS
[flightgear.git] / src / GUI / gui.cxx
index 97dc8f3094e7d75167fb7c9147c14c5d97edf146..74078a6e2bee1b6c988878ca5a7101e3ba59bcbf 100644 (file)
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Main/options.hxx>
+#include <Main/viewmgr.hxx>
 
 #ifdef FG_NETWORK_OLK
 #include <NetworkOLK/network.h>
 #endif
    
-#if defined( WIN32 ) && !defined( __CYGWIN__ )
+#if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
 #  include <simgear/screen/win32-printer.h>
 #  include <simgear/screen/GlBitmaps.h>
 #endif
@@ -91,7 +92,7 @@ SG_USING_STD(string);
 SG_USING_STD(cout);
 #endif
 
-#ifdef  _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
 #define  snprintf    _snprintf
 #endif   /* _MSC_VER */
 
@@ -152,6 +153,30 @@ void mkDialog (const char *txt)
     FG_PUSH_PUI_DIALOG( dialogBox );
 }
 
+// Message Box to report an error.
+void guiErrorMessage (const char *txt)
+{
+    SG_LOG(SG_GENERAL, SG_ALERT, txt);
+    if (dialogBox != 0)
+      mkDialog(txt);
+}
+
+// Message Box to report a throwable (usually an exception).
+void guiErrorMessage (const char *txt, const sg_throwable &throwable)
+{
+    string msg = txt;
+    msg += '\n';
+    msg += throwable.getFormattedMessage();
+    if (throwable.getOrigin() != (string)"") {
+      msg += "\n (reported by ";
+      msg += throwable.getOrigin();
+      msg += ')';
+    }
+    SG_LOG(SG_GENERAL, SG_ALERT, msg);
+    if (dialogBox != 0)
+      mkDialog(msg.c_str());
+}
+
 // Toggle the Menu and Mouse display state
 void guiToggleMenu(void)
 {
@@ -224,8 +249,8 @@ static void saveFlight(puObject *cv) {
     SaveDialog = new puDialogBox (150, 50);
     {
         SaveDialogFrame   = new puFrame           (0,0,350, 150);
-        SaveDialogMessage = new puText            (
-                       (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
+        SaveDialogMessage
+            = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
         SaveDialogMessage ->    setLabel          ("File Name:");
 
         SaveDialogInput   = new puInput           (50, 70, 300, 100);
@@ -289,8 +314,8 @@ static void loadFlight(puObject *cb)
     LoadDialog = new puDialogBox (150, 50);
     {
         LoadDialogFrame   = new puFrame           (0,0,350, 150);
-        LoadDialogMessage = new puText            (
-                       (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
+        LoadDialogMessage
+            = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
         LoadDialogMessage ->    setLabel          ("File Name:");
 
         LoadDialogInput   = new puInput           (50, 70, 300, 100);
@@ -387,7 +412,7 @@ void ConfirmExitDialogInit(void)
     char *s;
 
     //  printf("ConfirmExitDialogInit\n");
-    int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
+    int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
 
     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
@@ -432,24 +457,24 @@ void helpCb (puObject *)
 #  endif
 #endif
        
-#if !defined(WIN32)
-    string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
+    SGPath path( globals->get_fg_root() );
+    path.append( "Docs/index.html" );
        
+    string help_app = fgGetString("/sim/startup/browser-app");
+
     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
-        command = "netscape -remote \"openURL(" + url + ")\" &";
+        command = help_app + " -remote \"openURL(" + path.str() + ")\"";
     } else {
-        command = "netscape " + url + " &";
+        command = help_app + " " + path.str();
     }
-#else
-    command = "webrun.bat";
+#if !defined(WIN32)
+    command += " &";
 #endif
        
     system( command.c_str() );
-    //string text = "Help started in netscape window.";
-
-    //mkDialog (text.c_str());
     mkDialog ("Help started in netscape window.");
 }
+
 #define TR_HIRES_SNAP
 #if defined( TR_HIRES_SNAP)
 #include <simgear/screen/tr.h>
@@ -495,7 +520,7 @@ void fgHiResDump()
     glLoadIdentity();
     ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
     float fov = globals->get_current_view()->get_fov();
-    ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
+    ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
     // ssgSetNearFar( 10.0f, 120000.0f );
     ssgSetNearFar( 0.5f, 1200000.0f );
 
@@ -647,7 +672,7 @@ void fgHiResDump()
 #endif // #if defined( TR_HIRES_SNAP)
 
 
-#if defined( WIN32 ) && !defined( __CYGWIN__)
+#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
 
 static void rotateView( double roll, double pitch, double yaw )
 {
@@ -686,7 +711,7 @@ GLubyte *hiResScreenCapture( int multiplier )
 #endif
 
 
-#if defined( WIN32 ) && !defined( __CYGWIN__)
+#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
 // win32 print screen function
 void printScreen ( puObject *obj ) {
     bool show_pu_cursor = false;
@@ -818,7 +843,7 @@ The menu stuff
 ---------------------------------------------------------------------*/
 char *fileSubmenu               [] = {
     "Exit", /* "Close", "---------", */
-#if defined( WIN32 ) && !defined( __CYGWIN__)
+#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
     "Print",
 #endif
     "Snap Shot",
@@ -831,7 +856,7 @@ char *fileSubmenu               [] = {
 };
 puCallback fileSubmenuCb        [] = {
     MayBeGoodBye, /* hideMenuCb, NULL, */
-#if defined( WIN32 ) && !defined( __CYGWIN__)
+#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
     printScreen, 
 #endif
     /* NULL, notCb, */
@@ -1019,5 +1044,9 @@ void guiInit()
     mainMenuBar-> close ();
     // Set up menu bar toggle
     gui_menu_on = ~0;
+
+    if (fgGetString("/sim/flight-model") == "ada") {
+        guiToggleMenu(); // Menu off by default
+    }
 }