1 /**************************************************************************
4 * Based on gui.cxx and renamed on 2002/08/13 by Erik Hofman.
6 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
9 * Additional mouse supported added by David Megginson, 1999.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of the
14 * License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 **************************************************************************/
33 #include <simgear/compiler.h>
35 #ifdef SG_MATH_EXCEPTION_CLASH
46 #if defined(FX) && defined(XMESA)
47 # include <GL/xmesa.h>
58 # include <shellapi.h>
60 # include <sys/cygwin.h>
64 #include <simgear/constants.h>
65 #include <simgear/debug/logstream.hxx>
66 #include <simgear/misc/sg_path.hxx>
67 #include <simgear/screen/screen-dump.hxx>
69 #include <Include/general.hxx>
70 #include <Aircraft/aircraft.hxx>
71 #include <Airports/simple.hxx>
72 #include <Autopilot/auto_gui.hxx>
73 #include <Autopilot/newauto.hxx>
74 #include <Cockpit/panel.hxx>
75 #include <Controls/controls.hxx>
76 #include <FDM/flight.hxx>
77 #include <Main/fg_init.hxx>
78 #include <Main/fg_io.hxx>
79 #include <Main/globals.hxx>
80 #include <Main/fg_props.hxx>
81 #include <Main/viewmgr.hxx>
84 #include <NetworkOLK/network.h>
87 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
88 # include <simgear/screen/win32-printer.h>
89 # include <simgear/screen/GlBitmaps.h>
93 #include "gui_local.hxx"
94 #include "apt_dlg.hxx"
95 #include "net_dlg.hxx"
96 #include "sgVec3Slider.hxx"
97 #include "prop_picker.hxx"
101 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
105 // main.cxx hack, should come from an include someplace
106 extern void fgInitVisuals( void );
107 extern void fgReshape( int width, int height );
108 extern void fgRenderFrame( void );
110 extern void fgHUDalphaAdjust( puObject * );
113 extern void fgLatLonFormatToggle( puObject *);
115 #ifdef FG_NETWORK_OLK
116 extern void net_fgd_scan(puObject *cb);
117 #endif // #ifdef FG_NETWORK_OLK
119 #if defined( TR_HIRES_SNAP)
120 #include <simgear/screen/tr.h>
121 extern void trRenderFrame( void );
122 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
123 GLfloat x_end, GLfloat y_end );
126 extern puMenuBar *mainMenuBar;
128 puDialogBox *dialogBox = 0;
129 puFrame *dialogFrame = 0;
130 puText *dialogBoxMessage = 0;
131 puOneShot *dialogBoxOkButton = 0;
133 puDialogBox *YNdialogBox = 0;
134 puFrame *YNdialogFrame = 0;
135 puText *YNdialogBoxMessage = 0;
136 puOneShot *YNdialogBoxOkButton = 0;
137 puOneShot *YNdialogBoxNoButton = 0;
139 char *gui_msg_OK; // "OK"
140 char *gui_msg_NO; // "NO"
141 char *gui_msg_YES; // "YES"
142 char *gui_msg_CANCEL; // "CANCEL"
143 char *gui_msg_RESET; // "RESET"
145 char msg_OK[] = "OK";
146 char msg_NO[] = "NO";
147 char msg_YES[] = "YES";
148 char msg_CANCEL[] = "Cancel";
149 char msg_RESET[] = "Reset";
151 char global_dialog_string[256];
153 const __fg_gui_fn_t __fg_gui_fn[] = {
156 {"saveFlight", saveFlight},
157 {"loadFlight", loadFlight},
160 {"dumpHiResSnapShot", dumpHiResSnapShot},
162 {"dumpSnapShot", dumpSnapShot},
163 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
164 {"printScreen", printScreen},
166 {"MayBeGoodBye", MayBeGoodBye},
169 {"guiTogglePanel", guiTogglePanel},
170 {"PilotOffsetAdjust", PilotOffsetAdjust},
171 {"fgHUDalphaAdjust", fgHUDalphaAdjust},
172 {"prop_pickerView", prop_pickerView},
175 {"NewAirport", NewAirport},
178 #ifdef FG_NETWORK_OLK
179 {"net_display_toggle", net_display_toggle},
180 {"NewCallSign", NewCallSign},
181 {"net_fgd_scan", net_fgd_scan},
182 {"net_register", net_register},
183 {"net_unregister", net_unregister},
187 {"NewAltitude", NewAltitude},
188 {"AddWayPoint", AddWayPoint},
189 {"PopWayPoint", PopWayPoint},
190 {"ClearRoute", ClearRoute},
191 {"fgAPAdjust", fgAPAdjust},
192 {"fgLatLonFormatToggle", fgLatLonFormatToggle},
197 // Structure termination
202 /* ================ General Purpose Functions ================ */
204 void initDialog(void) {
205 // Initialize our GLOBAL GUI STRINGS
206 gui_msg_OK = msg_OK; // "OK"
207 gui_msg_NO = msg_NO; // "NO"
208 gui_msg_YES = msg_YES; // "YES"
209 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
210 gui_msg_RESET = msg_RESET; // "RESET"
213 // General Purpose Message Box
214 void mkDialog (const char *txt)
216 strncpy(global_dialog_string, txt, 256);
217 dialogBoxMessage->setLabel(global_dialog_string);
218 FG_PUSH_PUI_DIALOG( dialogBox );
221 // Message Box to report an error.
222 void guiErrorMessage (const char *txt)
224 SG_LOG(SG_GENERAL, SG_ALERT, txt);
229 // Message Box to report a throwable (usually an exception).
230 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
234 msg += throwable.getFormattedMessage();
235 if (!throwable.getOrigin().empty()) {
236 msg += "\n (reported by ";
237 msg += throwable.getOrigin();
240 SG_LOG(SG_GENERAL, SG_ALERT, msg);
242 mkDialog(msg.c_str());
245 // Toggle the Menu and Mouse display state
246 void guiToggleMenu(void)
249 // printf("Hiding Menu\n");
250 mainMenuBar->hide ();
251 #if defined(WIN32_CURSOR_TWEAKS_OFF)
252 if( mouse_mode == MOUSE_POINTER )
254 #endif // WIN32_CURSOR_TWEAKS_OFF
256 // printf("Showing Menu\n");
257 mainMenuBar->reveal();
262 gui_menu_on = ~gui_menu_on;
265 // Intercept the Escape Key
266 void ConfirmExitDialog(void)
268 FG_PUSH_PUI_DIALOG( YNdialogBox );
273 /* -----------------------------------------------------------------------
274 the Gui callback functions
275 ____________________________________________________________________*/
278 // Hier Neu :-) This is my newly added code
279 // Added by David Findlay <nedz@bigpond.com>
280 // on Sunday 3rd of December
282 // Start new Save Dialog Box
283 puDialogBox *SaveDialog = 0;
284 puFrame *SaveDialogFrame = 0;
285 puText *SaveDialogMessage = 0;
286 puInput *SaveDialogInput = 0;
288 puOneShot *SaveDialogOkButton = 0;
289 puOneShot *SaveDialogCancelButton = 0;
290 // static puOneShot *SaveDialogResetButton = 0;
292 // Default save filename
293 char saveFile[256] = "fgfs.sav";
296 void SaveDialogCancel(puObject *) {
297 FG_POP_PUI_DIALOG( SaveDialog );
300 // If press OK do this
301 void SaveDialogOk(puObject*) {
303 FG_POP_PUI_DIALOG( SaveDialog );
306 SaveDialogInput->getValue(&s);
309 cout << saveFile << endl;
310 if (output.good() && fgSaveFlight(output)) {
312 mkDialog("Saved flight");
313 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
315 mkDialog("Cannot save flight");
316 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
321 void saveFlight(puObject *cv) {
322 SaveDialog = new puDialogBox (150, 50);
324 SaveDialogFrame = new puFrame (0,0,350, 150);
326 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
327 SaveDialogMessage -> setLabel ("File Name:");
329 SaveDialogInput = new puInput (50, 70, 300, 100);
330 SaveDialogInput -> setValue (saveFile);
331 SaveDialogInput -> acceptInput();
333 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
334 SaveDialogOkButton -> setLegend (gui_msg_OK);
335 SaveDialogOkButton -> setCallback ( SaveDialogOk );
336 SaveDialogOkButton -> makeReturnDefault(TRUE);
338 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
339 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
340 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
342 FG_FINALIZE_PUI_DIALOG( SaveDialog );
344 SaveDialog -> reveal();
348 puDialogBox *LoadDialog = 0;
349 puFrame *LoadDialogFrame = 0;
350 puText *LoadDialogMessage = 0;
351 puInput *LoadDialogInput = 0;
353 puOneShot *LoadDialogOkButton = 0;
354 puOneShot *LoadDialogCancelButton = 0;
355 // static puOneShot *LoadDialogResetButton = 0;
357 // Default load filename
358 char loadFile[256] = "fgfs.sav";
360 // Do this if the person click okay
361 void LoadDialogOk(puObject *) {
363 FG_POP_PUI_DIALOG( LoadDialog );
366 LoadDialogInput->getValue(&l);
369 if (input.good() && fgLoadFlight(input)) {
371 mkDialog("Loaded flight");
372 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
374 mkDialog("Failed to load flight");
375 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
379 // Do this if the person presses cancel
380 void LoadDialogCancel(puObject *) {
381 FG_POP_PUI_DIALOG( LoadDialog );
384 // Create Load Dialog
385 void loadFlight(puObject *cb)
387 LoadDialog = new puDialogBox (150, 50);
389 LoadDialogFrame = new puFrame (0,0,350, 150);
391 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
392 LoadDialogMessage -> setLabel ("File Name:");
394 LoadDialogInput = new puInput (50, 70, 300, 100);
395 LoadDialogInput -> setValue (loadFile);
396 LoadDialogInput -> acceptInput();
398 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
399 LoadDialogOkButton -> setLegend (gui_msg_OK);
400 LoadDialogOkButton -> setCallback ( LoadDialogOk );
401 LoadDialogOkButton -> makeReturnDefault(TRUE);
403 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
404 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
405 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
407 FG_FINALIZE_PUI_DIALOG( LoadDialog );
409 LoadDialog -> reveal();
412 // This is the accessor function
413 void guiTogglePanel(puObject *cb)
415 if (fgGetBool("/sim/panel/visibility"))
416 fgSetBool("/sim/panel/visibility", false);
418 fgSetBool("/sim/panel/visibility", true);
420 fgReshape(fgGetInt("/sim/startup/xsize"),
421 fgGetInt("/sim/startup/ysize"));
424 //void MenuHideMenuCb(puObject *cb)
425 void hideMenuCb (puObject *cb)
430 void goodBye(puObject *)
432 // SG_LOG( SG_INPUT, SG_ALERT,
433 // "Program exiting normally at user request." );
434 cout << "Program exiting normally at user request." << endl;
436 #ifdef FG_NETWORK_OLK
437 if ( fgGetBool("/sim/networking/network-olk") ) {
438 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
442 // close all external I/O connections
443 globals->get_io()->shutdown_all();
449 void goAwayCb (puObject *me)
451 FG_POP_PUI_DIALOG( dialogBox );
454 void mkDialogInit (void)
456 // printf("mkDialogInit\n");
457 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
458 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
459 dialogBox = new puDialogBox (x, y); // 150, 50
461 dialogFrame = new puFrame (0,0,400,100);
462 dialogBoxMessage = new puText (10, 70);
463 dialogBoxMessage -> setLabel ("");
464 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
465 dialogBoxOkButton -> setLegend (gui_msg_OK);
466 dialogBoxOkButton -> makeReturnDefault (TRUE );
467 dialogBoxOkButton -> setCallback (goAwayCb);
469 FG_FINALIZE_PUI_DIALOG( dialogBox );
472 void MayBeGoodBye(puObject *)
477 void goAwayYesNoCb(puObject *me)
479 FG_POP_PUI_DIALOG( YNdialogBox);
482 void ConfirmExitDialogInit(void)
484 char msg[] = "Really Quit";
487 // printf("ConfirmExitDialogInit\n");
488 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
490 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
491 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
493 YNdialogBox = new puDialogBox (x, y); // 150, 50
495 YNdialogFrame = new puFrame (0,0,400, 100);
497 YNdialogBoxMessage = new puText (len, 70);
498 YNdialogBoxMessage -> setDefaultValue (msg);
499 YNdialogBoxMessage -> getDefaultValue (&s);
500 YNdialogBoxMessage -> setLabel (s);
502 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
503 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
504 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
505 YNdialogBoxOkButton -> setCallback (goodBye);
507 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
508 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
509 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
511 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
514 void notCb (puObject *)
516 mkDialog ("This function isn't implemented yet");
519 void helpCb (puObject *)
523 #if defined(FX) && !defined(WIN32)
524 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
525 if ( globals->get_fullscreen() ) {
526 globals->set_fullscreen(false);
527 XMesaSetFXmode( XMESA_FX_WINDOW );
532 SGPath path( globals->get_fg_root() );
533 path.append( "Docs/index.html" );
537 string help_app = fgGetString("/sim/startup/browser-app");
539 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
540 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
542 command = help_app + " " + path.str();
545 system( command.c_str() );
549 // Look for favorite browser
550 char Dummy[1024], ExecName[1024], browserParameter[1024];
551 char win32_name[1024];
553 cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
555 strcpy(win32_name,path.c_str());
558 FindExecutable(win32_name, Dummy, ExecName);
559 sprintf(browserParameter, "file:///%s", win32_name);
560 ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
565 mkDialog ("Help started in your web browser window.");
568 #if defined( TR_HIRES_SNAP)
573 bool show_pu_cursor = false;
574 bool show_menu = false;
575 char *filename = new char [24];
576 static int count = 1;
578 static const SGPropertyNode *master_freeze
579 = fgGetNode("/sim/freeze/master");
581 bool freeze = master_freeze->getBoolValue();
583 fgSetBool("/sim/freeze/master", true);
591 if ( !puCursorIsHidden() ) {
592 show_pu_cursor = true;
597 fgReshape( fgGetInt("/sim/startup/xsize"),
598 fgGetInt("/sim/startup/ysize") );
600 // we need two render frames here to clear the menu and cursor
601 // ... not sure why but doing an extra fgRenderFrame() shouldn't
606 // Make sure we have SSG projection primed for current view
607 glMatrixMode(GL_MODELVIEW);
609 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
610 ssgSetFOV( globals->get_current_view()->get_h_fov(),
611 globals->get_current_view()->get_v_fov() );
612 // ssgSetNearFar( 10.0f, 120000.0f );
613 ssgSetNearFar( 0.5f, 1200000.0f );
616 // This ImageSize stuff is a temporary hack
617 // should probably use 128x128 tile size and
618 // support any image size
620 // This should be a requester to get multiplier from user
622 int width = fgGetInt("/sim/startup/xsize");
623 int height = fgGetInt("/sim/startup/ysize");
625 /* allocate buffer large enough to store one tile */
626 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
628 printf("Malloc of tile buffer failed!\n");
632 int imageWidth = multiplier*width;
633 int imageHeight = multiplier*height;
635 /* allocate buffer to hold a row of tiles */
637 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
640 printf("Malloc of tile row buffer failed!\n");
643 TRcontext *tr = trNew();
644 trTileSize(tr, width, height, 0);
645 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
646 trImageSize(tr, imageWidth, imageHeight);
647 trRowOrder(tr, TR_TOP_TO_BOTTOM);
648 sgFrustum *frustum = ssgGetFrustum();
650 frustum->getLeft(), frustum->getRight(),
651 frustum->getBot(), frustum->getTop(),
652 frustum->getNear(), frustum->getFar());
654 /* Prepare ppm output file */
655 while (count < 1000) {
656 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
657 if ( (f = fopen(filename, "r")) == NULL )
661 f = fopen(filename, "wb");
663 printf("Couldn't open image file: %s\n", filename);
669 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
670 fprintf(f,"%i %i\n", imageWidth, imageHeight);
673 /* just to be safe... */
674 glPixelStorei(GL_PACK_ALIGNMENT, 1);
676 /* Because the HUD and Panel change the ViewPort we will
677 * need to handle some lowlevel stuff ourselves */
678 int ncols = trGet(tr, TR_COLUMNS);
679 int nrows = trGet(tr, TR_ROWS);
681 bool do_hud = fgGetBool("/sim/hud/visibility");
682 GLfloat hud_col_step = 640.0 / ncols;
683 GLfloat hud_row_step = 480.0 / nrows;
685 bool do_panel = fgPanelVisible();
686 GLfloat panel_col_step = current_panel->getWidth() / ncols;
687 GLfloat panel_row_step = current_panel->getHeight() / nrows;
693 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
694 int curRow = trGet(tr, TR_CURRENT_ROW);
697 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
698 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
700 current_panel->update( curColumn*panel_col_step, panel_col_step,
701 curRow*panel_row_step, panel_row_step );
702 more = trEndTile(tr);
704 /* save tile into tile row buffer*/
705 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
706 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
707 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
708 int xOffset = curColumn * bytesPerTileRow;
709 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
711 for (i=0;i<height;i++) {
712 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
713 tile + i*bytesPerTileRow, /* Src */
714 bytesPerCurrentTileRow); /* Byte count*/
717 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
718 /* write this buffered row of tiles to the file */
719 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
720 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
722 for (i=0;i<curTileHeight;i++) {
723 /* Remember, OpenGL images are bottom to top. Have to reverse. */
724 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
725 fwrite(rowPtr, 1, imageWidth*3, f);
731 fgReshape( width, height );
737 message = "Snap shot saved to ";
739 mkDialog (message.c_str());
744 // message = "Snap shot saved to ";
745 // message += filename;
746 // mkDialog (message.c_str());
753 if ( show_pu_cursor ) {
758 fgSetBool("/sim/freeze/master", false);
761 #endif // #if defined( TR_HIRES_SNAP)
764 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
766 void rotateView( double roll, double pitch, double yaw )
772 GLubyte *hiResScreenCapture( int multiplier )
774 float oldfov = fgGetDouble("/sim/current-view/field-of-view");
775 float fov = oldfov / multiplier;
776 FGViewer *v = globals->get_current_view();
777 fgSetDouble("/sim/current-view/field-of-view", fov);
779 int cur_width = fgGetInt("/sim/startup/xsize");
780 int cur_height = fgGetInt("/sim/startup/ysize");
781 if (b1) delete( b1 );
782 // New empty (mostly) bitmap
783 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
785 for ( y = 0; y < multiplier; y++ ) {
786 for ( x = 0; x < multiplier; x++ ) {
787 fgReshape( cur_width, cur_height );
789 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
793 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
796 fgSetDouble("/sim/current-view/field-of-view", oldfov);
797 return b1->getBitmap();
801 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
802 // win32 print screen function
803 void printScreen ( puObject *obj ) {
804 bool show_pu_cursor = false;
806 if ( !puCursorIsHidden() ) {
807 show_pu_cursor = true;
813 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
814 int cur_width = fgGetInt("/sim/startup/xsize");
815 int cur_height = fgGetInt("/sim/startup/ysize");
816 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
817 p.End( hiResScreenCapture(3) );
820 mainMenuBar->reveal();
823 if ( show_pu_cursor ) {
828 #endif // #ifdef WIN32
831 void dumpSnapShot ( puObject *obj ) {
836 void dumpHiResSnapShot ( puObject *obj ) {
841 // do a screen snap shot
842 void fgDumpSnapShot () {
843 bool show_pu_cursor = false;
844 char *filename = new char [24];
846 static int count = 1;
848 static const SGPropertyNode *master_freeze
849 = fgGetNode("/sim/freeze/master");
851 bool freeze = master_freeze->getBoolValue();
853 fgSetBool("/sim/freeze/master", true);
858 if ( !puCursorIsHidden() ) {
859 show_pu_cursor = true;
864 fgReshape( fgGetInt("/sim/startup/xsize"),
865 fgGetInt("/sim/startup/ysize") );
867 // we need two render frames here to clear the menu and cursor
868 // ... not sure why but doing an extra fgRenderFrame() shouldn't
873 while (count < 1000) {
875 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
876 if ( (fp = fopen(filename, "r")) == NULL )
881 if ( sg_glDumpWindow( filename,
882 fgGetInt("/sim/startup/xsize"),
883 fgGetInt("/sim/startup/ysize")) ) {
884 message = "Snap shot saved to ";
887 message = "Failed to save to ";
891 mkDialog (message.c_str());
895 if ( show_pu_cursor ) {
901 mainMenuBar->reveal();
905 fgSetBool("/sim/freeze/master", false);
909 #ifdef FG_NETWORK_OLK
910 void net_display_toggle( puObject *cb)
912 net_hud_display = (net_hud_display) ? 0 : 1;
913 printf("Toggle net_hud_display : %d\n", net_hud_display);
916 void net_register( puObject *cb)
918 fgd_send_com( "1", FGFS_host );
919 net_is_registered = 0;
920 printf("Registering to deamon\n");
923 void net_unregister( puObject *cb)
925 fgd_send_com( "8", FGFS_host );
926 net_is_registered = -1;
927 printf("Unregistering from deamon\n");
930 #endif // #ifdef FG_NETWORK_OLK