]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui_funcs.cxx
Moved random ground cover object management code (userdata.[ch]xx) over
[flightgear.git] / src / GUI / gui_funcs.cxx
index c3a05ed65a1c416d5c4e3cf1a5180753f8180d83..8c17c1ebf640c5f1eac71a1dcf4fab0c3092992c 100644 (file)
@@ -40,8 +40,7 @@
 #  include <windows.h>
 #endif
 
-#include <GL/glut.h>
-#include <GL/gl.h>
+#include GLUT_H
 
 #if defined(FX) && defined(XMESA)
 #  include <GL/xmesa.h>
 #include <stdlib.h>
 #include <string.h>
 
+// for help call back
+#ifdef WIN32
+# include <shellapi.h>
+# ifdef __CYGWIN__
+#  include <sys/cygwin.h>
+# endif
+#endif
+
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 
 #include "gui.h"
 #include "gui_local.hxx"
-#include "apt_dlg.hxx"
 #include "net_dlg.hxx"
-#include "sgVec3Slider.hxx"
+#include "preset_dlg.hxx"
 #include "prop_picker.hxx"
+#include "sgVec3Slider.hxx"
 
 SG_USING_STD(string);
-
-#ifndef SG_HAVE_NATIVE_SGI_COMPILERS
 SG_USING_STD(cout);
-#endif
 
 // main.cxx hack, should come from an include someplace
 extern void fgInitVisuals( void );
-extern void fgReshape( int width, int height );
 extern void fgRenderFrame( void );
 
-extern FGInterface cur_view_fdm;
 extern void fgHUDalphaAdjust( puObject * );
 
 // from cockpit.cxx
@@ -109,8 +111,6 @@ extern void fgLatLonFormatToggle( puObject *);
 extern void net_fgd_scan(puObject *cb);
 #endif // #ifdef FG_NETWORK_OLK
 
-#define TR_HIRES_SNAP  1
-
 #if defined( TR_HIRES_SNAP)
 #include <simgear/screen/tr.h>
 extern void trRenderFrame( void );
@@ -118,8 +118,6 @@ extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
                          GLfloat x_end, GLfloat y_end );
 #endif
 
-extern puMenuBar    *mainMenuBar;
-
 puDialogBox  *dialogBox = 0;
 puFrame      *dialogFrame = 0;
 puText       *dialogBoxMessage = 0;
@@ -145,6 +143,61 @@ char msg_RESET[]  = "Reset";
 
 char global_dialog_string[256];
 
+const __fg_gui_fn_t __fg_gui_fn[] = {
+
+        // File
+        {"saveFlight", saveFlight},
+        {"loadFlight", loadFlight},
+        {"reInit", reInit},
+#ifdef TR_HIRES_SNAP
+        {"dumpHiResSnapShot", dumpHiResSnapShot},
+#endif
+        {"dumpSnapShot", dumpSnapShot},
+#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
+        {"printScreen", printScreen},
+#endif
+        {"MayBeGoodBye", MayBeGoodBye},
+
+        //View
+        {"guiTogglePanel", guiTogglePanel},
+        {"PilotOffsetAdjust", PilotOffsetAdjust},
+        {"fgHUDalphaAdjust", fgHUDalphaAdjust},
+        {"prop_pickerView", prop_pickerView},
+
+        // Environment
+        {"fgPresetAirport", fgPresetAirport},
+        {"fgPresetRunway", fgPresetRunway},
+        {"fgPresetOffsetDistance", fgPresetOffsetDistance},
+        {"fgPresetAltitude", fgPresetAltitude},
+        {"fgPresetGlideslope", fgPresetGlideslope},
+        {"fgPresetAirspeed", fgPresetAirspeed},
+        {"fgPresetCommit", fgPresetCommit},
+
+        // Network
+#ifdef FG_NETWORK_OLK
+        {"net_display_toggle", net_display_toggle},
+        {"NewCallSign", NewCallSign},
+        {"net_fgd_scan", net_fgd_scan},
+        {"net_register", net_register},
+        {"net_unregister", net_unregister},
+#endif
+
+        // Autopilot
+        {"NewAltitude", NewAltitude},
+       {"NewHeading", NewHeading},
+        {"AddWayPoint", AddWayPoint},
+        {"PopWayPoint", PopWayPoint},
+        {"ClearRoute", ClearRoute},
+        {"fgAPAdjust", fgAPAdjust},
+        {"fgLatLonFormatToggle", fgLatLonFormatToggle},
+
+        // Help
+        {"helpCb", helpCb},
+
+        // Structure termination
+        {"", NULL}
+};
+
 
 /* ================ General Purpose Functions ================ */
 
@@ -189,26 +242,6 @@ void guiErrorMessage (const char *txt, const sg_throwable &throwable)
       mkDialog(msg.c_str());
 }
 
-// Toggle the Menu and Mouse display state
-void guiToggleMenu(void)
-{
-    if( gui_menu_on ) {
-        // printf("Hiding Menu\n");
-        mainMenuBar->hide  ();
-#if defined(WIN32_CURSOR_TWEAKS_OFF)
-        if( mouse_mode == MOUSE_POINTER )
-            TurnCursorOff();
-#endif // WIN32_CURSOR_TWEAKS_OFF
-    } else {
-        // printf("Showing Menu\n");
-        mainMenuBar->reveal();
-#ifdef WIN32
-        TurnCursorOn();
-#endif // WIN32
-    }
-    gui_menu_on = ~gui_menu_on;
-}
-
 // Intercept the Escape Key
 void ConfirmExitDialog(void)
 {
@@ -253,7 +286,7 @@ void SaveDialogOk(puObject*) {
     SaveDialogInput->getValue(&s);
 
     ofstream output(s);
-    cout << saveFile << endl;
+    // cout << saveFile << endl;
     if (output.good() && fgSaveFlight(output)) {
        output.close();
        mkDialog("Saved flight");
@@ -367,12 +400,6 @@ void guiTogglePanel(puObject *cb)
   fgReshape(fgGetInt("/sim/startup/xsize"),
            fgGetInt("/sim/startup/ysize"));
 }
-    
-//void MenuHideMenuCb(puObject *cb)
-void hideMenuCb (puObject *cb)
-{
-    guiToggleMenu();
-}
 
 void goodBye(puObject *)
 {
@@ -387,7 +414,7 @@ void goodBye(puObject *)
 #endif
 
     // close all external I/O connections
-    fgIOShutdownAll();
+    globals->get_io()->shutdown_all();
 
     exit(0);
 }
@@ -480,6 +507,7 @@ void helpCb (puObject *)
     path.append( "Docs/index.html" );
        
 #if !defined(WIN32)
+
     string help_app = fgGetString("/sim/startup/browser-app");
 
     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
@@ -488,13 +516,27 @@ void helpCb (puObject *)
         command = help_app + " " + path.str();
     }
     command += " &";
+    system( command.c_str() );
+
 #else // WIN32
-       command = "start ";
-       command += path.str();
+
+    // Look for favorite browser
+    char Dummy[1024], ExecName[1024], browserParameter[1024];
+    char win32_name[1024];
+# ifdef __CYGWIN__
+    cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
+# else
+    strcpy(win32_name,path.c_str());
+# endif
+    Dummy[0] = 0;
+    FindExecutable(win32_name, Dummy, ExecName);
+    sprintf(browserParameter, "file:///%s", win32_name);
+    ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
+                   SW_SHOWNORMAL ) ;
+
 #endif
        
-    system( command.c_str() );
-    mkDialog ("Help started in netscape window.");
+    mkDialog ("Help started in your web browser window.");
 }
 
 #if defined( TR_HIRES_SNAP)
@@ -503,7 +545,6 @@ void fgHiResDump()
     FILE *f;
     string message;
     bool show_pu_cursor = false;
-    bool show_menu = false;
     char *filename = new char [24];
     static int count = 1;
 
@@ -515,11 +556,6 @@ void fgHiResDump()
         fgSetBool("/sim/freeze/master", true);
     }
 
-    if(gui_menu_on) {
-        show_menu = true;
-        guiToggleMenu();
-    }
-       
     if ( !puCursorIsHidden() ) {
         show_pu_cursor = true;
         puHideCursor();
@@ -615,8 +651,8 @@ void fgHiResDump()
     GLfloat hud_row_step = 480.0 / nrows;
        
     bool do_panel = fgPanelVisible();
-    GLfloat panel_col_step = current_panel->getWidth() / ncols;
-    GLfloat panel_row_step = current_panel->getHeight() / nrows;
+    GLfloat panel_col_step = globals->get_current_panel()->getWidth() / ncols;
+    GLfloat panel_row_step = globals->get_current_panel()->getHeight() / nrows;
        
     /* Draw tiles */
     int more = 1;
@@ -629,7 +665,8 @@ void fgHiResDump()
             fgUpdateHUD( curColumn*hud_col_step,      curRow*hud_row_step,
                          (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
         if (do_panel)
-            current_panel->update( curColumn*panel_col_step, panel_col_step,
+            globals->get_current_panel()->update(
+                                   curColumn*panel_col_step, panel_col_step,
                                    curRow*panel_row_step,    panel_row_step );
         more = trEndTile(tr);
 
@@ -679,9 +716,6 @@ void fgHiResDump()
 
     delete [] filename;
 
-    if( show_menu )
-        guiToggleMenu();
-
     if ( show_pu_cursor ) {
         puShowCursor();
     }
@@ -740,7 +774,6 @@ void printScreen ( puObject *obj ) {
        puHideCursor();
     }
     // BusyCursor( 0 );
-    mainMenuBar->hide();
 
     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
     int cur_width = fgGetInt("/sim/startup/xsize");
@@ -748,9 +781,6 @@ void printScreen ( puObject *obj ) {
     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
        p.End( hiResScreenCapture(3) );
 
-    if( gui_menu_on ) {
-       mainMenuBar->reveal();
-    }
     // BusyCursor(1);
     if ( show_pu_cursor ) {
        puShowCursor();
@@ -785,7 +815,6 @@ void fgDumpSnapShot () {
         fgSetBool("/sim/freeze/master", true);
     }
 
-    mainMenuBar->hide();
     TurnCursorOff();
     if ( !puCursorIsHidden() ) {
        show_pu_cursor = true;
@@ -829,9 +858,6 @@ void fgDumpSnapShot () {
     }
 
     TurnCursorOn();
-    if( gui_menu_on ) {
-       mainMenuBar->reveal();
-    }
 
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", false);