]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui_funcs.cxx
Mathias Fröhlich:
[flightgear.git] / src / GUI / gui_funcs.cxx
1 /**************************************************************************
2  * gui_funcs.cxx
3  *
4  * Based on gui.cxx and renamed on 2002/08/13 by Erik Hofman.
5  *
6  * Written 1998 by Durk Talsma, started Juni, 1998.  For the flight gear
7  * project.
8  *
9  * Additional mouse supported added by David Megginson, 1999.
10  *
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.
15  *
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.
20  *
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.
24  *
25  * $Id$
26  **************************************************************************/
27
28
29 #ifdef HAVE_CONFIG_H
30 #  include <config.h>
31 #endif
32
33 #include <simgear/compiler.h>
34
35 #ifdef SG_MATH_EXCEPTION_CLASH
36 #  include <math.h>
37 #endif
38
39 #ifdef HAVE_WINDOWS_H
40 #  include <windows.h>
41 #endif
42
43 #include SG_GL_H
44
45 #if defined(FX) && defined(XMESA)
46 #  include <GL/xmesa.h>
47 #endif
48
49 #include STL_FSTREAM
50 #include STL_STRING
51
52 #include <stdlib.h>
53 #include <string.h>
54
55 // for help call back
56 #ifdef WIN32
57 # include <shellapi.h>
58 # ifdef __CYGWIN__
59 #  include <sys/cygwin.h>
60 # endif
61 #endif
62
63 #include <plib/ssg.h>
64
65 #include <simgear/constants.h>
66 #include <simgear/debug/logstream.hxx>
67 #include <simgear/misc/sg_path.hxx>
68 #include <simgear/screen/screen-dump.hxx>
69
70 #include <Include/general.hxx>
71 #include <Aircraft/aircraft.hxx>
72 #include <Airports/simple.hxx>
73 #include <Autopilot/auto_gui.hxx>
74 #include <Cockpit/panel.hxx>
75 #include <Controls/controls.hxx>
76 #include <FDM/flight.hxx>
77 #include <Main/main.hxx>
78 #include <Main/fg_init.hxx>
79 #include <Main/fg_io.hxx>
80 #include <Main/globals.hxx>
81 #include <Main/fg_props.hxx>
82 #include <Main/renderer.hxx>
83 #include <Main/viewmgr.hxx>
84
85 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
86 #  include <simgear/screen/win32-printer.h>
87 #  include <simgear/screen/GlBitmaps.h>
88 #endif
89
90 #include "gui.h"
91 #include "gui_local.hxx"
92 #include "preset_dlg.hxx"
93 #include "prop_picker.hxx"
94 #include "sgVec3Slider.hxx"
95
96 SG_USING_STD(string);
97 SG_USING_STD(cout);
98
99 extern void fgHUDalphaAdjust( puObject * );
100
101 // from cockpit.cxx
102 extern void fgLatLonFormatToggle( puObject *);
103
104 #if defined( TR_HIRES_SNAP)
105 #include <simgear/screen/tr.h>
106 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
107                          GLfloat x_end, GLfloat y_end );
108 #endif
109
110 puDialogBox  *dialogBox = 0;
111 puFrame      *dialogFrame = 0;
112 puText       *dialogBoxMessage = 0;
113 puOneShot    *dialogBoxOkButton = 0;
114
115 puDialogBox  *YNdialogBox = 0;
116 puFrame      *YNdialogFrame = 0;
117 puText       *YNdialogBoxMessage = 0;
118 puOneShot    *YNdialogBoxOkButton = 0;
119 puOneShot    *YNdialogBoxNoButton = 0;
120
121 char *gui_msg_OK;     // "OK"
122 char *gui_msg_NO;     // "NO"
123 char *gui_msg_YES;    // "YES"
124 char *gui_msg_CANCEL; // "CANCEL"
125 char *gui_msg_RESET;  // "RESET"
126
127 char msg_OK[]     = "OK";
128 char msg_NO[]     = "NO";
129 char msg_YES[]    = "YES";
130 char msg_CANCEL[] = "Cancel";
131 char msg_RESET[]  = "Reset";
132
133 char global_dialog_string[256];
134
135 const __fg_gui_fn_t __fg_gui_fn[] = {
136
137         // File
138         {"reInit", reInit},
139 #ifdef TR_HIRES_SNAP
140         {"dumpHiResSnapShot", fgHiResDumpWrapper},
141 #endif
142         {"dumpSnapShot", fgDumpSnapShotWrapper},
143 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
144         {"printScreen", printScreen},
145 #endif
146         {"MayBeGoodBye", MayBeGoodBye},
147
148         //View
149         {"guiTogglePanel", guiTogglePanel},
150         {"fgHUDalphaAdjust", fgHUDalphaAdjust},
151         {"prop_pickerView", prop_pickerView},
152
153         // Environment
154         {"fgPresetAirport", fgPresetAirport},
155         {"fgPresetRunway", fgPresetRunway},
156         {"fgPresetOffsetDistance", fgPresetOffsetDistance},
157         {"fgPresetAltitude", fgPresetAltitude},
158         {"fgPresetGlideslope", fgPresetGlideslope},
159         {"fgPresetAirspeed", fgPresetAirspeed},
160         {"fgPresetCommit", fgPresetCommit},
161
162         // Autopilot
163         {"NewAltitude", NewAltitude},
164         {"NewHeading", NewHeading},
165         {"AddWayPoint", AddWayPoint},
166         {"PopWayPoint", PopWayPoint},
167         {"ClearRoute", ClearRoute},
168         {"fgLatLonFormatToggle", fgLatLonFormatToggle},
169
170         // Help
171         {"helpCb", helpCb},
172
173         // Structure termination
174         {"", NULL}
175 };
176
177
178 /* ================ General Purpose Functions ================ */
179
180 void initDialog(void) {
181     // Initialize our GLOBAL GUI STRINGS
182     gui_msg_OK     = msg_OK;     // "OK"
183     gui_msg_NO     = msg_NO;     // "NO"
184     gui_msg_YES    = msg_YES;    // "YES"
185     gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
186     gui_msg_RESET  = msg_RESET;  // "RESET"
187 }
188
189 // General Purpose Message Box
190 void mkDialog (const char *txt)
191 {
192     strncpy(global_dialog_string, txt, 256);
193     dialogBoxMessage->setLabel(global_dialog_string);
194     FG_PUSH_PUI_DIALOG( dialogBox );
195 }
196
197 // Message Box to report an error.
198 void guiErrorMessage (const char *txt)
199 {
200     SG_LOG(SG_GENERAL, SG_ALERT, txt);
201     if (dialogBox != 0)
202       mkDialog(txt);
203 }
204
205 // Message Box to report a throwable (usually an exception).
206 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
207 {
208     string msg = txt;
209     msg += '\n';
210     msg += throwable.getFormattedMessage();
211     if (!throwable.getOrigin().empty()) {
212       msg += "\n (reported by ";
213       msg += throwable.getOrigin();
214       msg += ')';
215     }
216     SG_LOG(SG_GENERAL, SG_ALERT, msg);
217     if (dialogBox != 0)
218       mkDialog(msg.c_str());
219 }
220
221 // Intercept the Escape Key
222 void ConfirmExitDialog(void)
223 {
224     FG_PUSH_PUI_DIALOG( YNdialogBox );
225 }
226
227
228
229 /* -----------------------------------------------------------------------
230 the Gui callback functions 
231 ____________________________________________________________________*/
232
233
234 // Hier Neu :-) This is my newly added code
235 // Added by David Findlay <nedz@bigpond.com>
236 // on Sunday 3rd of December
237
238
239 // This is the accessor function
240 void guiTogglePanel(puObject *cb)
241 {
242   if (fgGetBool("/sim/panel/visibility"))
243     fgSetBool("/sim/panel/visibility", false);
244   else
245     fgSetBool("/sim/panel/visibility", true);
246
247   globals->get_renderer()->resize(fgGetInt("/sim/startup/xsize"),
248                                   fgGetInt("/sim/startup/ysize"));
249 }
250
251 void goodBye(puObject *)
252 {
253     // SG_LOG( SG_INPUT, SG_ALERT,
254     //      "Program exiting normally at user request." );
255     cout << "Program exiting normally at user request." << endl;
256
257     exit(0);
258 }
259
260
261 void goAwayCb (puObject *me)
262 {
263     FG_POP_PUI_DIALOG( dialogBox );
264 }
265
266 void mkDialogInit (void)
267 {
268     //  printf("mkDialogInit\n");
269     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
270     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
271     dialogBox = new puDialogBox (x, y); // 150, 50
272     {
273         dialogFrame = new puFrame (0,0,400,100);
274         dialogBoxMessage  =  new puText         (10, 70);
275         dialogBoxMessage  -> setLabel           ("");
276         dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
277         dialogBoxOkButton -> setLegend          (gui_msg_OK);
278         dialogBoxOkButton -> makeReturnDefault  (TRUE );
279         dialogBoxOkButton -> setCallback        (goAwayCb);
280     }
281     FG_FINALIZE_PUI_DIALOG( dialogBox );
282 }
283
284 void MayBeGoodBye(puObject *)
285 {
286     ConfirmExitDialog(); 
287 }
288
289 void goAwayYesNoCb(puObject *me)
290 {
291     FG_POP_PUI_DIALOG( YNdialogBox);
292 }
293
294 void ConfirmExitDialogInit(void)
295 {
296     char msg[] = "Really Quit";
297     char *s;
298
299     //  printf("ConfirmExitDialogInit\n");
300     int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
301
302     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
303     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
304         
305     YNdialogBox = new puDialogBox (x, y); // 150, 50
306     {
307         YNdialogFrame = new puFrame (0,0,400, 100);
308         
309         YNdialogBoxMessage  =  new puText         (len, 70);
310         YNdialogBoxMessage  -> setDefaultValue    (msg);
311         YNdialogBoxMessage  -> getDefaultValue    (&s);
312         YNdialogBoxMessage  -> setLabel           (s);
313         
314         YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
315         YNdialogBoxOkButton -> setLegend          (gui_msg_OK);
316         YNdialogBoxOkButton -> makeReturnDefault  (TRUE );
317         YNdialogBoxOkButton -> setCallback        (goodBye);
318         
319         YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
320         YNdialogBoxNoButton -> setLegend          (gui_msg_NO);
321         YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
322     }
323     FG_FINALIZE_PUI_DIALOG( YNdialogBox );
324 }
325
326 void notCb (puObject *)
327 {
328     mkDialog ("This function isn't implemented yet");
329 }
330
331 void helpCb (puObject *)
332 {
333     string command;
334         
335 #if defined(FX) && !defined(WIN32)
336 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
337     if ( globals->get_fullscreen() ) {
338         globals->set_fullscreen(false);
339         XMesaSetFXmode( XMESA_FX_WINDOW );
340     }
341 #  endif
342 #endif
343         
344     SGPath path( globals->get_fg_root() );
345     path.append( "Docs/index.html" );
346         
347 #if !defined(WIN32)
348
349     string help_app = fgGetString("/sim/startup/browser-app");
350
351     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
352         command = help_app + " -remote \"openURL(" + path.str() + ")\"";
353     } else {
354         command = help_app + " " + path.str();
355     }
356     command += " &";
357     system( command.c_str() );
358
359 #else // WIN32
360
361     // Look for favorite browser
362     char Dummy[1024], ExecName[1024], browserParameter[1024];
363     char win32_name[1024];
364 # ifdef __CYGWIN__
365     cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
366 # else
367     strcpy(win32_name,path.c_str());
368 # endif
369     Dummy[0] = 0;
370     FindExecutable(win32_name, Dummy, ExecName);
371     sprintf(browserParameter, "file:///%s", win32_name);
372     ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
373                    SW_SHOWNORMAL ) ;
374
375 #endif
376         
377     mkDialog ("Help started in your web browser window.");
378 }
379
380 #if defined( TR_HIRES_SNAP)
381 void fgHiResDump()
382 {
383     FILE *f;
384     string message;
385     bool show_pu_cursor = false;
386     char *filename = new char [24];
387     static int count = 1;
388
389     static const SGPropertyNode *master_freeze
390         = fgGetNode("/sim/freeze/master");
391
392     bool freeze = master_freeze->getBoolValue();
393     if ( !freeze ) {
394         fgSetBool("/sim/freeze/master", true);
395     }
396
397     TurnCursorOff();
398     if ( !puCursorIsHidden() ) {
399         show_pu_cursor = true;
400         puHideCursor();
401     }
402
403     FGRenderer *renderer = globals->get_renderer();
404     renderer->init();
405     renderer->resize( fgGetInt("/sim/startup/xsize"),
406                       fgGetInt("/sim/startup/ysize") );
407
408     // we need two render frames here to clear the menu and cursor
409     // ... not sure why but doing an extra fgRenderFrame() shouldn't
410     // hurt anything
411     renderer->update( true );
412     renderer->update( true );
413
414     // This ImageSize stuff is a temporary hack
415     // should probably use 128x128 tile size and
416     // support any image size
417
418     // This should be a requester to get multiplier from user
419     int multiplier = fgGetInt("/sim/startup/hires-multiplier", 3);
420     int width = fgGetInt("/sim/startup/xsize");
421     int height = fgGetInt("/sim/startup/ysize");
422         
423     /* allocate buffer large enough to store one tile */
424     GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
425     if (!tile) {
426         printf("Malloc of tile buffer failed!\n");
427         return;
428     }
429
430     int imageWidth  = multiplier*width;
431     int imageHeight = multiplier*height;
432
433     /* allocate buffer to hold a row of tiles */
434     GLubyte *buffer
435         = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
436     if (!buffer) {
437         free(tile);
438         printf("Malloc of tile row buffer failed!\n");
439         return;
440     }
441     TRcontext *tr = trNew();
442     trTileSize(tr, width, height, 0);
443     trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
444     trImageSize(tr, imageWidth, imageHeight);
445     trRowOrder(tr, TR_TOP_TO_BOTTOM);
446     sgFrustum *frustum = ssgGetFrustum();
447     trFrustum(tr,
448               frustum->getLeft(), frustum->getRight(),
449               frustum->getBot(),  frustum->getTop(), 
450               frustum->getNear(), frustum->getFar());
451         
452     /* Prepare ppm output file */
453     while (count < 1000) {
454         snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
455         if ( (f = fopen(filename, "r")) == NULL )
456             break;
457         fclose(f);
458     }
459     f = fopen(filename, "wb");
460     if (!f) {
461         printf("Couldn't open image file: %s\n", filename);
462         free(buffer);
463         free(tile);
464         return;
465     }
466     fprintf(f,"P6\n");
467     fprintf(f,"# ppm-file created by %s\n", "trdemo2");
468     fprintf(f,"%i %i\n", imageWidth, imageHeight);
469     fprintf(f,"255\n");
470
471     /* just to be safe... */
472     glPixelStorei(GL_PACK_ALIGNMENT, 1);
473
474     /* Because the HUD and Panel change the ViewPort we will
475      * need to handle some lowlevel stuff ourselves */
476     int ncols = trGet(tr, TR_COLUMNS);
477     int nrows = trGet(tr, TR_ROWS);
478
479     bool do_hud = fgGetBool("/sim/hud/visibility");
480     GLfloat hud_col_step = 640.0 / ncols;
481     GLfloat hud_row_step = 480.0 / nrows;
482         
483     bool do_panel = fgPanelVisible();
484     GLfloat panel_col_step = globals->get_current_panel()->getWidth() / ncols;
485     GLfloat panel_row_step = globals->get_current_panel()->getHeight() / nrows;
486         
487     /* Draw tiles */
488     int more = 1;
489     while (more) {
490         trBeginTile(tr);
491         int curColumn = trGet(tr, TR_CURRENT_COLUMN);
492         int curRow =  trGet(tr, TR_CURRENT_ROW);
493         renderer->update( false );
494         if ( do_hud )
495             fgUpdateHUD( curColumn*hud_col_step,      curRow*hud_row_step,
496                          (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
497         if (do_panel)
498             globals->get_current_panel()->update(
499                                    curColumn*panel_col_step, panel_col_step,
500                                    curRow*panel_row_step,    panel_row_step );
501         more = trEndTile(tr);
502
503         /* save tile into tile row buffer*/
504         int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
505         int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
506         int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
507         int xOffset = curColumn * bytesPerTileRow;
508         int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
509         int i;
510         for (i=0;i<height;i++) {
511             memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
512                    tile + i*bytesPerTileRow,              /* Src */
513                    bytesPerCurrentTileRow);               /* Byte count*/
514         }
515
516         if (curColumn == trGet(tr, TR_COLUMNS)-1) {
517             /* write this buffered row of tiles to the file */
518             int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
519             int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
520             int i;
521             for (i=0;i<curTileHeight;i++) {
522                 /* Remember, OpenGL images are bottom to top.  Have to reverse. */
523                 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
524                 fwrite(rowPtr, 1, imageWidth*3, f);
525             }
526         }
527
528     }
529
530     renderer->resize( width, height );
531
532     trDelete(tr);
533
534     fclose(f);
535
536     message = "Snap shot saved to ";
537     message += filename;
538     mkDialog (message.c_str());
539
540     free(tile);
541     free(buffer);
542
543     //  message = "Snap shot saved to ";
544     //  message += filename;
545     //  mkDialog (message.c_str());
546
547     delete [] filename;
548
549     if ( show_pu_cursor ) {
550         puShowCursor();
551     }
552
553     TurnCursorOn();
554
555     if ( !freeze ) {
556         fgSetBool("/sim/freeze/master", false);
557     }
558 }
559 #endif // #if defined( TR_HIRES_SNAP)
560
561
562 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
563
564 void rotateView( double roll, double pitch, double yaw )
565 {
566         // rotate view
567 }
568
569 GlBitmap *b1 = NULL;
570 GLubyte *hiResScreenCapture( int multiplier )
571 {
572     float oldfov = fgGetDouble("/sim/current-view/field-of-view");
573     float fov = oldfov / multiplier;
574     FGViewer *v = globals->get_current_view();
575     fgSetDouble("/sim/current-view/field-of-view", fov);
576     globals->get_renderer()->init();
577     int cur_width = fgGetInt("/sim/startup/xsize");
578     int cur_height = fgGetInt("/sim/startup/ysize");
579     delete( b1 );
580     // New empty (mostly) bitmap
581     b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
582     int x,y;
583     for ( y = 0; y < multiplier; y++ ) {
584         for ( x = 0; x < multiplier; x++ ) {
585             globals->get_renderer()->resize( cur_width, cur_height );
586             // pan to tile
587             rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
588             globals->get_renderer()->update( false );
589             // restore view
590             GlBitmap b2;
591             b1->copyBitmap( &b2, cur_width*x, cur_height*y );
592         }
593     }
594     fgSetDouble("/sim/current-view/field-of-view", oldfov);
595     return b1->getBitmap();
596 }
597 #endif
598
599 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
600 // win32 print screen function
601 void printScreen ( puObject *obj ) {
602     bool show_pu_cursor = false;
603     TurnCursorOff();
604     if ( !puCursorIsHidden() ) {
605         show_pu_cursor = true;
606         puHideCursor();
607     }
608     // BusyCursor( 0 );
609
610     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
611     int cur_width = fgGetInt("/sim/startup/xsize");
612     int cur_height = fgGetInt("/sim/startup/ysize");
613     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
614     p.End( hiResScreenCapture(3) );
615
616     // BusyCursor(1);
617     if ( show_pu_cursor ) {
618         puShowCursor();
619     }
620     TurnCursorOn();
621 }
622 #endif // #ifdef WIN32
623
624
625 void fgDumpSnapShotWrapper ( puObject *obj ) {
626     fgDumpSnapShot();
627 }
628
629
630 void fgHiResDumpWrapper ( puObject *obj ) {
631     fgHiResDump();
632 }
633
634
635 // do a screen snap shot
636 void fgDumpSnapShot () {
637     bool show_pu_cursor = false;
638     char *filename = new char [24];
639     string message;
640     static int count = 1;
641
642     static const SGPropertyNode *master_freeze
643         = fgGetNode("/sim/freeze/master");
644
645     bool freeze = master_freeze->getBoolValue();
646     if ( !freeze ) {
647         fgSetBool("/sim/freeze/master", true);
648     }
649
650     TurnCursorOff();
651     if ( !puCursorIsHidden() ) {
652         show_pu_cursor = true;
653         puHideCursor();
654     }
655
656     FGRenderer *renderer = globals->get_renderer();
657     renderer->init();
658     renderer->resize( fgGetInt("/sim/startup/xsize"),
659                         fgGetInt("/sim/startup/ysize") );
660
661     // we need two render frames here to clear the menu and cursor
662     // ... not sure why but doing an extra fgRenderFrame() shouldn't
663     // hurt anything
664     renderer->update( true );
665     renderer->update( true );
666
667     while (count < 1000) {
668         FILE *fp;
669         snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
670         if ( (fp = fopen(filename, "r")) == NULL )
671             break;
672         fclose(fp);
673     }
674
675     if ( sg_glDumpWindow( filename,
676                           fgGetInt("/sim/startup/xsize"), 
677                           fgGetInt("/sim/startup/ysize")) ) {
678         message = "Snap shot saved to ";
679         message += filename;
680     } else {
681         message = "Failed to save to ";
682         message += filename;
683     }
684
685     mkDialog (message.c_str());
686
687     delete [] filename;
688
689     if ( show_pu_cursor ) {
690         puShowCursor();
691     }
692
693     TurnCursorOn();
694
695     if ( !freeze ) {
696         fgSetBool("/sim/freeze/master", false);
697     }
698 }
699