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 #if defined(FG_OLD_MENUBAR)
123 extern puMenuBar *mainMenuBar;
126 puDialogBox *dialogBox = 0;
127 puFrame *dialogFrame = 0;
128 puText *dialogBoxMessage = 0;
129 puOneShot *dialogBoxOkButton = 0;
131 puDialogBox *YNdialogBox = 0;
132 puFrame *YNdialogFrame = 0;
133 puText *YNdialogBoxMessage = 0;
134 puOneShot *YNdialogBoxOkButton = 0;
135 puOneShot *YNdialogBoxNoButton = 0;
137 char *gui_msg_OK; // "OK"
138 char *gui_msg_NO; // "NO"
139 char *gui_msg_YES; // "YES"
140 char *gui_msg_CANCEL; // "CANCEL"
141 char *gui_msg_RESET; // "RESET"
143 char msg_OK[] = "OK";
144 char msg_NO[] = "NO";
145 char msg_YES[] = "YES";
146 char msg_CANCEL[] = "Cancel";
147 char msg_RESET[] = "Reset";
149 char global_dialog_string[256];
151 const __fg_gui_fn_t __fg_gui_fn[] = {
154 {"saveFlight", saveFlight},
155 {"loadFlight", loadFlight},
158 {"dumpHiResSnapShot", dumpHiResSnapShot},
160 {"dumpSnapShot", dumpSnapShot},
161 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
162 {"printScreen", printScreen},
164 {"MayBeGoodBye", MayBeGoodBye},
167 {"guiTogglePanel", guiTogglePanel},
168 {"PilotOffsetAdjust", PilotOffsetAdjust},
169 {"fgHUDalphaAdjust", fgHUDalphaAdjust},
170 {"prop_pickerView", prop_pickerView},
173 {"fgPresetAirport", fgPresetAirport},
174 {"fgPresetRunway", fgPresetRunway},
175 {"fgPresetOffsetDistance", fgPresetOffsetDistance},
176 {"fgPresetAltitude", fgPresetAltitude},
177 {"fgPresetGlideslope", fgPresetGlideslope},
178 {"fgPresetAirspeed", fgPresetAirspeed},
179 {"fgPresetCommit", fgPresetCommit},
182 #ifdef FG_NETWORK_OLK
183 {"net_display_toggle", net_display_toggle},
184 {"NewCallSign", NewCallSign},
185 {"net_fgd_scan", net_fgd_scan},
186 {"net_register", net_register},
187 {"net_unregister", net_unregister},
191 {"NewAltitude", NewAltitude},
192 {"NewHeading", NewHeading},
193 {"AddWayPoint", AddWayPoint},
194 {"PopWayPoint", PopWayPoint},
195 {"ClearRoute", ClearRoute},
196 {"fgAPAdjust", fgAPAdjust},
197 {"fgLatLonFormatToggle", fgLatLonFormatToggle},
202 // Structure termination
207 /* ================ General Purpose Functions ================ */
209 void initDialog(void) {
210 // Initialize our GLOBAL GUI STRINGS
211 gui_msg_OK = msg_OK; // "OK"
212 gui_msg_NO = msg_NO; // "NO"
213 gui_msg_YES = msg_YES; // "YES"
214 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
215 gui_msg_RESET = msg_RESET; // "RESET"
218 // General Purpose Message Box
219 void mkDialog (const char *txt)
221 strncpy(global_dialog_string, txt, 256);
222 dialogBoxMessage->setLabel(global_dialog_string);
223 FG_PUSH_PUI_DIALOG( dialogBox );
226 // Message Box to report an error.
227 void guiErrorMessage (const char *txt)
229 SG_LOG(SG_GENERAL, SG_ALERT, txt);
234 // Message Box to report a throwable (usually an exception).
235 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
239 msg += throwable.getFormattedMessage();
240 if (!throwable.getOrigin().empty()) {
241 msg += "\n (reported by ";
242 msg += throwable.getOrigin();
245 SG_LOG(SG_GENERAL, SG_ALERT, msg);
247 mkDialog(msg.c_str());
250 #if defined(FG_OLD_MENUBAR)
251 // Toggle the Menu and Mouse display state
252 void guiToggleMenu(void)
255 // printf("Hiding Menu\n");
256 mainMenuBar->hide ();
257 #if defined(WIN32_CURSOR_TWEAKS_OFF)
258 if( mouse_mode == MOUSE_POINTER )
260 #endif // WIN32_CURSOR_TWEAKS_OFF
262 // printf("Showing Menu\n");
263 mainMenuBar->reveal();
268 gui_menu_on = ~gui_menu_on;
270 #endif // FG_OLD_MENUBAR
272 // Intercept the Escape Key
273 void ConfirmExitDialog(void)
275 FG_PUSH_PUI_DIALOG( YNdialogBox );
280 /* -----------------------------------------------------------------------
281 the Gui callback functions
282 ____________________________________________________________________*/
285 // Hier Neu :-) This is my newly added code
286 // Added by David Findlay <nedz@bigpond.com>
287 // on Sunday 3rd of December
289 // Start new Save Dialog Box
290 puDialogBox *SaveDialog = 0;
291 puFrame *SaveDialogFrame = 0;
292 puText *SaveDialogMessage = 0;
293 puInput *SaveDialogInput = 0;
295 puOneShot *SaveDialogOkButton = 0;
296 puOneShot *SaveDialogCancelButton = 0;
297 // static puOneShot *SaveDialogResetButton = 0;
299 // Default save filename
300 char saveFile[256] = "fgfs.sav";
303 void SaveDialogCancel(puObject *) {
304 FG_POP_PUI_DIALOG( SaveDialog );
307 // If press OK do this
308 void SaveDialogOk(puObject*) {
310 FG_POP_PUI_DIALOG( SaveDialog );
313 SaveDialogInput->getValue(&s);
316 cout << saveFile << endl;
317 if (output.good() && fgSaveFlight(output)) {
319 mkDialog("Saved flight");
320 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
322 mkDialog("Cannot save flight");
323 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
328 void saveFlight(puObject *cv) {
329 SaveDialog = new puDialogBox (150, 50);
331 SaveDialogFrame = new puFrame (0,0,350, 150);
333 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
334 SaveDialogMessage -> setLabel ("File Name:");
336 SaveDialogInput = new puInput (50, 70, 300, 100);
337 SaveDialogInput -> setValue (saveFile);
338 SaveDialogInput -> acceptInput();
340 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
341 SaveDialogOkButton -> setLegend (gui_msg_OK);
342 SaveDialogOkButton -> setCallback ( SaveDialogOk );
343 SaveDialogOkButton -> makeReturnDefault(TRUE);
345 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
346 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
347 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
349 FG_FINALIZE_PUI_DIALOG( SaveDialog );
351 SaveDialog -> reveal();
355 puDialogBox *LoadDialog = 0;
356 puFrame *LoadDialogFrame = 0;
357 puText *LoadDialogMessage = 0;
358 puInput *LoadDialogInput = 0;
360 puOneShot *LoadDialogOkButton = 0;
361 puOneShot *LoadDialogCancelButton = 0;
362 // static puOneShot *LoadDialogResetButton = 0;
364 // Default load filename
365 char loadFile[256] = "fgfs.sav";
367 // Do this if the person click okay
368 void LoadDialogOk(puObject *) {
370 FG_POP_PUI_DIALOG( LoadDialog );
373 LoadDialogInput->getValue(&l);
376 if (input.good() && fgLoadFlight(input)) {
378 mkDialog("Loaded flight");
379 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
381 mkDialog("Failed to load flight");
382 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
386 // Do this if the person presses cancel
387 void LoadDialogCancel(puObject *) {
388 FG_POP_PUI_DIALOG( LoadDialog );
391 // Create Load Dialog
392 void loadFlight(puObject *cb)
394 LoadDialog = new puDialogBox (150, 50);
396 LoadDialogFrame = new puFrame (0,0,350, 150);
398 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
399 LoadDialogMessage -> setLabel ("File Name:");
401 LoadDialogInput = new puInput (50, 70, 300, 100);
402 LoadDialogInput -> setValue (loadFile);
403 LoadDialogInput -> acceptInput();
405 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
406 LoadDialogOkButton -> setLegend (gui_msg_OK);
407 LoadDialogOkButton -> setCallback ( LoadDialogOk );
408 LoadDialogOkButton -> makeReturnDefault(TRUE);
410 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
411 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
412 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
414 FG_FINALIZE_PUI_DIALOG( LoadDialog );
416 LoadDialog -> reveal();
419 // This is the accessor function
420 void guiTogglePanel(puObject *cb)
422 if (fgGetBool("/sim/panel/visibility"))
423 fgSetBool("/sim/panel/visibility", false);
425 fgSetBool("/sim/panel/visibility", true);
427 fgReshape(fgGetInt("/sim/startup/xsize"),
428 fgGetInt("/sim/startup/ysize"));
431 #if defined(FG_OLD_MENUBAR)
432 //void MenuHideMenuCb(puObject *cb)
433 void hideMenuCb (puObject *cb)
439 void goodBye(puObject *)
441 // SG_LOG( SG_INPUT, SG_ALERT,
442 // "Program exiting normally at user request." );
443 cout << "Program exiting normally at user request." << endl;
445 #ifdef FG_NETWORK_OLK
446 if ( fgGetBool("/sim/networking/network-olk") ) {
447 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
451 // close all external I/O connections
452 globals->get_io()->shutdown_all();
458 void goAwayCb (puObject *me)
460 FG_POP_PUI_DIALOG( dialogBox );
463 void mkDialogInit (void)
465 // printf("mkDialogInit\n");
466 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
467 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
468 dialogBox = new puDialogBox (x, y); // 150, 50
470 dialogFrame = new puFrame (0,0,400,100);
471 dialogBoxMessage = new puText (10, 70);
472 dialogBoxMessage -> setLabel ("");
473 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
474 dialogBoxOkButton -> setLegend (gui_msg_OK);
475 dialogBoxOkButton -> makeReturnDefault (TRUE );
476 dialogBoxOkButton -> setCallback (goAwayCb);
478 FG_FINALIZE_PUI_DIALOG( dialogBox );
481 void MayBeGoodBye(puObject *)
486 void goAwayYesNoCb(puObject *me)
488 FG_POP_PUI_DIALOG( YNdialogBox);
491 void ConfirmExitDialogInit(void)
493 char msg[] = "Really Quit";
496 // printf("ConfirmExitDialogInit\n");
497 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
499 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
500 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
502 YNdialogBox = new puDialogBox (x, y); // 150, 50
504 YNdialogFrame = new puFrame (0,0,400, 100);
506 YNdialogBoxMessage = new puText (len, 70);
507 YNdialogBoxMessage -> setDefaultValue (msg);
508 YNdialogBoxMessage -> getDefaultValue (&s);
509 YNdialogBoxMessage -> setLabel (s);
511 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
512 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
513 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
514 YNdialogBoxOkButton -> setCallback (goodBye);
516 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
517 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
518 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
520 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
523 void notCb (puObject *)
525 mkDialog ("This function isn't implemented yet");
528 void helpCb (puObject *)
532 #if defined(FX) && !defined(WIN32)
533 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
534 if ( globals->get_fullscreen() ) {
535 globals->set_fullscreen(false);
536 XMesaSetFXmode( XMESA_FX_WINDOW );
541 SGPath path( globals->get_fg_root() );
542 path.append( "Docs/index.html" );
546 string help_app = fgGetString("/sim/startup/browser-app");
548 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
549 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
551 command = help_app + " " + path.str();
554 system( command.c_str() );
558 // Look for favorite browser
559 char Dummy[1024], ExecName[1024], browserParameter[1024];
560 char win32_name[1024];
562 cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
564 strcpy(win32_name,path.c_str());
567 FindExecutable(win32_name, Dummy, ExecName);
568 sprintf(browserParameter, "file:///%s", win32_name);
569 ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
574 mkDialog ("Help started in your web browser window.");
577 #if defined( TR_HIRES_SNAP)
582 bool show_pu_cursor = false;
583 char *filename = new char [24];
584 static int count = 1;
586 static const SGPropertyNode *master_freeze
587 = fgGetNode("/sim/freeze/master");
589 bool freeze = master_freeze->getBoolValue();
591 fgSetBool("/sim/freeze/master", true);
594 #if defined(FG_OLD_MENUBAR)
601 if ( !puCursorIsHidden() ) {
602 show_pu_cursor = true;
607 fgReshape( fgGetInt("/sim/startup/xsize"),
608 fgGetInt("/sim/startup/ysize") );
610 // we need two render frames here to clear the menu and cursor
611 // ... not sure why but doing an extra fgRenderFrame() shouldn't
616 // Make sure we have SSG projection primed for current view
617 glMatrixMode(GL_MODELVIEW);
619 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
620 ssgSetFOV( globals->get_current_view()->get_h_fov(),
621 globals->get_current_view()->get_v_fov() );
622 // ssgSetNearFar( 10.0f, 120000.0f );
623 ssgSetNearFar( 0.5f, 1200000.0f );
626 // This ImageSize stuff is a temporary hack
627 // should probably use 128x128 tile size and
628 // support any image size
630 // This should be a requester to get multiplier from user
632 int width = fgGetInt("/sim/startup/xsize");
633 int height = fgGetInt("/sim/startup/ysize");
635 /* allocate buffer large enough to store one tile */
636 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
638 printf("Malloc of tile buffer failed!\n");
642 int imageWidth = multiplier*width;
643 int imageHeight = multiplier*height;
645 /* allocate buffer to hold a row of tiles */
647 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
650 printf("Malloc of tile row buffer failed!\n");
653 TRcontext *tr = trNew();
654 trTileSize(tr, width, height, 0);
655 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
656 trImageSize(tr, imageWidth, imageHeight);
657 trRowOrder(tr, TR_TOP_TO_BOTTOM);
658 sgFrustum *frustum = ssgGetFrustum();
660 frustum->getLeft(), frustum->getRight(),
661 frustum->getBot(), frustum->getTop(),
662 frustum->getNear(), frustum->getFar());
664 /* Prepare ppm output file */
665 while (count < 1000) {
666 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
667 if ( (f = fopen(filename, "r")) == NULL )
671 f = fopen(filename, "wb");
673 printf("Couldn't open image file: %s\n", filename);
679 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
680 fprintf(f,"%i %i\n", imageWidth, imageHeight);
683 /* just to be safe... */
684 glPixelStorei(GL_PACK_ALIGNMENT, 1);
686 /* Because the HUD and Panel change the ViewPort we will
687 * need to handle some lowlevel stuff ourselves */
688 int ncols = trGet(tr, TR_COLUMNS);
689 int nrows = trGet(tr, TR_ROWS);
691 bool do_hud = fgGetBool("/sim/hud/visibility");
692 GLfloat hud_col_step = 640.0 / ncols;
693 GLfloat hud_row_step = 480.0 / nrows;
695 bool do_panel = fgPanelVisible();
696 GLfloat panel_col_step = current_panel->getWidth() / ncols;
697 GLfloat panel_row_step = current_panel->getHeight() / nrows;
703 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
704 int curRow = trGet(tr, TR_CURRENT_ROW);
707 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
708 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
710 current_panel->update( curColumn*panel_col_step, panel_col_step,
711 curRow*panel_row_step, panel_row_step );
712 more = trEndTile(tr);
714 /* save tile into tile row buffer*/
715 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
716 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
717 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
718 int xOffset = curColumn * bytesPerTileRow;
719 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
721 for (i=0;i<height;i++) {
722 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
723 tile + i*bytesPerTileRow, /* Src */
724 bytesPerCurrentTileRow); /* Byte count*/
727 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
728 /* write this buffered row of tiles to the file */
729 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
730 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
732 for (i=0;i<curTileHeight;i++) {
733 /* Remember, OpenGL images are bottom to top. Have to reverse. */
734 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
735 fwrite(rowPtr, 1, imageWidth*3, f);
741 fgReshape( width, height );
747 message = "Snap shot saved to ";
749 mkDialog (message.c_str());
754 // message = "Snap shot saved to ";
755 // message += filename;
756 // mkDialog (message.c_str());
760 #if defined(FG_OLD_MENUBAR)
765 if ( show_pu_cursor ) {
770 fgSetBool("/sim/freeze/master", false);
773 #endif // #if defined( TR_HIRES_SNAP)
776 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
778 void rotateView( double roll, double pitch, double yaw )
784 GLubyte *hiResScreenCapture( int multiplier )
786 float oldfov = fgGetDouble("/sim/current-view/field-of-view");
787 float fov = oldfov / multiplier;
788 FGViewer *v = globals->get_current_view();
789 fgSetDouble("/sim/current-view/field-of-view", fov);
791 int cur_width = fgGetInt("/sim/startup/xsize");
792 int cur_height = fgGetInt("/sim/startup/ysize");
793 if (b1) delete( b1 );
794 // New empty (mostly) bitmap
795 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
797 for ( y = 0; y < multiplier; y++ ) {
798 for ( x = 0; x < multiplier; x++ ) {
799 fgReshape( cur_width, cur_height );
801 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
805 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
808 fgSetDouble("/sim/current-view/field-of-view", oldfov);
809 return b1->getBitmap();
813 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
814 // win32 print screen function
815 void printScreen ( puObject *obj ) {
816 bool show_pu_cursor = false;
818 if ( !puCursorIsHidden() ) {
819 show_pu_cursor = true;
823 #if defined(FG_OLD_MENUBAR)
827 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
828 int cur_width = fgGetInt("/sim/startup/xsize");
829 int cur_height = fgGetInt("/sim/startup/ysize");
830 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
831 p.End( hiResScreenCapture(3) );
833 #if defined(FG_OLD_MENUBAR)
835 mainMenuBar->reveal();
839 if ( show_pu_cursor ) {
844 #endif // #ifdef WIN32
847 void dumpSnapShot ( puObject *obj ) {
852 void dumpHiResSnapShot ( puObject *obj ) {
857 // do a screen snap shot
858 void fgDumpSnapShot () {
859 bool show_pu_cursor = false;
860 char *filename = new char [24];
862 static int count = 1;
864 static const SGPropertyNode *master_freeze
865 = fgGetNode("/sim/freeze/master");
867 bool freeze = master_freeze->getBoolValue();
869 fgSetBool("/sim/freeze/master", true);
872 #if defined(FG_OLD_MENUBAR)
876 if ( !puCursorIsHidden() ) {
877 show_pu_cursor = true;
882 fgReshape( fgGetInt("/sim/startup/xsize"),
883 fgGetInt("/sim/startup/ysize") );
885 // we need two render frames here to clear the menu and cursor
886 // ... not sure why but doing an extra fgRenderFrame() shouldn't
891 while (count < 1000) {
893 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
894 if ( (fp = fopen(filename, "r")) == NULL )
899 if ( sg_glDumpWindow( filename,
900 fgGetInt("/sim/startup/xsize"),
901 fgGetInt("/sim/startup/ysize")) ) {
902 message = "Snap shot saved to ";
905 message = "Failed to save to ";
909 mkDialog (message.c_str());
913 if ( show_pu_cursor ) {
918 #if defined(FG_OLD_MENUBAR)
920 mainMenuBar->reveal();
925 fgSetBool("/sim/freeze/master", false);
929 #ifdef FG_NETWORK_OLK
930 void net_display_toggle( puObject *cb)
932 net_hud_display = (net_hud_display) ? 0 : 1;
933 printf("Toggle net_hud_display : %d\n", net_hud_display);
936 void net_register( puObject *cb)
938 fgd_send_com( "1", FGFS_host );
939 net_is_registered = 0;
940 printf("Registering to deamon\n");
943 void net_unregister( puObject *cb)
945 fgd_send_com( "8", FGFS_host );
946 net_is_registered = -1;
947 printf("Unregistering from deamon\n");
950 #endif // #ifdef FG_NETWORK_OLK