1 /**************************************************************************
4 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
7 * Additional mouse supported added by David Megginson, 1999.
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.
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.
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.
24 **************************************************************************/
31 #include <simgear/compiler.h>
33 #ifdef SG_MATH_EXCEPTION_CLASH
44 #if defined(FX) && defined(XMESA)
45 # include <GL/xmesa.h>
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>
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/fg_init.hxx>
68 #include <Main/fg_io.hxx>
69 #include <Main/globals.hxx>
70 #include <Main/fg_props.hxx>
71 #include <Main/options.hxx>
74 #include <NetworkOLK/network.h>
77 #if defined( WIN32 ) && !defined( __CYGWIN__ )
78 # include <simgear/screen/win32-printer.h>
79 # include <simgear/screen/GlBitmaps.h>
83 #include "gui_local.hxx"
84 #include "apt_dlg.hxx"
85 #include "net_dlg.hxx"
86 #include "sgVec3Slider.hxx"
90 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
95 #define snprintf _snprintf
98 // main.cxx hack, should come from an include someplace
99 extern void fgInitVisuals( void );
100 extern void fgReshape( int width, int height );
101 extern void fgRenderFrame( void );
104 fntTexFont *guiFntHandle = 0;
106 static puMenuBar *mainMenuBar = 0;
107 //static puButton *hideMenuButton = 0;
109 static puDialogBox *dialogBox = 0;
110 static puFrame *dialogFrame = 0;
111 static puText *dialogBoxMessage = 0;
112 static puOneShot *dialogBoxOkButton = 0;
115 static puDialogBox *YNdialogBox = 0;
116 static puFrame *YNdialogFrame = 0;
117 static puText *YNdialogBoxMessage = 0;
118 static puOneShot *YNdialogBoxOkButton = 0;
119 static puOneShot *YNdialogBoxNoButton = 0;
121 static char msg_OK[] = "OK";
122 static char msg_NO[] = "NO";
123 static char msg_YES[] = "YES";
124 static char msg_CANCEL[] = "Cancel";
125 static char msg_RESET[] = "Reset";
127 char *gui_msg_OK; // "OK"
128 char *gui_msg_NO; // "NO"
129 char *gui_msg_YES; // "YES"
130 char *gui_msg_CANCEL; // "CANCEL"
131 char *gui_msg_RESET; // "RESET"
133 static char global_dialog_string[256];
136 extern void fgLatLonFormatToggle( puObject *);
139 /* ================ General Purpose Functions ================ */
141 // Intercept the Escape Key
142 void ConfirmExitDialog(void)
144 FG_PUSH_PUI_DIALOG( YNdialogBox );
147 // General Purpose Message Box
148 void mkDialog (const char *txt)
150 strncpy(global_dialog_string, txt, 256);
151 dialogBoxMessage->setLabel(global_dialog_string);
152 FG_PUSH_PUI_DIALOG( dialogBox );
155 // Toggle the Menu and Mouse display state
156 void guiToggleMenu(void)
159 // printf("Hiding Menu\n");
160 mainMenuBar->hide ();
161 #if defined(WIN32_CURSOR_TWEAKS)
162 if( mouse_mode == MOUSE_POINTER )
164 #endif // #ifdef WIN32_CURSOR_TWEAKS
166 // printf("Showing Menu\n");
167 mainMenuBar->reveal();
170 #endif // #ifdef WIN32
172 gui_menu_on = ~gui_menu_on;
175 /* -----------------------------------------------------------------------
176 the Gui callback functions
177 ____________________________________________________________________*/
180 // Hier Neu :-) This is my newly added code
181 // Added by David Findlay <nedz@bigpond.com>
182 // on Sunday 3rd of December
184 // Start new Save Dialog Box
185 static puDialogBox *SaveDialog = 0;
186 static puFrame *SaveDialogFrame = 0;
187 static puText *SaveDialogMessage = 0;
188 static puInput *SaveDialogInput = 0;
190 static puOneShot *SaveDialogOkButton = 0;
191 static puOneShot *SaveDialogCancelButton = 0;
192 // static puOneShot *SaveDialogResetButton = 0;
194 // Default save filename
195 static char saveFile[256] = "fgfs.sav";
198 void SaveDialogCancel(puObject *) {
199 FG_POP_PUI_DIALOG( SaveDialog );
202 // If press OK do this
203 void SaveDialogOk(puObject*) {
205 FG_POP_PUI_DIALOG( SaveDialog );
208 SaveDialogInput->getValue(&s);
211 cout << saveFile << endl;
212 if (output.good() && fgSaveFlight(output)) {
214 mkDialog("Saved flight");
215 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
217 mkDialog("Cannot save flight");
218 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
223 static void saveFlight(puObject *cv) {
224 SaveDialog = new puDialogBox (150, 50);
226 SaveDialogFrame = new puFrame (0,0,350, 150);
227 SaveDialogMessage = new puText (
228 (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
229 SaveDialogMessage -> setLabel ("File Name:");
231 SaveDialogInput = new puInput (50, 70, 300, 100);
232 SaveDialogInput -> setValue (saveFile);
233 SaveDialogInput -> acceptInput();
235 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
236 SaveDialogOkButton -> setLegend (gui_msg_OK);
237 SaveDialogOkButton -> setCallback ( SaveDialogOk );
238 SaveDialogOkButton -> makeReturnDefault(TRUE);
240 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
241 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
242 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
244 FG_FINALIZE_PUI_DIALOG( SaveDialog );
246 SaveDialog -> reveal();
250 static puDialogBox *LoadDialog = 0;
251 static puFrame *LoadDialogFrame = 0;
252 static puText *LoadDialogMessage = 0;
253 static puInput *LoadDialogInput = 0;
255 static puOneShot *LoadDialogOkButton = 0;
256 static puOneShot *LoadDialogCancelButton = 0;
257 // static puOneShot *LoadDialogResetButton = 0;
259 // Default load filename
260 static char loadFile[256] = "fgfs.sav";
262 // Do this if the person click okay
263 void LoadDialogOk(puObject *) {
265 FG_POP_PUI_DIALOG( LoadDialog );
268 LoadDialogInput->getValue(&l);
271 if (input.good() && fgLoadFlight(input)) {
273 mkDialog("Loaded flight");
274 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
276 mkDialog("Failed to load flight");
277 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
281 // Do this is the person presses cancel
282 void LoadDialogCancel(puObject *) {
283 FG_POP_PUI_DIALOG( LoadDialog );
286 // Create Load Dialog
287 static void loadFlight(puObject *cb)
289 LoadDialog = new puDialogBox (150, 50);
291 LoadDialogFrame = new puFrame (0,0,350, 150);
292 LoadDialogMessage = new puText (
293 (150 - puGetStringWidth( puGetDefaultLabelFont(), "File Name:" ) / 2), 110);
294 LoadDialogMessage -> setLabel ("File Name:");
296 LoadDialogInput = new puInput (50, 70, 300, 100);
297 LoadDialogInput -> setValue (loadFile);
298 LoadDialogInput -> acceptInput();
300 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
301 LoadDialogOkButton -> setLegend (gui_msg_OK);
302 LoadDialogOkButton -> setCallback ( LoadDialogOk );
303 LoadDialogOkButton -> makeReturnDefault(TRUE);
305 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
306 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
307 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
309 FG_FINALIZE_PUI_DIALOG( LoadDialog );
311 LoadDialog -> reveal();
314 // This is the accessor function
315 void guiTogglePanel(puObject *cb)
317 if (fgGetBool("/sim/panel/visibility"))
318 fgSetBool("/sim/panel/visibility", false);
320 fgSetBool("/sim/panel/visibility", true);
322 fgReshape(fgGetInt("/sim/startup/xsize"),
323 fgGetInt("/sim/startup/ysize"));
326 //void MenuHideMenuCb(puObject *cb)
327 void hideMenuCb (puObject *cb)
332 void goodBye(puObject *)
334 // SG_LOG( SG_INPUT, SG_ALERT,
335 // "Program exiting normally at user request." );
336 cout << "Program exiting normally at user request." << endl;
338 #ifdef FG_NETWORK_OLK
339 if ( fgGetBool("/sim/networking/network-olk") ) {
340 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
344 // close all external I/O connections
351 void goAwayCb (puObject *me)
353 FG_POP_PUI_DIALOG( dialogBox );
356 void mkDialogInit (void)
358 // printf("mkDialogInit\n");
359 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
360 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
361 dialogBox = new puDialogBox (x, y); // 150, 50
363 dialogFrame = new puFrame (0,0,400,100);
364 dialogBoxMessage = new puText (10, 70);
365 dialogBoxMessage -> setLabel ("");
366 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
367 dialogBoxOkButton -> setLegend (gui_msg_OK);
368 dialogBoxOkButton -> makeReturnDefault (TRUE );
369 dialogBoxOkButton -> setCallback (goAwayCb);
371 FG_FINALIZE_PUI_DIALOG( dialogBox );
374 void MayBeGoodBye(puObject *)
379 void goAwayYesNoCb(puObject *me)
381 FG_POP_PUI_DIALOG( YNdialogBox);
384 void ConfirmExitDialogInit(void)
386 char msg[] = "Really Quit";
389 // printf("ConfirmExitDialogInit\n");
390 int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
392 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
393 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
395 YNdialogBox = new puDialogBox (x, y); // 150, 50
396 // YNdialogBox = new puDialogBox (150, 50);
398 YNdialogFrame = new puFrame (0,0,400, 100);
400 YNdialogBoxMessage = new puText (len, 70);
401 YNdialogBoxMessage -> setDefaultValue (msg);
402 YNdialogBoxMessage -> getDefaultValue (&s);
403 YNdialogBoxMessage -> setLabel (s);
405 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
406 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
407 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
408 YNdialogBoxOkButton -> setCallback (goodBye);
410 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
411 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
412 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
414 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
417 void notCb (puObject *)
419 mkDialog ("This function isn't implemented yet");
422 void helpCb (puObject *)
426 #if defined(FX) && !defined(WIN32)
427 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
428 if ( global_fullscreen ) {
429 global_fullscreen = false;
430 XMesaSetFXmode( XMESA_FX_WINDOW );
435 SGPath path( globals->get_fg_root() );
436 path.append( "Docs/index.html" );
438 string help_app = fgGetString("/sim/startup/browser-app");
440 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
441 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
443 command = help_app + path.str();
449 system( command.c_str() );
450 mkDialog ("Help started in netscape window.");
453 #define TR_HIRES_SNAP
454 #if defined( TR_HIRES_SNAP)
455 #include <simgear/screen/tr.h>
456 extern void trRenderFrame( void );
457 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
458 GLfloat x_end, GLfloat y_end );
464 bool show_pu_cursor = false;
465 bool show_menu = false;
466 char *filename = new char [24];
467 static int count = 1;
469 int freeze = globals->get_freeze();
471 globals->set_freeze( true );
478 if ( !puCursorIsHidden() ) {
479 show_pu_cursor = true;
484 fgReshape( fgGetInt("/sim/startup/xsize"),
485 fgGetInt("/sim/startup/ysize") );
487 // we need two render frames here to clear the menu and cursor
488 // ... not sure why but doing an extra fgRenderFrame() shouldn't
493 // Make sure we have SSG projection primed for current view
494 glMatrixMode(GL_MODELVIEW);
496 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
497 float fov = globals->get_current_view()->get_fov();
498 ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
499 // ssgSetNearFar( 10.0f, 120000.0f );
500 ssgSetNearFar( 0.5f, 1200000.0f );
503 // This ImageSize stuff is a temporary hack
504 // should probably use 128x128 tile size and
505 // support any image size
507 // This should be a requester to get multiplier from user
509 int width = fgGetInt("/sim/startup/xsize");
510 int height = fgGetInt("/sim/startup/ysize");
512 /* allocate buffer large enough to store one tile */
513 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
515 printf("Malloc of tile buffer failed!\n");
519 int imageWidth = multiplier*width;
520 int imageHeight = multiplier*height;
522 /* allocate buffer to hold a row of tiles */
524 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
527 printf("Malloc of tile row buffer failed!\n");
530 TRcontext *tr = trNew();
531 trTileSize(tr, width, height, 0);
532 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
533 trImageSize(tr, imageWidth, imageHeight);
534 trRowOrder(tr, TR_TOP_TO_BOTTOM);
535 sgFrustum *frustum = ssgGetFrustum();
537 frustum->getLeft(), frustum->getRight(),
538 frustum->getBot(), frustum->getTop(),
539 frustum->getNear(), frustum->getFar());
541 /* Prepare ppm output file */
542 while (count < 1000) {
543 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
544 if ( (f = fopen(filename, "r")) == NULL )
548 f = fopen(filename, "wb");
550 printf("Couldn't open image file: %s\n", filename);
556 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
557 fprintf(f,"%i %i\n", imageWidth, imageHeight);
560 /* just to be safe... */
561 glPixelStorei(GL_PACK_ALIGNMENT, 1);
563 /* Because the HUD and Panel change the ViewPort we will
564 * need to handle some lowlevel stuff ourselves */
565 int ncols = trGet(tr, TR_COLUMNS);
566 int nrows = trGet(tr, TR_ROWS);
568 bool do_hud = fgGetBool("/sim/hud/visibility");
569 GLfloat hud_col_step = 640.0 / ncols;
570 GLfloat hud_row_step = 480.0 / nrows;
572 bool do_panel = fgPanelVisible();
573 GLfloat panel_col_step = current_panel->getWidth() / ncols;
574 GLfloat panel_row_step = current_panel->getHeight() / nrows;
580 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
581 int curRow = trGet(tr, TR_CURRENT_ROW);
584 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
585 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
587 current_panel->update( curColumn*panel_col_step, panel_col_step,
588 curRow*panel_row_step, panel_row_step );
589 more = trEndTile(tr);
591 /* save tile into tile row buffer*/
592 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
593 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
594 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
595 int xOffset = curColumn * bytesPerTileRow;
596 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
598 for (i=0;i<height;i++) {
599 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
600 tile + i*bytesPerTileRow, /* Src */
601 bytesPerCurrentTileRow); /* Byte count*/
604 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
605 /* write this buffered row of tiles to the file */
606 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
607 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
609 for (i=0;i<curTileHeight;i++) {
610 /* Remember, OpenGL images are bottom to top. Have to reverse. */
611 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
612 fwrite(rowPtr, 1, imageWidth*3, f);
618 fgReshape( width, height );
624 message = "Snap shot saved to ";
626 mkDialog (message.c_str());
631 // message = "Snap shot saved to ";
632 // message += filename;
633 // mkDialog (message.c_str());
640 if ( show_pu_cursor ) {
645 globals->set_freeze( false );
647 #endif // #if defined( TR_HIRES_SNAP)
650 #if defined( WIN32 ) && !defined( __CYGWIN__)
652 static void rotateView( double roll, double pitch, double yaw )
657 static GlBitmap *b1 = NULL;
658 extern FGInterface cur_view_fdm;
659 GLubyte *hiResScreenCapture( int multiplier )
661 float oldfov = fgGetDouble("/sim/field-of-view");
662 float fov = oldfov / multiplier;
663 FGViewer *v = globals->get_current_view();
664 fgSetDouble("/sim/field-of-view", fov);
666 int cur_width = fgGetInt("/sim/startup/xsize");
667 int cur_height = fgGetInt("/sim/startup/ysize");
668 if (b1) delete( b1 );
669 // New empty (mostly) bitmap
670 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
672 for ( y = 0; y < multiplier; y++ ) {
673 for ( x = 0; x < multiplier; x++ ) {
674 fgReshape( cur_width, cur_height );
676 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
680 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
683 fgSetDouble("/sim/field-of-view", oldfov);
684 return b1->getBitmap();
689 #if defined( WIN32 ) && !defined( __CYGWIN__)
690 // win32 print screen function
691 void printScreen ( puObject *obj ) {
692 bool show_pu_cursor = false;
694 if ( !puCursorIsHidden() ) {
695 show_pu_cursor = true;
701 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
702 int cur_width = fgGetInt("/sim/startup/xsize");
703 int cur_height = fgGetInt("/sim/startup/ysize");
704 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
705 p.End( hiResScreenCapture(3) );
708 mainMenuBar->reveal();
711 if ( show_pu_cursor ) {
716 #endif // #ifdef WIN32
719 void dumpSnapShot ( puObject *obj ) {
724 void dumpHiResSnapShot ( puObject *obj ) {
729 // do a screen snap shot
730 void fgDumpSnapShot () {
731 bool show_pu_cursor = false;
732 char *filename = new char [24];
734 static int count = 1;
736 int freeze = globals->get_freeze();
738 globals->set_freeze( true );
742 if ( !puCursorIsHidden() ) {
743 show_pu_cursor = true;
748 fgReshape( fgGetInt("/sim/startup/xsize"),
749 fgGetInt("/sim/startup/ysize") );
751 // we need two render frames here to clear the menu and cursor
752 // ... not sure why but doing an extra fgRenderFrame() shouldn't
757 while (count < 1000) {
759 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
760 if ( (fp = fopen(filename, "r")) == NULL )
765 if ( sg_glDumpWindow( filename,
766 fgGetInt("/sim/startup/xsize"),
767 fgGetInt("/sim/startup/ysize")) ) {
768 message = "Snap shot saved to ";
771 message = "Failed to save to ";
775 mkDialog (message.c_str());
779 if ( show_pu_cursor ) {
785 mainMenuBar->reveal();
789 globals->set_freeze( false );
792 #ifdef FG_NETWORK_OLK
793 static void net_display_toggle( puObject *cb)
795 net_hud_display = (net_hud_display) ? 0 : 1;
796 printf("Toggle net_hud_display : %d\n", net_hud_display);
799 static void net_register( puObject *cb)
801 fgd_send_com( "1", FGFS_host );
802 net_is_registered = 0;
803 printf("Registering to deamon\n");
806 static void net_unregister( puObject *cb)
808 fgd_send_com( "8", FGFS_host );
809 net_is_registered = -1;
810 printf("Unregistering from deamon\n");
813 extern void net_fgd_scan(puObject *cb);
814 #endif // #ifdef FG_NETWORK_OLK
816 /* -----------------------------------------------------------------------
818 ---------------------------------------------------------------------*/
819 char *fileSubmenu [] = {
820 "Exit", /* "Close", "---------", */
821 #if defined( WIN32 ) && !defined( __CYGWIN__)
832 puCallback fileSubmenuCb [] = {
833 MayBeGoodBye, /* hideMenuCb, NULL, */
834 #if defined( WIN32 ) && !defined( __CYGWIN__)
848 char *editSubmenu [] = {
851 puCallback editSubmenuCb [] = {
856 extern void fgHUDalphaAdjust( puObject * );
857 char *viewSubmenu [] = {
860 /* "Cockpit View > ", "View >","------------", */
861 "Toggle Panel...", NULL
863 puCallback viewSubmenuCb [] = {
866 /* notCb, notCb, NULL, */
872 char *autopilotSubmenu [] = {
873 "Toggle HUD Format", "Adjust AP Settings",
875 "Clear Route", "Skip Current Waypoint", "Add Waypoint",
877 "Set Altitude", "Set Heading",
881 puCallback autopilotSubmenuCb [] = {
882 fgLatLonFormatToggle, fgAPAdjust,
884 ClearRoute, PopWayPoint, AddWayPoint,
886 NewAltitude, NewHeading,
890 char *environmentSubmenu [] = {
891 "Goto Airport", /* "Terrain", "Weather", */ NULL
893 puCallback environmentSubmenuCb [] = {
894 NewAirport, /* notCb, notCb, */ NULL
898 char *optionsSubmenu [] = {
899 "Preferences", "Realism & Reliablity...", NULL
901 puCallback optionsSubmenuCb [] = {
906 #ifdef FG_NETWORK_OLK
907 char *networkSubmenu [] = {
908 "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
910 "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
911 "Toggle Display", NULL
913 puCallback networkSubmenuCb [] = {
914 /* notCb, notCb, notCb, notCb, */
917 net_fgd_scan, NewCallSign,
918 net_display_toggle, NULL
922 char *helpSubmenu [] = {
923 /* "About...", */ "Help", NULL
925 puCallback helpSubmenuCb [] = {
926 /* notCb, */ helpCb, NULL
930 /* -------------------------------------------------------------------------
932 _____________________________________________________________________*/
937 char *mesa_win_state;
941 puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
942 puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
944 // Initialize our GLOBAL GUI STRINGS
945 gui_msg_OK = msg_OK; // "OK"
946 gui_msg_NO = msg_NO; // "NO"
947 gui_msg_YES = msg_YES; // "YES"
948 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
949 gui_msg_RESET = msg_RESET; // "RESET"
951 // Next check home directory
953 char* envp = ::getenv( "FG_FONTS" );
954 if ( envp != NULL ) {
957 fntpath.set( globals->get_fg_root() );
958 fntpath.append( "Fonts" );
961 // Install our fast fonts
962 fntpath.append( "typewriter.txf" );
963 guiFntHandle = new fntTexFont ;
964 guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
965 puFont GuiFont ( guiFntHandle, 15 ) ;
966 puSetDefaultFonts( GuiFont, GuiFont ) ;
967 guiFnt = puGetDefaultLabelFont();
969 if (!fgHasNode("/sim/startup/mouse-pointer")) {
970 // no preference specified for mouse pointer, attempt to autodetect...
971 // Determine if we need to render the cursor, or if the windowing
972 // system will do it. First test if we are rendering with glide.
973 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
974 // Test for the MESA_GLX_FX env variable
975 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
976 // test if we are fullscreen mesa/glide
977 if ( (mesa_win_state[0] == 'f') ||
978 (mesa_win_state[0] == 'F') ) {
983 // mouse_active = ~mouse_active;
984 } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
985 // don't show pointer
987 // force showing pointer
989 // mouse_active = ~mouse_active;
992 // MOUSE_VIEW mode stuff
995 // Set up our Dialog Boxes
996 ConfirmExitDialogInit();
998 #ifdef FG_NETWORK_OLK
1005 // Make the menu bar
1006 mainMenuBar = new puMenuBar ();
1007 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
1008 // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
1009 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
1010 mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
1011 mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
1012 // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
1013 #ifdef FG_NETWORK_OLK
1014 if ( fgGetBool("/sim/networking/network-olk") ) {
1015 mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
1018 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
1019 mainMenuBar-> close ();
1020 // Set up menu bar toggle