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