]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
Changes to begin incorporating plib support for managing and rendering the
[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  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  * $Id$
22  **************************************************************************/
23
24
25 #ifdef HAVE_CONFIG_H
26 #  include <config.h>
27 #endif
28
29 #include <Include/compiler.h>
30
31 #ifdef FG_MATH_EXCEPTION_CLASH
32 #  include <math.h>
33 #endif
34
35 #ifdef HAVE_WINDOWS_H
36 #  include <windows.h>
37 #endif
38
39 #include <GL/glut.h>
40 #include <XGL/xgl.h>
41
42 #if defined(FX) && defined(XMESA)
43 #  include <GL/xmesa.h>
44 #endif
45
46 #include STL_STRING
47
48 #include <stdlib.h>
49 #include <string.h>
50
51 #include <Include/general.hxx>
52 #include <Debug/logstream.hxx>
53 #include <Aircraft/aircraft.hxx>
54 #include <Airports/simple.hxx>
55 #include <Cockpit/panel.hxx>
56 #include <FDM/flight.hxx>
57 #include <Main/options.hxx>
58 #include <Main/fg_init.hxx>
59 #include <Main/views.hxx>
60 #include <Misc/fgpath.hxx>
61 #include <Network/network.h>
62 #include <Time/fg_time.hxx>
63
64 #include "gui.h"
65
66 FG_USING_STD(string);
67
68 puFont guiFnt = 0;
69 fntTexFont *guiFntHandle = 0;
70
71 static puMenuBar    *mainMenuBar = 0;
72 //static puButton     *hideMenuButton = 0;
73
74 static puDialogBox  *dialogBox = 0;
75 static puFrame      *dialogFrame = 0;
76 static puText       *dialogBoxMessage = 0;
77 static puOneShot    *dialogBoxOkButton = 0;
78
79
80 static puDialogBox  *YNdialogBox = 0;
81 static puFrame      *YNdialogFrame = 0;
82 static puText       *YNdialogBoxMessage = 0;
83 static puOneShot    *YNdialogBoxOkButton = 0;
84 static puOneShot    *YNdialogBoxNoButton = 0;
85
86 static char msg_OK[]     = "OK";
87 static char msg_NO[]     = "NO";
88 static char msg_YES[]    = "YES";
89 static char msg_CANCEL[] = "Cancel";
90 static char msg_RESET[]  = "Reset";
91
92 char *gui_msg_OK;     // "OK"
93 char *gui_msg_NO;     // "NO"
94 char *gui_msg_YES;    // "YES"
95 char *gui_msg_CANCEL; // "CANCEL"
96 char *gui_msg_RESET;  // "RESET"
97
98 static char global_dialog_string[256];
99
100 extern void NewAltitude( puObject *cb );
101 extern void NewHeading( puObject *cb );
102 extern void fgAPAdjust( puObject * );
103 extern void fgLatLonFormatToggle( puObject *);
104
105 /* --------------------------------------------------------------------
106 Mouse stuff
107 ---------------------------------------------------------------------*/
108
109 static int _mX = 0;
110 static int  _mY = 0;
111 static int last_buttons = 0 ;
112 static int mouse_active = 0;
113 static int menu_on = 0;
114
115 void guiMotionFunc ( int x, int y )
116 {
117     _mX = x;
118     _mY = y;
119     puMouse ( x, y ) ;
120     glutPostRedisplay () ;
121 }
122
123 void guiMouseFunc(int button, int updown, int x, int y)
124 {
125     _mX = x;
126     _mY = y;
127     if ( updown == PU_DOWN )
128         last_buttons |=  ( 1 << button ) ;
129     else
130         last_buttons &= ~( 1 << button ) ;
131     puMouse (button, updown, x,y);
132     glutPostRedisplay ();
133 }
134
135 int guiGetMouseButton(void)
136 {
137     return last_buttons;
138 }
139
140 void guiGetMouse(int *x, int *y)
141 {
142     *x = _mX;
143     *y = _mY;
144 };
145
146 static inline void TurnCursorOn( void )
147 {
148     mouse_active = ~0;
149 #if defined ( WIN32 ) || defined(__CYGWIN32__)
150     glutSetCursor(GLUT_CURSOR_INHERIT);
151 #endif
152 #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
153     glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH)/2, glutGet(GLUT_SCREEN_HEIGHT)/2);
154 #endif
155 }
156
157 static inline void TurnCursorOff( void )
158 {
159     mouse_active = 0;
160 #if defined ( WIN32 ) || defined(__CYGWIN32__)
161     glutSetCursor(GLUT_CURSOR_NONE);
162 #else  // I guess this is what we want to do ??
163 #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
164     glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
165 #endif
166 #endif
167 }
168
169 void maybeToggleMouse( void )
170 {
171 #ifdef WIN32
172     static int first_time = ~0;
173     static int mouse_changed = 0;
174
175     if ( first_time ) {
176         if(!mouse_active) {
177             mouse_changed = ~mouse_changed;
178             TurnCursorOn();
179         }
180     } else {
181         if( mouse_changed ) {
182             mouse_changed = ~mouse_changed;
183             if(mouse_active) {
184                 TurnCursorOff();
185             }
186         }
187     }
188     first_time = ~first_time;
189 #endif // #ifdef WIN32
190 }
191
192 // Call with FALSE to init and TRUE to restore
193 void BusyCursor( int restore )
194 {
195     static int cursor = 0;
196     if( restore ) {
197         glutSetCursor(cursor);
198     } else {
199         cursor = glutGet( GLUT_WINDOW_CURSOR );
200 #ifdef WIN32
201         TurnCursorOn();
202 #endif
203         glutSetCursor( GLUT_CURSOR_WAIT );
204     }
205 }
206 /* ================ General Purpose Functions ================ */
207
208 // Intercept the Escape Key
209 void ConfirmExitDialog(void)
210 {
211     FG_PUSH_PUI_DIALOG( YNdialogBox );
212 }
213
214 // General Purpose Message Box
215 void mkDialog (const char *txt)
216 {
217     strncpy(global_dialog_string, txt, 256);
218     dialogBoxMessage->setLabel(global_dialog_string);
219     FG_PUSH_PUI_DIALOG( dialogBox );
220 }
221
222 // Repair any damage done to the Panel by other Gui Items
223 void guiFixPanel( void )
224 {
225     int toggle_pause;
226
227     if ( current_options.get_panel_status() ) {
228         FGView *v = &current_view;
229         FGTime *t = FGTime::cur_time_params;
230
231         if( (toggle_pause = !t->getPause()) )
232             t->togglePauseMode();
233
234         // this seems to be the only way to do this :-(
235         // problem is the viewport has been mucked with
236         xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
237         FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
238
239         if(toggle_pause)
240             t->togglePauseMode();
241     }
242 }
243
244 // Toggle the Menu and Mouse display state
245 void guiToggleMenu(void)
246 {
247     if( menu_on ) {
248         // printf("Hiding Menu\n");
249         mainMenuBar->hide  ();
250 #ifdef WIN32
251         TurnCursorOff();
252 #endif // #ifdef WIN32
253     } else {
254         // printf("Showing Menu\n");
255         mainMenuBar->reveal();
256 #ifdef WIN32
257         TurnCursorOn();
258 #endif // #ifdef WIN32
259     }
260     menu_on = ~menu_on;
261 }
262     
263 /* -----------------------------------------------------------------------
264 the Gui callback functions 
265 ____________________________________________________________________*/
266
267 void reInit(puObject *cb)
268 {
269     BusyCursor(0);
270     fgReInitSubsystems();
271     BusyCursor(1);
272 }
273         
274 // This is the accessor function
275 void guiTogglePanel(puObject *cb)
276 {
277     current_options.toggle_panel();
278 }
279     
280 //void MenuHideMenuCb(puObject *cb)
281 void hideMenuCb (puObject *cb)
282 {
283     guiToggleMenu();
284 }
285
286 void goodBye(puObject *)
287 {
288     // FG_LOG( FG_INPUT, FG_ALERT,
289     //      "Program exiting normally at user request." );
290     cout << "Program exiting normally at user request." << endl;
291
292     //  if(gps_bug)
293     //      fclose(gps_bug);
294
295     exit(-1);
296 }
297
298
299 void goAwayCb (puObject *me)
300 {
301     FG_POP_PUI_DIALOG( dialogBox );
302 }
303
304 void mkDialogInit (void)
305 {
306     //  printf("mkDialogInit\n");
307     int x = (current_options.get_xsize()/2 - 400/2);
308     int y = (current_options.get_ysize()/2 - 100/2);
309     dialogBox = new puDialogBox (x, y); // 150, 50
310     {
311         dialogFrame = new puFrame (0,0,400,100);
312         dialogBoxMessage  =  new puText         (10, 70);
313         dialogBoxMessage  -> setLabel           ("");
314         dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
315         dialogBoxOkButton -> setLegend          (gui_msg_OK);
316         dialogBoxOkButton -> makeReturnDefault  (TRUE );
317         dialogBoxOkButton -> setCallback        (goAwayCb);
318     }
319     FG_FINALIZE_PUI_DIALOG( dialogBox );
320 }
321
322 void MayBeGoodBye(puObject *)
323 {
324     ConfirmExitDialog(); 
325 }
326
327 void goAwayYesNoCb(puObject *me)
328 {
329     FG_POP_PUI_DIALOG( YNdialogBox);
330 }
331
332 void ConfirmExitDialogInit(void)
333 {
334     char msg[] = "Really Quit";
335     char *s;
336
337     //  printf("ConfirmExitDialogInit\n");
338     int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
339
340     int x = (current_options.get_xsize()/2 - 400/2);
341     int y = (current_options.get_ysize()/2 - 100/2);
342         
343     YNdialogBox = new puDialogBox (x, y); // 150, 50
344     //  YNdialogBox = new puDialogBox (150, 50);
345     {
346         YNdialogFrame = new puFrame (0,0,400, 100);
347         
348         YNdialogBoxMessage  =  new puText         (len, 70);
349         YNdialogBoxMessage  -> setDefaultValue    (msg);
350         YNdialogBoxMessage  -> getDefaultValue    (&s);
351         YNdialogBoxMessage  -> setLabel           (s);
352         
353         YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
354         YNdialogBoxOkButton -> setLegend          (gui_msg_OK);
355         YNdialogBoxOkButton -> setCallback        (goodBye);
356         
357         YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
358         YNdialogBoxNoButton -> setLegend          (gui_msg_NO);
359         //      YNdialogBoxNoButton -> makeReturnDefault  (TRUE );
360         YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
361     }
362     FG_FINALIZE_PUI_DIALOG( YNdialogBox );
363 }
364
365 void notCb (puObject *)
366 {
367     mkDialog ("This function isn't implemented yet");
368 }
369
370 void helpCb (puObject *)
371 {
372     string command;
373         
374 #if defined(FX) && !defined(WIN32)
375 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
376     if ( global_fullscreen ) {
377         global_fullscreen = false;
378         XMesaSetFXmode( XMESA_FX_WINDOW );
379     }
380 #  endif
381 #endif
382         
383 #if !defined(WIN32)
384     string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
385         
386     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
387         command = "netscape -remote \"openURL(" + url + ")\" &";
388     } else {
389         command = "netscape " + url + " &";
390     }
391 #else
392     command = "webrun.bat";
393 #endif
394         
395     system( command.c_str() );
396     //string text = "Help started in netscape window.";
397
398     //mkDialog (text.c_str());
399     mkDialog ("Help started in netscape window.");
400 }
401
402 /// The beginnings of teleportation :-)
403 //  Needs cleaning up but works
404 //  These statics should disapear when this is a class
405 static puDialogBox     *AptDialog = 0;
406 static puFrame         *AptDialogFrame = 0;
407 static puText          *AptDialogMessage = 0;
408 static puInput         *AptDialogInput = 0;
409
410 static char NewAirportId[16];
411 static char NewAirportLabel[] = "Enter New Airport ID"; 
412
413 static puOneShot       *AptDialogOkButton = 0;
414 static puOneShot       *AptDialogCancelButton = 0;
415 static puOneShot       *AptDialogResetButton = 0;
416
417 void AptDialog_Cancel(puObject *)
418 {
419     FG_POP_PUI_DIALOG( AptDialog );
420 }
421
422 void AptDialog_OK (puObject *)
423 {
424     string AptId;
425     
426     FGTime *t = FGTime::cur_time_params;
427     int PauseMode = t->getPause();
428     if(!PauseMode)
429         t->togglePauseMode();
430
431     char *s;
432     AptDialogInput->getValue(&s);
433     AptId = s;
434     
435     AptDialog_Cancel( NULL );
436     
437     if ( AptId.length() ) {
438         // set initial position from airport id
439         fgAIRPORTS airports;
440         fgAIRPORT a;
441
442         FG_LOG( FG_GENERAL, FG_INFO,
443                 "Attempting to set starting position from airport code "
444                 << s );
445
446         airports.load("apt_simple");
447         if ( airports.search( AptId, &a ) )
448         {
449             current_options.set_airport_id( AptId.c_str() );
450             BusyCursor(0);
451             fgReInitSubsystems();
452             BusyCursor(1);
453         } else {
454             AptId  += " not in database.";
455             mkDialog(AptId.c_str());
456         }
457     }
458     if( PauseMode != t->getPause() )
459         t->togglePauseMode();
460 }
461
462 void AptDialog_Reset(puObject *)
463 {
464     //  strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
465     sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
466     AptDialogInput->setValue ( NewAirportId );
467     AptDialogInput->setCursor( 0 ) ;
468 }
469
470 void NewAirport(puObject *cb)
471 {
472     //  strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
473     sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
474     AptDialogInput->setValue( NewAirportId );
475
476     FG_PUSH_PUI_DIALOG( AptDialog );
477 }
478
479 static void NewAirportInit(void)
480 {
481     sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
482     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
483                                       NewAirportLabel ) / 2;
484
485     AptDialog = new puDialogBox (150, 50);
486     {
487         AptDialogFrame   = new puFrame           (0,0,350, 150);
488         AptDialogMessage = new puText            (len, 110);
489         AptDialogMessage ->    setLabel          (NewAirportLabel);
490
491         AptDialogInput   = new puInput           (50, 70, 300, 100);
492         AptDialogInput   ->    setValue          (NewAirportId);
493         AptDialogInput   ->    acceptInput();
494
495         AptDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
496         AptDialogOkButton     ->     setLegend   (gui_msg_OK);
497         AptDialogOkButton     ->     setCallback (AptDialog_OK);
498         AptDialogOkButton     ->     makeReturnDefault(TRUE);
499
500         AptDialogCancelButton =  new puOneShot   (140, 10, 210, 50);
501         AptDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
502         AptDialogCancelButton ->     setCallback (AptDialog_Cancel);
503
504         AptDialogResetButton  =  new puOneShot   (240, 10, 300, 50);
505         AptDialogResetButton  ->     setLegend   (gui_msg_RESET);
506         AptDialogResetButton  ->     setCallback (AptDialog_Reset);
507     }
508     FG_FINALIZE_PUI_DIALOG( AptDialog );
509 }
510
511 /// The beginnings of networking :-)
512 //  Needs cleaning up but works
513 //  These statics should disapear when this is a class
514 static puDialogBox     *NetIdDialog = 0;
515 static puFrame         *NetIdDialogFrame = 0;
516 static puText          *NetIdDialogMessage = 0;
517 static puInput         *NetIdDialogInput = 0;
518
519 static char NewNetId[16];
520 static char NewNetIdLabel[] = "Enter New Callsign"; 
521
522 static puOneShot       *NetIdDialogOkButton = 0;
523 static puOneShot       *NetIdDialogCancelButton = 0;
524
525 void NetIdDialog_Cancel(puObject *)
526 {
527     FG_POP_PUI_DIALOG( NetIdDialog );
528 }
529
530 void NetIdDialog_OK (puObject *)
531 {
532     string NetId;
533     
534     FGTime *t = FGTime::cur_time_params;
535     int PauseMode = t->getPause();
536     if(!PauseMode)
537         t->togglePauseMode();
538
539     char *s;
540     NetIdDialogInput->getValue(&s);
541     NetId = s;
542     
543     NetIdDialog_Cancel( NULL );
544     current_options.set_net_id( NetId.c_str() );
545     net_hud_display = 1;
546
547     if( PauseMode != t->getPause() )
548         t->togglePauseMode();
549 }
550
551 void NewCallSign(puObject *cb)
552 {
553     sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
554     NetIdDialogInput->setValue( NewNetId );
555
556     FG_PUSH_PUI_DIALOG( NetIdDialog );
557 }
558
559 static void NewNetIdInit(void)
560 {
561     sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
562     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
563                                       NewNetIdLabel ) / 2;
564
565     NetIdDialog = new puDialogBox (150, 50);
566     {
567         NetIdDialogFrame   = new puFrame           (0,0,350, 150);
568         NetIdDialogMessage = new puText            (len, 110);
569         NetIdDialogMessage ->    setLabel          (NewNetIdLabel);
570
571         NetIdDialogInput   = new puInput           (50, 70, 300, 100);
572         NetIdDialogInput   ->    setValue          (NewNetId);
573         NetIdDialogInput   ->    acceptInput();
574
575         NetIdDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
576         NetIdDialogOkButton     ->     setLegend   (gui_msg_OK);
577         NetIdDialogOkButton     ->     setCallback (NetIdDialog_OK);
578         NetIdDialogOkButton     ->     makeReturnDefault(TRUE);
579
580         NetIdDialogCancelButton =  new puOneShot   (240, 10, 300, 50);
581         NetIdDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
582         NetIdDialogCancelButton ->     setCallback (NetIdDialog_Cancel);
583
584     }
585     FG_FINALIZE_PUI_DIALOG( NetIdDialog );
586 }
587
588 static void net_display_toggle( puObject *cb)
589 {
590         net_hud_display = (net_hud_display) ? 0 : 1;
591 }
592
593 /***************  End Networking  **************/
594
595
596
597 /* -----------------------------------------------------------------------
598 The menu stuff 
599 ---------------------------------------------------------------------*/
600 char *fileSubmenu               [] = {
601     "Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL
602 };
603 puCallback fileSubmenuCb        [] = {
604     MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL
605 };
606
607 char *editSubmenu               [] = {
608     "Edit text", NULL
609 };
610 puCallback editSubmenuCb        [] = {
611     notCb, NULL
612 };
613
614 char *viewSubmenu               [] = {
615     "Cockpit View > ", "View >","------------", "Toggle Panel...", NULL
616 };
617 puCallback viewSubmenuCb        [] = {
618     notCb, notCb, NULL, guiTogglePanel, NULL
619 };
620
621 char *aircraftSubmenu           [] = {
622     "Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
623 };
624 puCallback aircraftSubmenuCb    [] = {
625     fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
626 };
627
628 char *environmentSubmenu        [] = {
629     "Airport", "Terrain", "Weather", NULL
630 };
631 puCallback environmentSubmenuCb [] = {
632     NewAirport, notCb, notCb, NULL
633 };
634
635 char *optionsSubmenu            [] = {
636     "Preferences", "Realism & Reliablity...", NULL
637 };
638 puCallback optionsSubmenuCb     [] = {
639     notCb, notCb, NULL
640 };
641
642 #ifdef FG_NETWORK_OLK
643 char *networkSubmenu            [] = {
644     "Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", "Register to FGD",
645     "Scan for Deamons", "Enter Callsign", "Display Netinfos", "Toggle Display", NULL
646 };
647 puCallback networkSubmenuCb     [] = {
648     notCb, notCb, notCb, notCb, notCb, notCb, NewCallSign, notCb,
649     net_display_toggle, NULL
650 };
651 #endif
652
653 char *helpSubmenu               [] = {
654     "About...", "Help", NULL
655 };
656 puCallback helpSubmenuCb        [] = {
657     notCb, helpCb, NULL
658 };
659
660
661 /* -------------------------------------------------------------------------
662 init the gui
663 _____________________________________________________________________*/
664
665
666 void guiInit()
667 {
668     char *mesa_win_state;
669
670     // Initialize PUI
671     puInit();
672     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
673     puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
674
675     // Initialize our GLOBAL GUI STRINGS
676     gui_msg_OK     = msg_OK;     // "OK"
677     gui_msg_NO     = msg_NO;     // "NO"
678     gui_msg_YES    = msg_YES;    // "YES"
679     gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
680     gui_msg_RESET  = msg_RESET;  // "RESET"
681
682     // Next check home directory
683     FGPath fntpath;
684     char* envp = ::getenv( "FG_FONTS" );
685     if ( envp != NULL ) {
686         fntpath.set( envp );
687     } else {
688         fntpath.set( current_options.get_fg_root() );
689         fntpath.append( "Fonts" );
690     }
691
692     // Install our fast fonts
693     fntpath.append( "typewriter.txf" );
694     guiFntHandle = new fntTexFont ;
695     guiFntHandle -> load ( fntpath.c_str() ) ;
696     puFont GuiFont ( guiFntHandle, 15 ) ;
697     puSetDefaultFonts( GuiFont, GuiFont ) ;
698     guiFnt = puGetDefaultLabelFont();
699   
700     if ( current_options.get_mouse_pointer() == 0 ) {
701         // no preference specified for mouse pointer, attempt to autodetect...
702         // Determine if we need to render the cursor, or if the windowing
703         // system will do it.  First test if we are rendering with glide.
704         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
705             // Test for the MESA_GLX_FX env variable
706             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
707                 // test if we are fullscreen mesa/glide
708                 if ( (mesa_win_state[0] == 'f') ||
709                      (mesa_win_state[0] == 'F') ) {
710                     puShowCursor ();
711                 }
712             }
713         }
714         mouse_active = ~mouse_active;
715     } else if ( current_options.get_mouse_pointer() == 1 ) {
716         // don't show pointer
717     } else if ( current_options.get_mouse_pointer() == 2 ) {
718         // force showing pointer
719         puShowCursor();
720         mouse_active = ~mouse_active;
721     }
722
723     // Set up our Dialog Boxes
724     ConfirmExitDialogInit();
725     NewAirportInit();
726 #ifdef FG_NETWORK_OLK
727     NewNetIdInit();
728 #endif
729     mkDialogInit();
730     
731     // Make the menu bar
732     mainMenuBar = new puMenuBar ();
733     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
734     mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
735     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
736     mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
737     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
738     mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
739 #ifdef FG_NETWORK_OLK
740     mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
741 #endif
742     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
743     mainMenuBar-> close ();
744     // Set up menu bar toggle
745     menu_on = ~0;
746 }