]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
8c130f24c4464d7183e47b8993ced87c7212aad8
[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    The following needs some cleanup because 
544    "string options.NetId" and "char *net_callsign" 
545 */
546     NetIdDialogInput->getValue(&net_callsign);
547     NetId = net_callsign;
548     
549     NetIdDialog_Cancel( NULL );
550     current_options.set_net_id( NetId.c_str() );
551 /* Entering a callsign indicates : user wants Net HUD Info */
552     net_hud_display = 1;
553
554     if( PauseMode != t->getPause() )
555         t->togglePauseMode();
556 }
557
558 void NewCallSign(puObject *cb)
559 {
560     sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
561     NetIdDialogInput->setValue( NewNetId );
562
563     FG_PUSH_PUI_DIALOG( NetIdDialog );
564 }
565
566 static void NewNetIdInit(void)
567 {
568     sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
569     int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
570                                       NewNetIdLabel ) / 2;
571
572     NetIdDialog = new puDialogBox (150, 50);
573     {
574         NetIdDialogFrame   = new puFrame           (0,0,350, 150);
575         NetIdDialogMessage = new puText            (len, 110);
576         NetIdDialogMessage ->    setLabel          (NewNetIdLabel);
577
578         NetIdDialogInput   = new puInput           (50, 70, 300, 100);
579         NetIdDialogInput   ->    setValue          (NewNetId);
580         NetIdDialogInput   ->    acceptInput();
581
582         NetIdDialogOkButton     =  new puOneShot   (50, 10, 110, 50);
583         NetIdDialogOkButton     ->     setLegend   (gui_msg_OK);
584         NetIdDialogOkButton     ->     setCallback (NetIdDialog_OK);
585         NetIdDialogOkButton     ->     makeReturnDefault(TRUE);
586
587         NetIdDialogCancelButton =  new puOneShot   (240, 10, 300, 50);
588         NetIdDialogCancelButton ->     setLegend   (gui_msg_CANCEL);
589         NetIdDialogCancelButton ->     setCallback (NetIdDialog_Cancel);
590
591     }
592     FG_FINALIZE_PUI_DIALOG( NetIdDialog );
593 }
594
595 static void net_display_toggle( puObject *cb)
596 {
597         net_hud_display = (net_hud_display) ? 0 : 1;
598         printf("Toggle net_hud_display : %d\n", net_hud_display);
599 }
600
601 static void net_blaster_toggle( puObject *cb)
602 {
603         net_blast_toggle = (net_blast_toggle) ? 0 : -1;
604         printf("Toggle net_blast : %d\n", net_blast_toggle);
605 }
606
607 /***************  End Networking  **************/
608
609
610
611 /* -----------------------------------------------------------------------
612 The menu stuff 
613 ---------------------------------------------------------------------*/
614 char *fileSubmenu               [] = {
615     "Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL
616 };
617 puCallback fileSubmenuCb        [] = {
618     MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL
619 };
620
621 char *editSubmenu               [] = {
622     "Edit text", NULL
623 };
624 puCallback editSubmenuCb        [] = {
625     notCb, NULL
626 };
627
628 char *viewSubmenu               [] = {
629     "Cockpit View > ", "View >","------------", "Toggle Panel...", NULL
630 };
631 puCallback viewSubmenuCb        [] = {
632     notCb, notCb, NULL, guiTogglePanel, NULL
633 };
634
635 char *aircraftSubmenu           [] = {
636     "Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
637 };
638 puCallback aircraftSubmenuCb    [] = {
639     fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
640 };
641
642 char *environmentSubmenu        [] = {
643     "Airport", "Terrain", "Weather", NULL
644 };
645 puCallback environmentSubmenuCb [] = {
646     NewAirport, notCb, notCb, NULL
647 };
648
649 char *optionsSubmenu            [] = {
650     "Preferences", "Realism & Reliablity...", NULL
651 };
652 puCallback optionsSubmenuCb     [] = {
653     notCb, notCb, NULL
654 };
655
656 #ifdef FG_NETWORK_OLK
657 char *networkSubmenu            [] = {
658     "Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", "Register to FGD",
659     "Scan for Deamons", "Enter Callsign", "Display Netinfos", "Toggle Display",
660     "Hyper Blast", NULL
661 };
662 puCallback networkSubmenuCb     [] = {
663     notCb, notCb, notCb, notCb, notCb, notCb, NewCallSign, notCb,
664     net_display_toggle, net_blaster_toggle, NULL
665 };
666 #endif
667
668 char *helpSubmenu               [] = {
669     "About...", "Help", NULL
670 };
671 puCallback helpSubmenuCb        [] = {
672     notCb, helpCb, NULL
673 };
674
675
676 /* -------------------------------------------------------------------------
677 init the gui
678 _____________________________________________________________________*/
679
680
681 void guiInit()
682 {
683     char *mesa_win_state;
684
685     // Initialize PUI
686     puInit();
687     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
688     puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
689
690     // Initialize our GLOBAL GUI STRINGS
691     gui_msg_OK     = msg_OK;     // "OK"
692     gui_msg_NO     = msg_NO;     // "NO"
693     gui_msg_YES    = msg_YES;    // "YES"
694     gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
695     gui_msg_RESET  = msg_RESET;  // "RESET"
696
697     // Next check home directory
698     FGPath fntpath;
699     char* envp = ::getenv( "FG_FONTS" );
700     if ( envp != NULL ) {
701         fntpath.set( envp );
702     } else {
703         fntpath.set( current_options.get_fg_root() );
704         fntpath.append( "Fonts" );
705     }
706
707     // Install our fast fonts
708     fntpath.append( "typewriter.txf" );
709     guiFntHandle = new fntTexFont ;
710     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
711     puFont GuiFont ( guiFntHandle, 15 ) ;
712     puSetDefaultFonts( GuiFont, GuiFont ) ;
713     guiFnt = puGetDefaultLabelFont();
714   
715     if ( current_options.get_mouse_pointer() == 0 ) {
716         // no preference specified for mouse pointer, attempt to autodetect...
717         // Determine if we need to render the cursor, or if the windowing
718         // system will do it.  First test if we are rendering with glide.
719         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
720             // Test for the MESA_GLX_FX env variable
721             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
722                 // test if we are fullscreen mesa/glide
723                 if ( (mesa_win_state[0] == 'f') ||
724                      (mesa_win_state[0] == 'F') ) {
725                     puShowCursor ();
726                 }
727             }
728         }
729         mouse_active = ~mouse_active;
730     } else if ( current_options.get_mouse_pointer() == 1 ) {
731         // don't show pointer
732     } else if ( current_options.get_mouse_pointer() == 2 ) {
733         // force showing pointer
734         puShowCursor();
735         mouse_active = ~mouse_active;
736     }
737
738     // Set up our Dialog Boxes
739     ConfirmExitDialogInit();
740     NewAirportInit();
741 #ifdef FG_NETWORK_OLK
742     NewNetIdInit();
743 #endif
744     mkDialogInit();
745     
746     // Make the menu bar
747     mainMenuBar = new puMenuBar ();
748     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
749     mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
750     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
751     mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
752     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
753     mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
754 #ifdef FG_NETWORK_OLK
755     mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
756 #endif
757     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
758     mainMenuBar-> close ();
759     // Set up menu bar toggle
760     menu_on = ~0;
761 }