]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
c1b86e36eeeb4b55d18232ca312ee70338578b7c
[flightgear.git] / src / GUI / gui.cxx
1 /**************************************************************************
2  * gui.cxx
3  *
4  * Written 1998 by Durk Talsma, started Juni, 1998.  For the flight gear
5  * project.
6  *
7  * Additional mouse supported added by David Megginson, 1999.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  **************************************************************************/
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #ifdef FG_MATH_EXCEPTION_CLASH
34 #  include <math.h>
35 #endif
36
37 #ifdef HAVE_WINDOWS_H
38 #  include <windows.h>
39 #endif
40
41 #include <GL/glut.h>
42 #include <simgear/xgl/xgl.h>
43
44 #if defined(FX) && defined(XMESA)
45 #  include <GL/xmesa.h>
46 #endif
47
48 #include STL_FSTREAM
49 #include STL_STRING
50
51 #include <stdlib.h>
52 #include <string.h>
53
54 #include <simgear/constants.h>
55 #include <simgear/debug/logstream.hxx>
56 #include <simgear/misc/fgpath.hxx>
57 #include <simgear/screen/screen-dump.hxx>
58
59 #include <Include/general.hxx>
60 #include <Aircraft/aircraft.hxx>
61 #include <Airports/simple.hxx>
62 #include <Autopilot/auto_gui.hxx>
63 #include <Autopilot/newauto.hxx>
64 #include <Cockpit/panel.hxx>
65 #include <Controls/controls.hxx>
66 #include <FDM/flight.hxx>
67 #include <Main/bfi.hxx>
68 #include <Main/fg_init.hxx>
69 #include <Main/fg_io.hxx>
70 #include <Main/globals.hxx>
71 #include <Main/fg_props.hxx>
72 #include <Main/options.hxx>
73
74 #ifdef FG_NETWORK_OLK
75 #include <NetworkOLK/network.h>
76 #endif
77    
78 #if defined( WIN32 ) && !defined( __CYGWIN__ )
79 #  include <simgear/screen/win32-printer.h>
80 #  include <simgear/screen/GlBitmaps.h>
81 #endif
82
83 #include "gui.h"
84 #include "gui_local.hxx"
85 #include "apt_dlg.hxx"
86 #include "net_dlg.hxx"
87 #include "sgVec3Slider.hxx"
88
89 FG_USING_STD(string);
90
91 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
92 FG_USING_STD(cout);
93 #endif
94
95 #if defined(WIN32) || defined(__CYGWIN32__)
96 #define WIN32_CURSOR_TWEAKS
97 #elif (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
98 #define X_CURSOR_TWEAKS
99 #endif
100
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 );
105
106 puFont guiFnt = 0;
107 fntTexFont *guiFntHandle = 0;
108 int gui_menu_on = 0;
109 static puMenuBar    *mainMenuBar = 0;
110 //static puButton     *hideMenuButton = 0;
111
112 static puDialogBox  *dialogBox = 0;
113 static puFrame      *dialogFrame = 0;
114 static puText       *dialogBoxMessage = 0;
115 static puOneShot    *dialogBoxOkButton = 0;
116
117
118 static puDialogBox  *YNdialogBox = 0;
119 static puFrame      *YNdialogFrame = 0;
120 static puText       *YNdialogBoxMessage = 0;
121 static puOneShot    *YNdialogBoxOkButton = 0;
122 static puOneShot    *YNdialogBoxNoButton = 0;
123
124 static char msg_OK[]     = "OK";
125 static char msg_NO[]     = "NO";
126 static char msg_YES[]    = "YES";
127 static char msg_CANCEL[] = "Cancel";
128 static char msg_RESET[]  = "Reset";
129
130 char *gui_msg_OK;     // "OK"
131 char *gui_msg_NO;     // "NO"
132 char *gui_msg_YES;    // "YES"
133 char *gui_msg_CANCEL; // "CANCEL"
134 char *gui_msg_RESET;  // "RESET"
135
136 static char global_dialog_string[256];
137
138 // from cockpit.cxx
139 extern void fgLatLonFormatToggle( puObject *);
140
141
142 /* ================ General Purpose Functions ================ */
143
144 // Intercept the Escape Key
145 void ConfirmExitDialog(void)
146 {
147     FG_PUSH_PUI_DIALOG( YNdialogBox );
148 }
149
150 // General Purpose Message Box
151 void mkDialog (const char *txt)
152 {
153     strncpy(global_dialog_string, txt, 256);
154     dialogBoxMessage->setLabel(global_dialog_string);
155     FG_PUSH_PUI_DIALOG( dialogBox );
156 }
157
158 // Toggle the Menu and Mouse display state
159 void guiToggleMenu(void)
160 {
161     if( gui_menu_on ) {
162         // printf("Hiding Menu\n");
163         mainMenuBar->hide  ();
164 #if defined(WIN32_CURSOR_TWEAKS)
165         if( mouse_mode == MOUSE_POINTER )
166             TurnCursorOff();
167 #endif // #ifdef WIN32_CURSOR_TWEAKS
168     } else {
169         // printf("Showing Menu\n");
170         mainMenuBar->reveal();
171 #ifdef WIN32
172         TurnCursorOn();
173 #endif // #ifdef WIN32
174     }
175     gui_menu_on = ~gui_menu_on;
176 }
177     
178 /* -----------------------------------------------------------------------
179 the Gui callback functions 
180 ____________________________________________________________________*/
181
182
183 // Hier Neu :-) This is my newly added code
184 // Added by David Findlay <nedz@bigpond.com>
185 // on Sunday 3rd of December
186
187 // Start new Save Dialog Box
188 static puDialogBox     *SaveDialog = 0;
189 static puFrame         *SaveDialogFrame = 0;
190 static puText          *SaveDialogMessage = 0;
191 static puInput         *SaveDialogInput = 0;
192
193 static puOneShot       *SaveDialogOkButton = 0;
194 static puOneShot       *SaveDialogCancelButton = 0;
195 static puOneShot       *SaveDialogResetButton = 0;
196
197 // Default save filename
198 static char saveFile[256] = "fgfs.sav";
199
200 // Cancel Button
201 void SaveDialogCancel(puObject *) {
202     FG_POP_PUI_DIALOG( SaveDialog );
203 }
204
205 // If press OK do this
206 void SaveDialogOk(puObject*) {
207
208     FG_POP_PUI_DIALOG( SaveDialog );
209
210     char *s;
211     SaveDialogInput->getValue(&s);
212
213     ofstream output(s);
214     cout << saveFile << endl;
215     if (output.good() && fgSaveFlight(output)) {
216         output.close();
217         mkDialog("Saved flight");
218         FG_LOG(FG_INPUT, FG_INFO, "Saved flight");
219     } else {
220         mkDialog("Cannot save flight");
221         FG_LOG(FG_INPUT, FG_ALERT, "Cannot save flight");
222     }
223 }
224
225 // Create Dialog
226 static void saveFlight(puObject *cv) {
227     SaveDialog = new puDialogBox (150, 50);
228     {
229         SaveDialogFrame   = new puFrame           (0,0,350, 150);
230         SaveDialogMessage = new puText            (
231                         (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
232         SaveDialogMessage ->    setLabel          ("File Name:");
233
234         SaveDialogInput   = new puInput           (50, 70, 300, 100);
235         SaveDialogInput   ->    setValue          (saveFile);
236         SaveDialogInput   ->    acceptInput();
237
238         SaveDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
239         SaveDialogOkButton     ->     setLegend   (gui_msg_OK);
240         SaveDialogOkButton     ->     setCallback ( SaveDialogOk );
241         SaveDialogOkButton     ->     makeReturnDefault(TRUE);
242
243         SaveDialogCancelButton =  new puOneShot   (140, 10, 210, 50);
244         SaveDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
245         SaveDialogCancelButton ->     setCallback ( SaveDialogCancel );
246     }
247     FG_FINALIZE_PUI_DIALOG( SaveDialog );
248    
249     SaveDialog -> reveal();
250 }
251
252 // Load Dialog Start
253 static puDialogBox     *LoadDialog = 0;
254 static puFrame         *LoadDialogFrame = 0;
255 static puText          *LoadDialogMessage = 0;
256 static puInput         *LoadDialogInput = 0;
257
258 static puOneShot       *LoadDialogOkButton = 0;
259 static puOneShot       *LoadDialogCancelButton = 0;
260 static puOneShot       *LoadDialogResetButton = 0;
261
262 // Default load filename
263 static char loadFile[256] = "fgfs.sav";
264
265 // Do this if the person click okay
266 void LoadDialogOk(puObject *) {
267
268     FG_POP_PUI_DIALOG( LoadDialog );
269
270     char *l;
271     LoadDialogInput->getValue(&l);
272
273     ifstream input(l);
274     if (input.good() && fgLoadFlight(input)) {
275         input.close();
276         mkDialog("Loaded flight");
277         FG_LOG(FG_INPUT, FG_INFO, "Restored flight");
278     } else {
279         mkDialog("Failed to load flight");
280         FG_LOG(FG_INPUT, FG_ALERT, "Cannot load flight");
281     }
282 }
283
284 // Do this is the person presses cancel
285 void LoadDialogCancel(puObject *) {
286     FG_POP_PUI_DIALOG( LoadDialog );
287 }
288
289 // Create Load Dialog
290 static void loadFlight(puObject *cb)
291 {
292     LoadDialog = new puDialogBox (150, 50);
293     {
294         LoadDialogFrame   = new puFrame           (0,0,350, 150);
295         LoadDialogMessage = new puText            (
296                         (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
297         LoadDialogMessage ->    setLabel          ("File Name:");
298
299         LoadDialogInput   = new puInput           (50, 70, 300, 100);
300         LoadDialogInput   ->    setValue          (loadFile);
301         LoadDialogInput   ->    acceptInput();
302
303         LoadDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
304         LoadDialogOkButton     ->     setLegend   (gui_msg_OK);
305         LoadDialogOkButton     ->     setCallback ( LoadDialogOk );
306         LoadDialogOkButton     ->     makeReturnDefault(TRUE);
307
308         LoadDialogCancelButton =  new puOneShot   (140, 10, 210, 50);
309         LoadDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
310         LoadDialogCancelButton ->     setCallback ( LoadDialogCancel );
311     }
312     FG_FINALIZE_PUI_DIALOG( LoadDialog );
313    
314     LoadDialog -> reveal();
315 }
316
317 // This is the accessor function
318 void guiTogglePanel(puObject *cb)
319 {
320   if (fgGetBool("/sim/panel/visibility"))
321     fgSetBool("/sim/panel/visibility", false);
322   else
323     fgSetBool("/sim/panel/visibility", true);
324
325   fgReshape(fgGetInt("/sim/startup/xsize"),
326             fgGetInt("/sim/startup/ysize"));
327 }
328     
329 //void MenuHideMenuCb(puObject *cb)
330 void hideMenuCb (puObject *cb)
331 {
332     guiToggleMenu();
333 }
334
335 void goodBye(puObject *)
336 {
337     // FG_LOG( FG_INPUT, FG_ALERT,
338     //      "Program exiting normally at user request." );
339     cout << "Program exiting normally at user request." << endl;
340
341 #ifdef FG_NETWORK_OLK    
342     if ( fgGetBool("/sim/networking/network-olk") ) {
343         if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
344     }
345 #endif
346
347     // close all external I/O connections
348     fgIOShutdownAll();
349
350     exit(0);
351 }
352
353
354 void goAwayCb (puObject *me)
355 {
356     FG_POP_PUI_DIALOG( dialogBox );
357 }
358
359 void mkDialogInit (void)
360 {
361     //  printf("mkDialogInit\n");
362     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
363     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
364     dialogBox = new puDialogBox (x, y); // 150, 50
365     {
366         dialogFrame = new puFrame (0,0,400,100);
367         dialogBoxMessage  =  new puText         (10, 70);
368         dialogBoxMessage  -> setLabel           ("");
369         dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
370         dialogBoxOkButton -> setLegend          (gui_msg_OK);
371         dialogBoxOkButton -> makeReturnDefault  (TRUE );
372         dialogBoxOkButton -> setCallback        (goAwayCb);
373     }
374     FG_FINALIZE_PUI_DIALOG( dialogBox );
375 }
376
377 void MayBeGoodBye(puObject *)
378 {
379     ConfirmExitDialog(); 
380 }
381
382 void goAwayYesNoCb(puObject *me)
383 {
384     FG_POP_PUI_DIALOG( YNdialogBox);
385 }
386
387 void ConfirmExitDialogInit(void)
388 {
389     char msg[] = "Really Quit";
390     char *s;
391
392     //  printf("ConfirmExitDialogInit\n");
393     int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
394
395     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
396     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
397         
398     YNdialogBox = new puDialogBox (x, y); // 150, 50
399     //  YNdialogBox = new puDialogBox (150, 50);
400     {
401         YNdialogFrame = new puFrame (0,0,400, 100);
402         
403         YNdialogBoxMessage  =  new puText         (len, 70);
404         YNdialogBoxMessage  -> setDefaultValue    (msg);
405         YNdialogBoxMessage  -> getDefaultValue    (&s);
406         YNdialogBoxMessage  -> setLabel           (s);
407         
408         YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
409         YNdialogBoxOkButton -> setLegend          (gui_msg_OK);
410         YNdialogBoxOkButton -> makeReturnDefault  (TRUE );
411         YNdialogBoxOkButton -> setCallback        (goodBye);
412         
413         YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
414         YNdialogBoxNoButton -> setLegend          (gui_msg_NO);
415         YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
416     }
417     FG_FINALIZE_PUI_DIALOG( YNdialogBox );
418 }
419
420 void notCb (puObject *)
421 {
422     mkDialog ("This function isn't implemented yet");
423 }
424
425 void helpCb (puObject *)
426 {
427     string command;
428         
429 #if defined(FX) && !defined(WIN32)
430 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
431     if ( global_fullscreen ) {
432         global_fullscreen = false;
433         XMesaSetFXmode( XMESA_FX_WINDOW );
434     }
435 #  endif
436 #endif
437         
438 #if !defined(WIN32)
439     string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
440         
441     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
442         command = "netscape -remote \"openURL(" + url + ")\" &";
443     } else {
444         command = "netscape " + url + " &";
445     }
446 #else
447     command = "webrun.bat";
448 #endif
449         
450     system( command.c_str() );
451     //string text = "Help started in netscape window.";
452
453     //mkDialog (text.c_str());
454     mkDialog ("Help started in netscape window.");
455 }
456
457 #if defined( WIN32 ) && !defined( __CYGWIN__)
458
459 static void rotateView( double roll, double pitch, double yaw )
460 {
461         // rotate view
462 }
463
464 static GlBitmap *b1 = NULL;
465 extern FGInterface cur_view_fdm;
466 GLubyte *hiResScreenCapture( int multiplier )
467 {
468     float oldfov = fgGetDouble("/sim/field-of-view");
469     float fov = oldfov / multiplier;
470     FGViewer *v = globals->get_current_view();
471     fgSetDouble("/sim/field-of-view", fov);
472     fgInitVisuals();
473     int cur_width = fgGetInt("/sim/startup/xsize");
474     int cur_height = fgGetInt("/sim/startup/ysize");
475     if (b1) delete( b1 );
476     // New empty (mostly) bitmap
477     b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
478     int x,y;
479     for ( y = 0; y < multiplier; y++ ) {
480         for ( x = 0; x < multiplier; x++ ) {
481             fgReshape( cur_width, cur_height );
482             // pan to tile
483             rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
484             fgRenderFrame();
485             // restore view
486             GlBitmap b2;
487             b1->copyBitmap( &b2, cur_width*x, cur_height*y );
488         }
489     }
490     fgSetDouble("/sim/field-of-view", oldfov);
491     return b1->getBitmap();
492 }
493 #endif
494
495
496 #if defined( WIN32 ) && !defined( __CYGWIN__)
497 // win32 print screen function
498 void printScreen ( puObject *obj ) {
499     bool show_pu_cursor = false;
500     TurnCursorOff();
501     if ( !puCursorIsHidden() ) {
502         show_pu_cursor = true;
503         puHideCursor();
504     }
505     BusyCursor( 0 );
506     mainMenuBar->hide();
507
508     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
509     int cur_width = fgGetInt("/sim/startup/xsize");
510     int cur_height = fgGetInt("/sim/startup/ysize");
511     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
512         p.End( hiResScreenCapture(3) );
513
514     if( gui_menu_on ) {
515         mainMenuBar->reveal();
516     }
517     BusyCursor(1);
518     if ( show_pu_cursor ) {
519         puShowCursor();
520     }
521     TurnCursorOn();
522 }
523 #endif // #ifdef WIN32
524
525
526 void dumpSnapShot ( puObject *obj ) {
527     fgDumpSnapShot();
528 }
529
530
531 // do a screen snap shot
532 void fgDumpSnapShot () {
533     bool show_pu_cursor = false;
534
535     int freeze = globals->get_freeze();
536     if(!freeze)
537         globals->set_freeze( true );
538
539     mainMenuBar->hide();
540     TurnCursorOff();
541     if ( !puCursorIsHidden() ) {
542         show_pu_cursor = true;
543         puHideCursor();
544     }
545
546     fgInitVisuals();
547     fgReshape( fgGetInt("/sim/startup/xsize"),
548                fgGetInt("/sim/startup/ysize") );
549
550     // we need two render frames here to clear the menu and cursor
551     // ... not sure why but doing an extra fgFenderFrame() shoulnd't
552     // hurt anything
553     fgRenderFrame();
554     fgRenderFrame();
555
556     my_glDumpWindow( "fgfs-screen.ppm", 
557                      fgGetInt("/sim/startup/xsize"), 
558                      fgGetInt("/sim/startup/ysize") );
559     
560     mkDialog ("Snap shot saved to fgfs-screen.ppm");
561
562     if ( show_pu_cursor ) {
563         puShowCursor();
564     }
565
566     TurnCursorOn();
567     if( gui_menu_on ) {
568         mainMenuBar->reveal();
569     }
570
571     if(!freeze)
572         globals->set_freeze( false );
573 }
574
575 #ifdef FG_NETWORK_OLK
576 static void net_display_toggle( puObject *cb)
577 {
578         net_hud_display = (net_hud_display) ? 0 : 1;
579         printf("Toggle net_hud_display : %d\n", net_hud_display);
580 }
581
582 static void net_register( puObject *cb)
583 {
584         fgd_send_com( "1", FGFS_host );
585         net_is_registered = 0;
586         printf("Registering to deamon\n");
587 }
588
589 static void net_unregister( puObject *cb)
590 {
591         fgd_send_com( "8", FGFS_host );
592         net_is_registered = -1;
593         printf("Unregistering from deamon\n");
594 }
595
596 extern void net_fgd_scan(puObject *cb);
597 #endif // #ifdef FG_NETWORK_OLK
598
599 /* -----------------------------------------------------------------------
600 The menu stuff 
601 ---------------------------------------------------------------------*/
602 char *fileSubmenu               [] = {
603     "Exit", /* "Close", "---------", */
604 #if defined( WIN32 ) && !defined( __CYGWIN__)
605     "Print",
606 #endif
607     "Snap Shot",
608     "---------", 
609     "Reset", 
610     "Load flight",
611     "Save flight",
612     NULL
613 };
614 puCallback fileSubmenuCb        [] = {
615     MayBeGoodBye, /* hideMenuCb, NULL, */
616 #if defined( WIN32 ) && !defined( __CYGWIN__)
617     printScreen, 
618 #endif
619     /* NULL, notCb, */
620     dumpSnapShot,
621     NULL,
622     reInit, 
623     loadFlight,
624     saveFlight,
625     NULL
626 };
627
628 /*
629 char *editSubmenu               [] = {
630     "Edit text", NULL
631 };
632 puCallback editSubmenuCb        [] = {
633     notCb, NULL
634 };
635 */
636
637 extern void fgHUDalphaAdjust( puObject * );
638 char *viewSubmenu               [] = {
639     "HUD Alpha",
640     "Pilot Offset",
641     /* "Cockpit View > ", "View >","------------", */
642     "Toggle Panel...", NULL
643 };
644 puCallback viewSubmenuCb        [] = {
645     fgHUDalphaAdjust,
646     PilotOffsetAdjust,
647     /* notCb, notCb, NULL, */
648     guiTogglePanel, NULL
649 };
650
651 //  "---------", 
652
653 char *autopilotSubmenu           [] = {
654     "Toggle HUD Format", "Adjust AP Settings",
655     "---------", 
656     "Clear Route", "Skip Current Waypoint", "Add Waypoint",
657     "---------", 
658     "Set Altitude", "Set Heading",
659     NULL
660 };
661
662 puCallback autopilotSubmenuCb    [] = {
663     fgLatLonFormatToggle, fgAPAdjust,
664     NULL,
665     ClearRoute, PopWayPoint, AddWayPoint,
666     NULL,
667     NewAltitude, NewHeading,
668     /* notCb, */ NULL
669 };
670
671 char *environmentSubmenu        [] = {
672     "Goto Airport", /* "Terrain", "Weather", */ NULL
673 };
674 puCallback environmentSubmenuCb [] = {
675     NewAirport, /* notCb, notCb, */ NULL
676 };
677
678 /*
679 char *optionsSubmenu            [] = {
680     "Preferences", "Realism & Reliablity...", NULL
681 };
682 puCallback optionsSubmenuCb     [] = {
683     notCb, notCb, NULL
684 };
685 */
686
687 #ifdef FG_NETWORK_OLK
688 char *networkSubmenu            [] = {
689     "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
690     "Register to FGD",
691     "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
692     "Toggle Display", NULL
693 };
694 puCallback networkSubmenuCb     [] = {
695     /* notCb, notCb, notCb, notCb, */ 
696     net_unregister, 
697     net_register, 
698     net_fgd_scan, NewCallSign, 
699     net_display_toggle, NULL
700 };
701 #endif
702
703 char *helpSubmenu               [] = {
704     /* "About...", */ "Help", NULL
705 };
706 puCallback helpSubmenuCb        [] = {
707     /* notCb, */ helpCb, NULL
708 };
709
710
711 /* -------------------------------------------------------------------------
712 init the gui
713 _____________________________________________________________________*/
714
715
716 void guiInit()
717 {
718     char *mesa_win_state;
719
720     // Initialize PUI
721     puInit();
722     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
723     puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
724
725     // Initialize our GLOBAL GUI STRINGS
726     gui_msg_OK     = msg_OK;     // "OK"
727     gui_msg_NO     = msg_NO;     // "NO"
728     gui_msg_YES    = msg_YES;    // "YES"
729     gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
730     gui_msg_RESET  = msg_RESET;  // "RESET"
731
732     // Next check home directory
733     FGPath fntpath;
734     char* envp = ::getenv( "FG_FONTS" );
735     if ( envp != NULL ) {
736         fntpath.set( envp );
737     } else {
738         fntpath.set( globals->get_fg_root() );
739         fntpath.append( "Fonts" );
740     }
741
742     // Install our fast fonts
743     fntpath.append( "typewriter.txf" );
744     guiFntHandle = new fntTexFont ;
745     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
746     puFont GuiFont ( guiFntHandle, 15 ) ;
747     puSetDefaultFonts( GuiFont, GuiFont ) ;
748     guiFnt = puGetDefaultLabelFont();
749   
750     if (!fgHasValue("/sim/startup/mouse-pointer")) {
751         // no preference specified for mouse pointer, attempt to autodetect...
752         // Determine if we need to render the cursor, or if the windowing
753         // system will do it.  First test if we are rendering with glide.
754         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
755             // Test for the MESA_GLX_FX env variable
756             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
757                 // test if we are fullscreen mesa/glide
758                 if ( (mesa_win_state[0] == 'f') ||
759                      (mesa_win_state[0] == 'F') ) {
760                     puShowCursor ();
761                 }
762             }
763         }
764 //        mouse_active = ~mouse_active;
765     } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
766         // don't show pointer
767     } else {
768         // force showing pointer
769         puShowCursor();
770 //        mouse_active = ~mouse_active;
771     }
772         
773     // MOUSE_VIEW mode stuff
774         initMouseQuat();
775
776     // Set up our Dialog Boxes
777     ConfirmExitDialogInit();
778     NewAirportInit();
779 #ifdef FG_NETWORK_OLK
780     NewNetIdInit();
781     NewNetFGDInit();
782 #endif
783
784         mkDialogInit();
785     
786     // Make the menu bar
787     mainMenuBar = new puMenuBar ();
788     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
789     // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
790     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
791     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
792     mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
793     // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
794 #ifdef FG_NETWORK_OLK
795     if ( fgGetBool("/sim/networking/network-olk") ) {
796         mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
797     }
798 #endif
799     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
800     mainMenuBar-> close ();
801     // Set up menu bar toggle
802     gui_menu_on = ~0;
803 }
804