]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/gui_funcs.cxx
Melchior: Make line wrapping in textboxes configurable, and enable it by default
[flightgear.git] / src / GUI / gui_funcs.cxx
index d124c00464c128f5f3f5edc612be42e20a651cbc..559d2ffb575b6d6f559ffd99140db785e1f0b9c4 100644 (file)
@@ -40,7 +40,7 @@
 #  include <windows.h>
 #endif
 
-#include GLUT_H
+#include SG_GL_H
 
 #if defined(FX) && defined(XMESA)
 #  include <GL/xmesa.h>
@@ -60,6 +60,8 @@
 # endif
 #endif
 
+#include <plib/ssg.h>
+
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/sg_path.hxx>
 #include <Aircraft/aircraft.hxx>
 #include <Airports/simple.hxx>
 #include <Autopilot/auto_gui.hxx>
-#include <Autopilot/newauto.hxx>
 #include <Cockpit/panel.hxx>
 #include <Controls/controls.hxx>
 #include <FDM/flight.hxx>
+#include <Main/main.hxx>
 #include <Main/fg_init.hxx>
 #include <Main/fg_io.hxx>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
+#include <Main/renderer.hxx>
 #include <Main/viewmgr.hxx>
 
-#ifdef FG_NETWORK_OLK
-#include <NetworkOLK/network.h>
-#endif
-   
 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
 #  include <simgear/screen/win32-printer.h>
 #  include <simgear/screen/GlBitmaps.h>
@@ -90,7 +89,6 @@
 
 #include "gui.h"
 #include "gui_local.hxx"
-#include "net_dlg.hxx"
 #include "preset_dlg.hxx"
 #include "prop_picker.hxx"
 #include "sgVec3Slider.hxx"
 SG_USING_STD(string);
 SG_USING_STD(cout);
 
-// 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 void fgHUDalphaAdjust( puObject * );
 
 // from cockpit.cxx
 extern void fgLatLonFormatToggle( puObject *);
 
-#ifdef FG_NETWORK_OLK
-extern void net_fgd_scan(puObject *cb);
-#endif // #ifdef FG_NETWORK_OLK
-
 #if defined( TR_HIRES_SNAP)
 #include <simgear/screen/tr.h>
-extern void trRenderFrame( void );
 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;
@@ -153,9 +139,9 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
         {"loadFlight", loadFlight},
         {"reInit", reInit},
 #ifdef TR_HIRES_SNAP
-        {"dumpHiResSnapShot", dumpHiResSnapShot},
+        {"dumpHiResSnapShot", fgHiResDumpWrapper},
 #endif
-        {"dumpSnapShot", dumpSnapShot},
+        {"dumpSnapShot", fgDumpSnapShotWrapper},
 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
         {"printScreen", printScreen},
 #endif
@@ -176,22 +162,12 @@ const __fg_gui_fn_t __fg_gui_fn[] = {
         {"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
@@ -245,26 +221,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)
 {
@@ -309,7 +265,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");
@@ -420,14 +376,8 @@ void guiTogglePanel(puObject *cb)
   else
     fgSetBool("/sim/panel/visibility", true);
 
-  fgReshape(fgGetInt("/sim/startup/xsize"),
-           fgGetInt("/sim/startup/ysize"));
-}
-    
-//void MenuHideMenuCb(puObject *cb)
-void hideMenuCb (puObject *cb)
-{
-    guiToggleMenu();
+  globals->get_renderer()->resize(fgGetInt("/sim/startup/xsize"),
+                                  fgGetInt("/sim/startup/ysize"));
 }
 
 void goodBye(puObject *)
@@ -436,15 +386,6 @@ void goodBye(puObject *)
     //      "Program exiting normally at user request." );
     cout << "Program exiting normally at user request." << endl;
 
-#ifdef FG_NETWORK_OLK    
-    if ( fgGetBool("/sim/networking/network-olk") ) {
-       if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
-    }
-#endif
-
-    // close all external I/O connections
-    globals->get_io()->shutdown_all();
-
     exit(0);
 }
 
@@ -574,54 +515,40 @@ void fgHiResDump()
     FILE *f;
     string message;
     bool show_pu_cursor = false;
-    bool show_menu = false;
     char *filename = new char [24];
     static int count = 1;
 
     static const SGPropertyNode *master_freeze
-       = fgGetNode("/sim/freeze/master");
+        = fgGetNode("/sim/freeze/master");
 
     bool freeze = master_freeze->getBoolValue();
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", true);
     }
 
-    if(gui_menu_on) {
-        show_menu = true;
-        guiToggleMenu();
-    }
-       
+    TurnCursorOff();
     if ( !puCursorIsHidden() ) {
-        show_pu_cursor = true;
-        puHideCursor();
+       show_pu_cursor = true;
+       puHideCursor();
     }
 
-    fgInitVisuals();
-    fgReshape( fgGetInt("/sim/startup/xsize"),
-               fgGetInt("/sim/startup/ysize") );
+    FGRenderer *renderer = globals->get_renderer();
+    renderer->init();
+    renderer->resize( fgGetInt("/sim/startup/xsize"),
+                      fgGetInt("/sim/startup/ysize") );
 
     // we need two render frames here to clear the menu and cursor
     // ... not sure why but doing an extra fgRenderFrame() shouldn't
     // hurt anything
-    fgRenderFrame();
-    fgRenderFrame();
-
-    // Make sure we have SSG projection primed for current view
-    glMatrixMode(GL_MODELVIEW);
-    glLoadIdentity();
-    ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
-    ssgSetFOV( globals->get_current_view()->get_h_fov(),
-              globals->get_current_view()->get_v_fov() );
-    // ssgSetNearFar( 10.0f, 120000.0f );
-    ssgSetNearFar( 0.5f, 1200000.0f );
+    renderer->update( true );
+    renderer->update( true );
 
-       
     // This ImageSize stuff is a temporary hack
     // should probably use 128x128 tile size and
     // support any image size
 
     // This should be a requester to get multiplier from user
-    int multiplier = 3;
+    int multiplier = fgGetInt("/sim/startup/hires-multiplier", 3);
     int width = fgGetInt("/sim/startup/xsize");
     int height = fgGetInt("/sim/startup/ysize");
        
@@ -686,8 +613,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;
@@ -695,12 +622,13 @@ void fgHiResDump()
         trBeginTile(tr);
         int curColumn = trGet(tr, TR_CURRENT_COLUMN);
         int curRow =  trGet(tr, TR_CURRENT_ROW);
-        trRenderFrame();
+        renderer->update( false );
         if ( do_hud )
             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);
 
@@ -731,7 +659,7 @@ void fgHiResDump()
 
     }
 
-    fgReshape( width, height );
+    renderer->resize( width, height );
 
     trDelete(tr);
 
@@ -750,13 +678,12 @@ void fgHiResDump()
 
     delete [] filename;
 
-    if( show_menu )
-        guiToggleMenu();
-
     if ( show_pu_cursor ) {
         puShowCursor();
     }
 
+    TurnCursorOn();
+
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", false);
     }
@@ -778,19 +705,19 @@ GLubyte *hiResScreenCapture( int multiplier )
     float fov = oldfov / multiplier;
     FGViewer *v = globals->get_current_view();
     fgSetDouble("/sim/current-view/field-of-view", fov);
-    fgInitVisuals();
+    globals->get_renderer()->init();
     int cur_width = fgGetInt("/sim/startup/xsize");
     int cur_height = fgGetInt("/sim/startup/ysize");
-    if (b1) delete( b1 );
+    delete( b1 );
     // New empty (mostly) bitmap
     b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
     int x,y;
     for ( y = 0; y < multiplier; y++ ) {
        for ( x = 0; x < multiplier; x++ ) {
-           fgReshape( cur_width, cur_height );
+           globals->get_renderer()->resize( cur_width, cur_height );
            // pan to tile
            rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
-           fgRenderFrame();
+           globals->get_renderer()->update( false );
            // restore view
            GlBitmap b2;
            b1->copyBitmap( &b2, cur_width*x, cur_height*y );
@@ -811,17 +738,13 @@ void printScreen ( puObject *obj ) {
        puHideCursor();
     }
     // BusyCursor( 0 );
-    mainMenuBar->hide();
 
     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
     int cur_width = fgGetInt("/sim/startup/xsize");
     int cur_height = fgGetInt("/sim/startup/ysize");
     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
-       p.End( hiResScreenCapture(3) );
+    p.End( hiResScreenCapture(3) );
 
-    if( gui_menu_on ) {
-       mainMenuBar->reveal();
-    }
     // BusyCursor(1);
     if ( show_pu_cursor ) {
        puShowCursor();
@@ -831,12 +754,12 @@ void printScreen ( puObject *obj ) {
 #endif // #ifdef WIN32
 
 
-void dumpSnapShot ( puObject *obj ) {
+void fgDumpSnapShotWrapper ( puObject *obj ) {
     fgDumpSnapShot();
 }
 
 
-void dumpHiResSnapShot ( puObject *obj ) {
+void fgHiResDumpWrapper ( puObject *obj ) {
     fgHiResDump();
 }
 
@@ -856,22 +779,22 @@ void fgDumpSnapShot () {
         fgSetBool("/sim/freeze/master", true);
     }
 
-    mainMenuBar->hide();
     TurnCursorOff();
     if ( !puCursorIsHidden() ) {
        show_pu_cursor = true;
        puHideCursor();
     }
 
-    fgInitVisuals();
-    fgReshape( fgGetInt("/sim/startup/xsize"),
-              fgGetInt("/sim/startup/ysize") );
+    FGRenderer *renderer = globals->get_renderer();
+    renderer->init();
+    renderer->resize( fgGetInt("/sim/startup/xsize"),
+                        fgGetInt("/sim/startup/ysize") );
 
     // we need two render frames here to clear the menu and cursor
     // ... not sure why but doing an extra fgRenderFrame() shouldn't
     // hurt anything
-    fgRenderFrame();
-    fgRenderFrame();
+    renderer->update( true );
+    renderer->update( true );
 
     while (count < 1000) {
         FILE *fp;
@@ -900,34 +823,9 @@ void fgDumpSnapShot () {
     }
 
     TurnCursorOn();
-    if( gui_menu_on ) {
-       mainMenuBar->reveal();
-    }
 
     if ( !freeze ) {
         fgSetBool("/sim/freeze/master", false);
     }
 }
 
-#ifdef FG_NETWORK_OLK
-void net_display_toggle( puObject *cb)
-{
-       net_hud_display = (net_hud_display) ? 0 : 1;
-       printf("Toggle net_hud_display : %d\n", net_hud_display);
-}
-
-void net_register( puObject *cb)
-{
-       fgd_send_com( "1", FGFS_host );
-       net_is_registered = 0;
-       printf("Registering to deamon\n");
-}
-
-void net_unregister( puObject *cb)
-{
-       fgd_send_com( "8", FGFS_host );
-       net_is_registered = -1;
-       printf("Unregistering from deamon\n");
-}
-
-#endif // #ifdef FG_NETWORK_OLK