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
45 #if defined(FX) && defined(XMESA)
46 # include <GL/xmesa.h>
57 # include <shellapi.h>
59 # include <sys/cygwin.h>
63 #include <simgear/constants.h>
64 #include <simgear/debug/logstream.hxx>
65 #include <simgear/misc/sg_path.hxx>
66 #include <simgear/screen/screen-dump.hxx>
68 #include <Include/general.hxx>
69 #include <Aircraft/aircraft.hxx>
70 #include <Airports/simple.hxx>
71 #include <Autopilot/auto_gui.hxx>
72 #include <Autopilot/newauto.hxx>
73 #include <Cockpit/panel.hxx>
74 #include <Controls/controls.hxx>
75 #include <FDM/flight.hxx>
76 #include <Main/fg_init.hxx>
77 #include <Main/fg_io.hxx>
78 #include <Main/globals.hxx>
79 #include <Main/fg_props.hxx>
80 #include <Main/viewmgr.hxx>
83 #include <NetworkOLK/network.h>
86 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
87 # include <simgear/screen/win32-printer.h>
88 # include <simgear/screen/GlBitmaps.h>
92 #include "gui_local.hxx"
93 #include "net_dlg.hxx"
94 #include "preset_dlg.hxx"
95 #include "prop_picker.hxx"
96 #include "sgVec3Slider.hxx"
101 // main.cxx hack, should come from an include someplace
102 extern void fgInitVisuals( void );
103 extern void fgReshape( int width, int height );
104 extern void fgRenderFrame( void );
106 extern void fgHUDalphaAdjust( puObject * );
109 extern void fgLatLonFormatToggle( puObject *);
111 #ifdef FG_NETWORK_OLK
112 extern void net_fgd_scan(puObject *cb);
113 #endif // #ifdef FG_NETWORK_OLK
115 #if defined( TR_HIRES_SNAP)
116 #include <simgear/screen/tr.h>
117 extern void trRenderFrame( void );
118 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
119 GLfloat x_end, GLfloat y_end );
122 extern puMenuBar *mainMenuBar;
124 puDialogBox *dialogBox = 0;
125 puFrame *dialogFrame = 0;
126 puText *dialogBoxMessage = 0;
127 puOneShot *dialogBoxOkButton = 0;
129 puDialogBox *YNdialogBox = 0;
130 puFrame *YNdialogFrame = 0;
131 puText *YNdialogBoxMessage = 0;
132 puOneShot *YNdialogBoxOkButton = 0;
133 puOneShot *YNdialogBoxNoButton = 0;
135 char *gui_msg_OK; // "OK"
136 char *gui_msg_NO; // "NO"
137 char *gui_msg_YES; // "YES"
138 char *gui_msg_CANCEL; // "CANCEL"
139 char *gui_msg_RESET; // "RESET"
141 char msg_OK[] = "OK";
142 char msg_NO[] = "NO";
143 char msg_YES[] = "YES";
144 char msg_CANCEL[] = "Cancel";
145 char msg_RESET[] = "Reset";
147 char global_dialog_string[256];
149 const __fg_gui_fn_t __fg_gui_fn[] = {
152 {"saveFlight", saveFlight},
153 {"loadFlight", loadFlight},
156 {"dumpHiResSnapShot", dumpHiResSnapShot},
158 {"dumpSnapShot", dumpSnapShot},
159 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
160 {"printScreen", printScreen},
162 {"MayBeGoodBye", MayBeGoodBye},
165 {"guiTogglePanel", guiTogglePanel},
166 {"PilotOffsetAdjust", PilotOffsetAdjust},
167 {"fgHUDalphaAdjust", fgHUDalphaAdjust},
168 {"prop_pickerView", prop_pickerView},
171 {"fgPresetAirport", fgPresetAirport},
172 {"fgPresetRunway", fgPresetRunway},
173 {"fgPresetOffsetDistance", fgPresetOffsetDistance},
174 {"fgPresetAltitude", fgPresetAltitude},
175 {"fgPresetGlideslope", fgPresetGlideslope},
176 {"fgPresetAirspeed", fgPresetAirspeed},
177 {"fgPresetCommit", fgPresetCommit},
180 #ifdef FG_NETWORK_OLK
181 {"net_display_toggle", net_display_toggle},
182 {"NewCallSign", NewCallSign},
183 {"net_fgd_scan", net_fgd_scan},
184 {"net_register", net_register},
185 {"net_unregister", net_unregister},
189 {"NewAltitude", NewAltitude},
190 {"NewHeading", NewHeading},
191 {"AddWayPoint", AddWayPoint},
192 {"PopWayPoint", PopWayPoint},
193 {"ClearRoute", ClearRoute},
194 {"fgAPAdjust", fgAPAdjust},
195 {"fgLatLonFormatToggle", fgLatLonFormatToggle},
200 // Structure termination
205 /* ================ General Purpose Functions ================ */
207 void initDialog(void) {
208 // Initialize our GLOBAL GUI STRINGS
209 gui_msg_OK = msg_OK; // "OK"
210 gui_msg_NO = msg_NO; // "NO"
211 gui_msg_YES = msg_YES; // "YES"
212 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
213 gui_msg_RESET = msg_RESET; // "RESET"
216 // General Purpose Message Box
217 void mkDialog (const char *txt)
219 strncpy(global_dialog_string, txt, 256);
220 dialogBoxMessage->setLabel(global_dialog_string);
221 FG_PUSH_PUI_DIALOG( dialogBox );
224 // Message Box to report an error.
225 void guiErrorMessage (const char *txt)
227 SG_LOG(SG_GENERAL, SG_ALERT, txt);
232 // Message Box to report a throwable (usually an exception).
233 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
237 msg += throwable.getFormattedMessage();
238 if (!throwable.getOrigin().empty()) {
239 msg += "\n (reported by ";
240 msg += throwable.getOrigin();
243 SG_LOG(SG_GENERAL, SG_ALERT, msg);
245 mkDialog(msg.c_str());
248 // Toggle the Menu and Mouse display state
249 void guiToggleMenu(void)
252 // printf("Hiding Menu\n");
253 mainMenuBar->hide ();
254 #if defined(WIN32_CURSOR_TWEAKS_OFF)
255 if( mouse_mode == MOUSE_POINTER )
257 #endif // WIN32_CURSOR_TWEAKS_OFF
259 // printf("Showing Menu\n");
260 mainMenuBar->reveal();
265 gui_menu_on = ~gui_menu_on;
268 // Intercept the Escape Key
269 void ConfirmExitDialog(void)
271 FG_PUSH_PUI_DIALOG( YNdialogBox );
276 /* -----------------------------------------------------------------------
277 the Gui callback functions
278 ____________________________________________________________________*/
281 // Hier Neu :-) This is my newly added code
282 // Added by David Findlay <nedz@bigpond.com>
283 // on Sunday 3rd of December
285 // Start new Save Dialog Box
286 puDialogBox *SaveDialog = 0;
287 puFrame *SaveDialogFrame = 0;
288 puText *SaveDialogMessage = 0;
289 puInput *SaveDialogInput = 0;
291 puOneShot *SaveDialogOkButton = 0;
292 puOneShot *SaveDialogCancelButton = 0;
293 // static puOneShot *SaveDialogResetButton = 0;
295 // Default save filename
296 char saveFile[256] = "fgfs.sav";
299 void SaveDialogCancel(puObject *) {
300 FG_POP_PUI_DIALOG( SaveDialog );
303 // If press OK do this
304 void SaveDialogOk(puObject*) {
306 FG_POP_PUI_DIALOG( SaveDialog );
309 SaveDialogInput->getValue(&s);
312 cout << saveFile << endl;
313 if (output.good() && fgSaveFlight(output)) {
315 mkDialog("Saved flight");
316 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
318 mkDialog("Cannot save flight");
319 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
324 void saveFlight(puObject *cv) {
325 SaveDialog = new puDialogBox (150, 50);
327 SaveDialogFrame = new puFrame (0,0,350, 150);
329 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
330 SaveDialogMessage -> setLabel ("File Name:");
332 SaveDialogInput = new puInput (50, 70, 300, 100);
333 SaveDialogInput -> setValue (saveFile);
334 SaveDialogInput -> acceptInput();
336 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
337 SaveDialogOkButton -> setLegend (gui_msg_OK);
338 SaveDialogOkButton -> setCallback ( SaveDialogOk );
339 SaveDialogOkButton -> makeReturnDefault(TRUE);
341 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
342 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
343 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
345 FG_FINALIZE_PUI_DIALOG( SaveDialog );
347 SaveDialog -> reveal();
351 puDialogBox *LoadDialog = 0;
352 puFrame *LoadDialogFrame = 0;
353 puText *LoadDialogMessage = 0;
354 puInput *LoadDialogInput = 0;
356 puOneShot *LoadDialogOkButton = 0;
357 puOneShot *LoadDialogCancelButton = 0;
358 // static puOneShot *LoadDialogResetButton = 0;
360 // Default load filename
361 char loadFile[256] = "fgfs.sav";
363 // Do this if the person click okay
364 void LoadDialogOk(puObject *) {
366 FG_POP_PUI_DIALOG( LoadDialog );
369 LoadDialogInput->getValue(&l);
372 if (input.good() && fgLoadFlight(input)) {
374 mkDialog("Loaded flight");
375 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
377 mkDialog("Failed to load flight");
378 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
382 // Do this if the person presses cancel
383 void LoadDialogCancel(puObject *) {
384 FG_POP_PUI_DIALOG( LoadDialog );
387 // Create Load Dialog
388 void loadFlight(puObject *cb)
390 LoadDialog = new puDialogBox (150, 50);
392 LoadDialogFrame = new puFrame (0,0,350, 150);
394 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
395 LoadDialogMessage -> setLabel ("File Name:");
397 LoadDialogInput = new puInput (50, 70, 300, 100);
398 LoadDialogInput -> setValue (loadFile);
399 LoadDialogInput -> acceptInput();
401 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
402 LoadDialogOkButton -> setLegend (gui_msg_OK);
403 LoadDialogOkButton -> setCallback ( LoadDialogOk );
404 LoadDialogOkButton -> makeReturnDefault(TRUE);
406 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
407 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
408 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
410 FG_FINALIZE_PUI_DIALOG( LoadDialog );
412 LoadDialog -> reveal();
415 // This is the accessor function
416 void guiTogglePanel(puObject *cb)
418 if (fgGetBool("/sim/panel/visibility"))
419 fgSetBool("/sim/panel/visibility", false);
421 fgSetBool("/sim/panel/visibility", true);
423 fgReshape(fgGetInt("/sim/startup/xsize"),
424 fgGetInt("/sim/startup/ysize"));
427 //void MenuHideMenuCb(puObject *cb)
428 void hideMenuCb (puObject *cb)
433 void goodBye(puObject *)
435 // SG_LOG( SG_INPUT, SG_ALERT,
436 // "Program exiting normally at user request." );
437 cout << "Program exiting normally at user request." << endl;
439 #ifdef FG_NETWORK_OLK
440 if ( fgGetBool("/sim/networking/network-olk") ) {
441 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
445 // close all external I/O connections
446 globals->get_io()->shutdown_all();
452 void goAwayCb (puObject *me)
454 FG_POP_PUI_DIALOG( dialogBox );
457 void mkDialogInit (void)
459 // printf("mkDialogInit\n");
460 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
461 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
462 dialogBox = new puDialogBox (x, y); // 150, 50
464 dialogFrame = new puFrame (0,0,400,100);
465 dialogBoxMessage = new puText (10, 70);
466 dialogBoxMessage -> setLabel ("");
467 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
468 dialogBoxOkButton -> setLegend (gui_msg_OK);
469 dialogBoxOkButton -> makeReturnDefault (TRUE );
470 dialogBoxOkButton -> setCallback (goAwayCb);
472 FG_FINALIZE_PUI_DIALOG( dialogBox );
475 void MayBeGoodBye(puObject *)
480 void goAwayYesNoCb(puObject *me)
482 FG_POP_PUI_DIALOG( YNdialogBox);
485 void ConfirmExitDialogInit(void)
487 char msg[] = "Really Quit";
490 // printf("ConfirmExitDialogInit\n");
491 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
493 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
494 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
496 YNdialogBox = new puDialogBox (x, y); // 150, 50
498 YNdialogFrame = new puFrame (0,0,400, 100);
500 YNdialogBoxMessage = new puText (len, 70);
501 YNdialogBoxMessage -> setDefaultValue (msg);
502 YNdialogBoxMessage -> getDefaultValue (&s);
503 YNdialogBoxMessage -> setLabel (s);
505 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
506 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
507 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
508 YNdialogBoxOkButton -> setCallback (goodBye);
510 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
511 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
512 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
514 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
517 void notCb (puObject *)
519 mkDialog ("This function isn't implemented yet");
522 void helpCb (puObject *)
526 #if defined(FX) && !defined(WIN32)
527 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
528 if ( globals->get_fullscreen() ) {
529 globals->set_fullscreen(false);
530 XMesaSetFXmode( XMESA_FX_WINDOW );
535 SGPath path( globals->get_fg_root() );
536 path.append( "Docs/index.html" );
540 string help_app = fgGetString("/sim/startup/browser-app");
542 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
543 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
545 command = help_app + " " + path.str();
548 system( command.c_str() );
552 // Look for favorite browser
553 char Dummy[1024], ExecName[1024], browserParameter[1024];
554 char win32_name[1024];
556 cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
558 strcpy(win32_name,path.c_str());
561 FindExecutable(win32_name, Dummy, ExecName);
562 sprintf(browserParameter, "file:///%s", win32_name);
563 ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
568 mkDialog ("Help started in your web browser window.");
571 #if defined( TR_HIRES_SNAP)
576 bool show_pu_cursor = false;
577 bool show_menu = false;
578 char *filename = new char [24];
579 static int count = 1;
581 static const SGPropertyNode *master_freeze
582 = fgGetNode("/sim/freeze/master");
584 bool freeze = master_freeze->getBoolValue();
586 fgSetBool("/sim/freeze/master", true);
594 if ( !puCursorIsHidden() ) {
595 show_pu_cursor = true;
600 fgReshape( fgGetInt("/sim/startup/xsize"),
601 fgGetInt("/sim/startup/ysize") );
603 // we need two render frames here to clear the menu and cursor
604 // ... not sure why but doing an extra fgRenderFrame() shouldn't
609 // Make sure we have SSG projection primed for current view
610 glMatrixMode(GL_MODELVIEW);
612 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
613 ssgSetFOV( globals->get_current_view()->get_h_fov(),
614 globals->get_current_view()->get_v_fov() );
615 // ssgSetNearFar( 10.0f, 120000.0f );
616 ssgSetNearFar( 0.5f, 1200000.0f );
619 // This ImageSize stuff is a temporary hack
620 // should probably use 128x128 tile size and
621 // support any image size
623 // This should be a requester to get multiplier from user
625 int width = fgGetInt("/sim/startup/xsize");
626 int height = fgGetInt("/sim/startup/ysize");
628 /* allocate buffer large enough to store one tile */
629 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
631 printf("Malloc of tile buffer failed!\n");
635 int imageWidth = multiplier*width;
636 int imageHeight = multiplier*height;
638 /* allocate buffer to hold a row of tiles */
640 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
643 printf("Malloc of tile row buffer failed!\n");
646 TRcontext *tr = trNew();
647 trTileSize(tr, width, height, 0);
648 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
649 trImageSize(tr, imageWidth, imageHeight);
650 trRowOrder(tr, TR_TOP_TO_BOTTOM);
651 sgFrustum *frustum = ssgGetFrustum();
653 frustum->getLeft(), frustum->getRight(),
654 frustum->getBot(), frustum->getTop(),
655 frustum->getNear(), frustum->getFar());
657 /* Prepare ppm output file */
658 while (count < 1000) {
659 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
660 if ( (f = fopen(filename, "r")) == NULL )
664 f = fopen(filename, "wb");
666 printf("Couldn't open image file: %s\n", filename);
672 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
673 fprintf(f,"%i %i\n", imageWidth, imageHeight);
676 /* just to be safe... */
677 glPixelStorei(GL_PACK_ALIGNMENT, 1);
679 /* Because the HUD and Panel change the ViewPort we will
680 * need to handle some lowlevel stuff ourselves */
681 int ncols = trGet(tr, TR_COLUMNS);
682 int nrows = trGet(tr, TR_ROWS);
684 bool do_hud = fgGetBool("/sim/hud/visibility");
685 GLfloat hud_col_step = 640.0 / ncols;
686 GLfloat hud_row_step = 480.0 / nrows;
688 bool do_panel = fgPanelVisible();
689 GLfloat panel_col_step = current_panel->getWidth() / ncols;
690 GLfloat panel_row_step = current_panel->getHeight() / nrows;
696 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
697 int curRow = trGet(tr, TR_CURRENT_ROW);
700 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
701 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
703 current_panel->update( curColumn*panel_col_step, panel_col_step,
704 curRow*panel_row_step, panel_row_step );
705 more = trEndTile(tr);
707 /* save tile into tile row buffer*/
708 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
709 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
710 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
711 int xOffset = curColumn * bytesPerTileRow;
712 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
714 for (i=0;i<height;i++) {
715 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
716 tile + i*bytesPerTileRow, /* Src */
717 bytesPerCurrentTileRow); /* Byte count*/
720 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
721 /* write this buffered row of tiles to the file */
722 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
723 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
725 for (i=0;i<curTileHeight;i++) {
726 /* Remember, OpenGL images are bottom to top. Have to reverse. */
727 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
728 fwrite(rowPtr, 1, imageWidth*3, f);
734 fgReshape( width, height );
740 message = "Snap shot saved to ";
742 mkDialog (message.c_str());
747 // message = "Snap shot saved to ";
748 // message += filename;
749 // mkDialog (message.c_str());
756 if ( show_pu_cursor ) {
761 fgSetBool("/sim/freeze/master", false);
764 #endif // #if defined( TR_HIRES_SNAP)
767 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
769 void rotateView( double roll, double pitch, double yaw )
775 GLubyte *hiResScreenCapture( int multiplier )
777 float oldfov = fgGetDouble("/sim/current-view/field-of-view");
778 float fov = oldfov / multiplier;
779 FGViewer *v = globals->get_current_view();
780 fgSetDouble("/sim/current-view/field-of-view", fov);
782 int cur_width = fgGetInt("/sim/startup/xsize");
783 int cur_height = fgGetInt("/sim/startup/ysize");
784 if (b1) delete( b1 );
785 // New empty (mostly) bitmap
786 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
788 for ( y = 0; y < multiplier; y++ ) {
789 for ( x = 0; x < multiplier; x++ ) {
790 fgReshape( cur_width, cur_height );
792 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
796 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
799 fgSetDouble("/sim/current-view/field-of-view", oldfov);
800 return b1->getBitmap();
804 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
805 // win32 print screen function
806 void printScreen ( puObject *obj ) {
807 bool show_pu_cursor = false;
809 if ( !puCursorIsHidden() ) {
810 show_pu_cursor = true;
816 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
817 int cur_width = fgGetInt("/sim/startup/xsize");
818 int cur_height = fgGetInt("/sim/startup/ysize");
819 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
820 p.End( hiResScreenCapture(3) );
823 mainMenuBar->reveal();
826 if ( show_pu_cursor ) {
831 #endif // #ifdef WIN32
834 void dumpSnapShot ( puObject *obj ) {
839 void dumpHiResSnapShot ( puObject *obj ) {
844 // do a screen snap shot
845 void fgDumpSnapShot () {
846 bool show_pu_cursor = false;
847 char *filename = new char [24];
849 static int count = 1;
851 static const SGPropertyNode *master_freeze
852 = fgGetNode("/sim/freeze/master");
854 bool freeze = master_freeze->getBoolValue();
856 fgSetBool("/sim/freeze/master", true);
861 if ( !puCursorIsHidden() ) {
862 show_pu_cursor = true;
867 fgReshape( fgGetInt("/sim/startup/xsize"),
868 fgGetInt("/sim/startup/ysize") );
870 // we need two render frames here to clear the menu and cursor
871 // ... not sure why but doing an extra fgRenderFrame() shouldn't
876 while (count < 1000) {
878 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
879 if ( (fp = fopen(filename, "r")) == NULL )
884 if ( sg_glDumpWindow( filename,
885 fgGetInt("/sim/startup/xsize"),
886 fgGetInt("/sim/startup/ysize")) ) {
887 message = "Snap shot saved to ";
890 message = "Failed to save to ";
894 mkDialog (message.c_str());
898 if ( show_pu_cursor ) {
904 mainMenuBar->reveal();
908 fgSetBool("/sim/freeze/master", false);
912 #ifdef FG_NETWORK_OLK
913 void net_display_toggle( puObject *cb)
915 net_hud_display = (net_hud_display) ? 0 : 1;
916 printf("Toggle net_hud_display : %d\n", net_hud_display);
919 void net_register( puObject *cb)
921 fgd_send_com( "1", FGFS_host );
922 net_is_registered = 0;
923 printf("Registering to deamon\n");
926 void net_unregister( puObject *cb)
928 fgd_send_com( "8", FGFS_host );
929 net_is_registered = -1;
930 printf("Unregistering from deamon\n");
933 #endif // #ifdef FG_NETWORK_OLK