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