]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
7d08b547a7a0ed6c373f8caee5a558548173a67e
[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   if (fgGetBool("/sim/panel/visibility"))
319     fgSetBool("/sim/panel/visibility", false);
320   else
321     fgSetBool("/sim/panel/visibility", true);
322
323   fgReshape(fgGetInt("/sim/startup/xsize"),
324             fgGetInt("/sim/startup/ysize"));
325 }
326     
327 //void MenuHideMenuCb(puObject *cb)
328 void hideMenuCb (puObject *cb)
329 {
330     guiToggleMenu();
331 }
332
333 void goodBye(puObject *)
334 {
335     // FG_LOG( FG_INPUT, FG_ALERT,
336     //      "Program exiting normally at user request." );
337     cout << "Program exiting normally at user request." << endl;
338
339 #ifdef FG_NETWORK_OLK    
340     if ( fgGetBool("/sim/networking/network-olk") ) {
341         if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
342     }
343 #endif
344
345     // close all external I/O connections
346     fgIOShutdownAll();
347
348     exit(0);
349 }
350
351
352 void goAwayCb (puObject *me)
353 {
354     FG_POP_PUI_DIALOG( dialogBox );
355 }
356
357 void mkDialogInit (void)
358 {
359     //  printf("mkDialogInit\n");
360     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
361     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
362     dialogBox = new puDialogBox (x, y); // 150, 50
363     {
364         dialogFrame = new puFrame (0,0,400,100);
365         dialogBoxMessage  =  new puText         (10, 70);
366         dialogBoxMessage  -> setLabel           ("");
367         dialogBoxOkButton =  new puOneShot      (180, 10, 240, 50);
368         dialogBoxOkButton -> setLegend          (gui_msg_OK);
369         dialogBoxOkButton -> makeReturnDefault  (TRUE );
370         dialogBoxOkButton -> setCallback        (goAwayCb);
371     }
372     FG_FINALIZE_PUI_DIALOG( dialogBox );
373 }
374
375 void MayBeGoodBye(puObject *)
376 {
377     ConfirmExitDialog(); 
378 }
379
380 void goAwayYesNoCb(puObject *me)
381 {
382     FG_POP_PUI_DIALOG( YNdialogBox);
383 }
384
385 void ConfirmExitDialogInit(void)
386 {
387     char msg[] = "Really Quit";
388     char *s;
389
390     //  printf("ConfirmExitDialogInit\n");
391     int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
392
393     int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
394     int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
395         
396     YNdialogBox = new puDialogBox (x, y); // 150, 50
397     //  YNdialogBox = new puDialogBox (150, 50);
398     {
399         YNdialogFrame = new puFrame (0,0,400, 100);
400         
401         YNdialogBoxMessage  =  new puText         (len, 70);
402         YNdialogBoxMessage  -> setDefaultValue    (msg);
403         YNdialogBoxMessage  -> getDefaultValue    (&s);
404         YNdialogBoxMessage  -> setLabel           (s);
405         
406         YNdialogBoxOkButton =  new puOneShot      (100, 10, 160, 50);
407         YNdialogBoxOkButton -> setLegend          (gui_msg_OK);
408         YNdialogBoxOkButton -> makeReturnDefault  (TRUE );
409         YNdialogBoxOkButton -> setCallback        (goodBye);
410         
411         YNdialogBoxNoButton =  new puOneShot      (240, 10, 300, 50);
412         YNdialogBoxNoButton -> setLegend          (gui_msg_NO);
413         YNdialogBoxNoButton -> setCallback        (goAwayYesNoCb);
414     }
415     FG_FINALIZE_PUI_DIALOG( YNdialogBox );
416 }
417
418 void notCb (puObject *)
419 {
420     mkDialog ("This function isn't implemented yet");
421 }
422
423 void helpCb (puObject *)
424 {
425     string command;
426         
427 #if defined(FX) && !defined(WIN32)
428 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
429     if ( global_fullscreen ) {
430         global_fullscreen = false;
431         XMesaSetFXmode( XMESA_FX_WINDOW );
432     }
433 #  endif
434 #endif
435         
436 #if !defined(WIN32)
437     string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
438         
439     if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
440         command = "netscape -remote \"openURL(" + url + ")\" &";
441     } else {
442         command = "netscape " + url + " &";
443     }
444 #else
445     command = "webrun.bat";
446 #endif
447         
448     system( command.c_str() );
449     //string text = "Help started in netscape window.";
450
451     //mkDialog (text.c_str());
452     mkDialog ("Help started in netscape window.");
453 }
454
455 #if defined( WIN32 ) && !defined( __CYGWIN__)
456
457 static void rotateView( double roll, double pitch, double yaw )
458 {
459         // rotate view
460 }
461
462 static GlBitmap *b1 = NULL;
463 extern FGInterface cur_view_fdm;
464 GLubyte *hiResScreenCapture( int multiplier )
465 {
466     float oldfov = fgGetDouble("/sim/field-of-view");
467     float fov = oldfov / multiplier;
468     FGViewer *v = globals->get_current_view();
469     fgSetDouble("/sim/field-of-view", fov);
470     fgInitVisuals();
471     int cur_width = fgGetInt("/sim/startup/xsize");
472     int cur_height = fgGetInt("/sim/startup/ysize");
473     if (b1) delete( b1 );
474     // New empty (mostly) bitmap
475     b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
476     int x,y;
477     for ( y = 0; y < multiplier; y++ ) {
478         for ( x = 0; x < multiplier; x++ ) {
479             fgReshape( cur_width, cur_height );
480             // pan to tile
481             rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
482             fgRenderFrame();
483             // restore view
484             GlBitmap b2;
485             b1->copyBitmap( &b2, cur_width*x, cur_height*y );
486         }
487     }
488     fgSetDouble("/sim/field-of-view", oldfov);
489     return b1->getBitmap();
490 }
491 #endif
492
493
494 #if defined( WIN32 ) && !defined( __CYGWIN__)
495 // win32 print screen function
496 void printScreen ( puObject *obj ) {
497     bool show_pu_cursor = false;
498     TurnCursorOff();
499     if ( !puCursorIsHidden() ) {
500         show_pu_cursor = true;
501         puHideCursor();
502     }
503     BusyCursor( 0 );
504     mainMenuBar->hide();
505
506     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
507     int cur_width = fgGetInt("/sim/startup/xsize");
508     int cur_height = fgGetInt("/sim/startup/ysize");
509     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
510         p.End( hiResScreenCapture(3) );
511
512     if( gui_menu_on ) {
513         mainMenuBar->reveal();
514     }
515     BusyCursor(1);
516     if ( show_pu_cursor ) {
517         puShowCursor();
518     }
519     TurnCursorOn();
520 }
521 #endif // #ifdef WIN32
522
523
524 void dumpSnapShot ( puObject *obj ) {
525     fgDumpSnapShot();
526 }
527
528
529 // do a screen snap shot
530 void fgDumpSnapShot () {
531     bool show_pu_cursor = false;
532
533     int freeze = globals->get_freeze();
534     if(!freeze)
535         globals->set_freeze( true );
536
537     mainMenuBar->hide();
538     TurnCursorOff();
539     if ( !puCursorIsHidden() ) {
540         show_pu_cursor = true;
541         puHideCursor();
542     }
543
544     fgInitVisuals();
545     fgReshape( fgGetInt("/sim/startup/xsize"),
546                fgGetInt("/sim/startup/ysize") );
547
548     // we need two render frames here to clear the menu and cursor
549     // ... not sure why but doing an extra fgFenderFrame() shoulnd't
550     // hurt anything
551     fgRenderFrame();
552     fgRenderFrame();
553
554     my_glDumpWindow( "fgfs-screen.ppm", 
555                      fgGetInt("/sim/startup/xsize"), 
556                      fgGetInt("/sim/startup/ysize") );
557     
558     mkDialog ("Snap shot saved to fgfs-screen.ppm");
559
560     if ( show_pu_cursor ) {
561         puShowCursor();
562     }
563
564     TurnCursorOn();
565     if( gui_menu_on ) {
566         mainMenuBar->reveal();
567     }
568
569     if(!freeze)
570         globals->set_freeze( false );
571 }
572
573 #ifdef FG_NETWORK_OLK
574 static void net_display_toggle( puObject *cb)
575 {
576         net_hud_display = (net_hud_display) ? 0 : 1;
577         printf("Toggle net_hud_display : %d\n", net_hud_display);
578 }
579
580 static void net_register( puObject *cb)
581 {
582         fgd_send_com( "1", FGFS_host );
583         net_is_registered = 0;
584         printf("Registering to deamon\n");
585 }
586
587 static void net_unregister( puObject *cb)
588 {
589         fgd_send_com( "8", FGFS_host );
590         net_is_registered = -1;
591         printf("Unregistering from deamon\n");
592 }
593
594 extern void net_fgd_scan(puObject *cb);
595 #endif // #ifdef FG_NETWORK_OLK
596
597 /* -----------------------------------------------------------------------
598 The menu stuff 
599 ---------------------------------------------------------------------*/
600 char *fileSubmenu               [] = {
601     "Exit", /* "Close", "---------", */
602 #if defined( WIN32 ) && !defined( __CYGWIN__)
603     "Print",
604 #endif
605     "Snap Shot",
606     "---------", 
607     "Reset", 
608     "Load flight",
609     "Save flight",
610     NULL
611 };
612 puCallback fileSubmenuCb        [] = {
613     MayBeGoodBye, /* hideMenuCb, NULL, */
614 #if defined( WIN32 ) && !defined( __CYGWIN__)
615     printScreen, 
616 #endif
617     /* NULL, notCb, */
618     dumpSnapShot,
619     NULL,
620     reInit, 
621     loadFlight,
622     saveFlight,
623     NULL
624 };
625
626 /*
627 char *editSubmenu               [] = {
628     "Edit text", NULL
629 };
630 puCallback editSubmenuCb        [] = {
631     notCb, NULL
632 };
633 */
634
635 extern void fgHUDalphaAdjust( puObject * );
636 char *viewSubmenu               [] = {
637     "HUD Alpha",
638     /* "Cockpit View > ", "View >","------------", */
639     "Toggle Panel...", NULL
640 };
641 puCallback viewSubmenuCb        [] = {
642     fgHUDalphaAdjust,
643     /* notCb, notCb, NULL, */
644     guiTogglePanel, NULL
645 };
646
647 //  "---------", 
648
649 char *autopilotSubmenu           [] = {
650     "Toggle HUD Format", "Adjust AP Settings",
651     "---------", 
652     "Clear Route", "Skip Current Waypoint", "Add Waypoint",
653     "---------", 
654     "Set Altitude", "Set Heading",
655     NULL
656 };
657
658 puCallback autopilotSubmenuCb    [] = {
659     fgLatLonFormatToggle, fgAPAdjust,
660     NULL,
661     ClearRoute, PopWayPoint, AddWayPoint,
662     NULL,
663     NewAltitude, NewHeading,
664     /* notCb, */ NULL
665 };
666
667 char *environmentSubmenu        [] = {
668     "Goto Airport", /* "Terrain", "Weather", */ NULL
669 };
670 puCallback environmentSubmenuCb [] = {
671     NewAirport, /* notCb, notCb, */ NULL
672 };
673
674 /*
675 char *optionsSubmenu            [] = {
676     "Preferences", "Realism & Reliablity...", NULL
677 };
678 puCallback optionsSubmenuCb     [] = {
679     notCb, notCb, NULL
680 };
681 */
682
683 #ifdef FG_NETWORK_OLK
684 char *networkSubmenu            [] = {
685     "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
686     "Register to FGD",
687     "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
688     "Toggle Display", NULL
689 };
690 puCallback networkSubmenuCb     [] = {
691     /* notCb, notCb, notCb, notCb, */ 
692     net_unregister, 
693     net_register, 
694     net_fgd_scan, NewCallSign, 
695     net_display_toggle, NULL
696 };
697 #endif
698
699 char *helpSubmenu               [] = {
700     /* "About...", */ "Help", NULL
701 };
702 puCallback helpSubmenuCb        [] = {
703     /* notCb, */ helpCb, NULL
704 };
705
706
707 /* -------------------------------------------------------------------------
708 init the gui
709 _____________________________________________________________________*/
710
711
712 void guiInit()
713 {
714     char *mesa_win_state;
715
716     // Initialize PUI
717     puInit();
718     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
719     puSetDefaultColourScheme  (0.8, 0.8, 0.8, 0.4);
720
721     // Initialize our GLOBAL GUI STRINGS
722     gui_msg_OK     = msg_OK;     // "OK"
723     gui_msg_NO     = msg_NO;     // "NO"
724     gui_msg_YES    = msg_YES;    // "YES"
725     gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
726     gui_msg_RESET  = msg_RESET;  // "RESET"
727
728     // Next check home directory
729     FGPath fntpath;
730     char* envp = ::getenv( "FG_FONTS" );
731     if ( envp != NULL ) {
732         fntpath.set( envp );
733     } else {
734         fntpath.set( globals->get_fg_root() );
735         fntpath.append( "Fonts" );
736     }
737
738     // Install our fast fonts
739     fntpath.append( "typewriter.txf" );
740     guiFntHandle = new fntTexFont ;
741     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
742     puFont GuiFont ( guiFntHandle, 15 ) ;
743     puSetDefaultFonts( GuiFont, GuiFont ) ;
744     guiFnt = puGetDefaultLabelFont();
745   
746     if (!fgHasValue("/sim/startup/mouse-pointer")) {
747         // no preference specified for mouse pointer, attempt to autodetect...
748         // Determine if we need to render the cursor, or if the windowing
749         // system will do it.  First test if we are rendering with glide.
750         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
751             // Test for the MESA_GLX_FX env variable
752             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
753                 // test if we are fullscreen mesa/glide
754                 if ( (mesa_win_state[0] == 'f') ||
755                      (mesa_win_state[0] == 'F') ) {
756                     puShowCursor ();
757                 }
758             }
759         }
760 //        mouse_active = ~mouse_active;
761     } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
762         // don't show pointer
763     } else {
764         // force showing pointer
765         puShowCursor();
766 //        mouse_active = ~mouse_active;
767     }
768         
769     // MOUSE_VIEW mode stuff
770         initMouseQuat();
771
772     // Set up our Dialog Boxes
773     ConfirmExitDialogInit();
774     NewAirportInit();
775 #ifdef FG_NETWORK_OLK
776     NewNetIdInit();
777     NewNetFGDInit();
778 #endif
779
780         mkDialogInit();
781     
782     // Make the menu bar
783     mainMenuBar = new puMenuBar ();
784     mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
785     // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
786     mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
787     mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
788     mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
789     // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
790 #ifdef FG_NETWORK_OLK
791     if ( fgGetBool("/sim/networking/network-olk") ) {
792         mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
793     }
794 #endif
795     mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
796     mainMenuBar-> close ();
797     // Set up menu bar toggle
798     gui_menu_on = ~0;
799 }
800