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