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>
72 #include <Main/viewmgr.hxx>
75 #include <NetworkOLK/network.h>
78 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
79 # include <simgear/screen/win32-printer.h>
80 # include <simgear/screen/GlBitmaps.h>
84 #include "gui_local.hxx"
85 #include "apt_dlg.hxx"
86 #include "net_dlg.hxx"
87 #include "sgVec3Slider.hxx"
91 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
95 #if defined(_MSC_VER) || defined(__MINGW32__)
96 #define snprintf _snprintf
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 );
105 fntTexFont *guiFntHandle = 0;
107 static puMenuBar *mainMenuBar = 0;
108 //static puButton *hideMenuButton = 0;
110 static puDialogBox *dialogBox = 0;
111 static puFrame *dialogFrame = 0;
112 static puText *dialogBoxMessage = 0;
113 static puOneShot *dialogBoxOkButton = 0;
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;
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";
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"
134 static char global_dialog_string[256];
137 extern void fgLatLonFormatToggle( puObject *);
140 /* ================ General Purpose Functions ================ */
142 // Intercept the Escape Key
143 void ConfirmExitDialog(void)
145 FG_PUSH_PUI_DIALOG( YNdialogBox );
148 // General Purpose Message Box
149 void mkDialog (const char *txt)
151 strncpy(global_dialog_string, txt, 256);
152 dialogBoxMessage->setLabel(global_dialog_string);
153 FG_PUSH_PUI_DIALOG( dialogBox );
156 // Message Box to report an error.
157 void guiErrorMessage (const char *txt)
159 SG_LOG(SG_GENERAL, SG_ALERT, txt);
164 // Message Box to report a throwable (usually an exception).
165 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
169 msg += throwable.getFormattedMessage();
170 if (throwable.getOrigin() != (string)"") {
171 msg += "\n (reported by ";
172 msg += throwable.getOrigin();
175 SG_LOG(SG_GENERAL, SG_ALERT, msg);
177 mkDialog(msg.c_str());
180 // Toggle the Menu and Mouse display state
181 void guiToggleMenu(void)
184 // printf("Hiding Menu\n");
185 mainMenuBar->hide ();
186 #if defined(WIN32_CURSOR_TWEAKS)
187 if( mouse_mode == MOUSE_POINTER )
189 #endif // #ifdef WIN32_CURSOR_TWEAKS
191 // printf("Showing Menu\n");
192 mainMenuBar->reveal();
195 #endif // #ifdef WIN32
197 gui_menu_on = ~gui_menu_on;
200 /* -----------------------------------------------------------------------
201 the Gui callback functions
202 ____________________________________________________________________*/
205 // Hier Neu :-) This is my newly added code
206 // Added by David Findlay <nedz@bigpond.com>
207 // on Sunday 3rd of December
209 // Start new Save Dialog Box
210 static puDialogBox *SaveDialog = 0;
211 static puFrame *SaveDialogFrame = 0;
212 static puText *SaveDialogMessage = 0;
213 static puInput *SaveDialogInput = 0;
215 static puOneShot *SaveDialogOkButton = 0;
216 static puOneShot *SaveDialogCancelButton = 0;
217 // static puOneShot *SaveDialogResetButton = 0;
219 // Default save filename
220 static char saveFile[256] = "fgfs.sav";
223 void SaveDialogCancel(puObject *) {
224 FG_POP_PUI_DIALOG( SaveDialog );
227 // If press OK do this
228 void SaveDialogOk(puObject*) {
230 FG_POP_PUI_DIALOG( SaveDialog );
233 SaveDialogInput->getValue(&s);
236 cout << saveFile << endl;
237 if (output.good() && fgSaveFlight(output)) {
239 mkDialog("Saved flight");
240 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
242 mkDialog("Cannot save flight");
243 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
248 static void saveFlight(puObject *cv) {
249 SaveDialog = new puDialogBox (150, 50);
251 SaveDialogFrame = new puFrame (0,0,350, 150);
253 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
254 SaveDialogMessage -> setLabel ("File Name:");
256 SaveDialogInput = new puInput (50, 70, 300, 100);
257 SaveDialogInput -> setValue (saveFile);
258 SaveDialogInput -> acceptInput();
260 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
261 SaveDialogOkButton -> setLegend (gui_msg_OK);
262 SaveDialogOkButton -> setCallback ( SaveDialogOk );
263 SaveDialogOkButton -> makeReturnDefault(TRUE);
265 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
266 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
267 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
269 FG_FINALIZE_PUI_DIALOG( SaveDialog );
271 SaveDialog -> reveal();
275 static puDialogBox *LoadDialog = 0;
276 static puFrame *LoadDialogFrame = 0;
277 static puText *LoadDialogMessage = 0;
278 static puInput *LoadDialogInput = 0;
280 static puOneShot *LoadDialogOkButton = 0;
281 static puOneShot *LoadDialogCancelButton = 0;
282 // static puOneShot *LoadDialogResetButton = 0;
284 // Default load filename
285 static char loadFile[256] = "fgfs.sav";
287 // Do this if the person click okay
288 void LoadDialogOk(puObject *) {
290 FG_POP_PUI_DIALOG( LoadDialog );
293 LoadDialogInput->getValue(&l);
296 if (input.good() && fgLoadFlight(input)) {
298 mkDialog("Loaded flight");
299 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
301 mkDialog("Failed to load flight");
302 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
306 // Do this is the person presses cancel
307 void LoadDialogCancel(puObject *) {
308 FG_POP_PUI_DIALOG( LoadDialog );
311 // Create Load Dialog
312 static void loadFlight(puObject *cb)
314 LoadDialog = new puDialogBox (150, 50);
316 LoadDialogFrame = new puFrame (0,0,350, 150);
318 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
319 LoadDialogMessage -> setLabel ("File Name:");
321 LoadDialogInput = new puInput (50, 70, 300, 100);
322 LoadDialogInput -> setValue (loadFile);
323 LoadDialogInput -> acceptInput();
325 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
326 LoadDialogOkButton -> setLegend (gui_msg_OK);
327 LoadDialogOkButton -> setCallback ( LoadDialogOk );
328 LoadDialogOkButton -> makeReturnDefault(TRUE);
330 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
331 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
332 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
334 FG_FINALIZE_PUI_DIALOG( LoadDialog );
336 LoadDialog -> reveal();
339 // This is the accessor function
340 void guiTogglePanel(puObject *cb)
342 if (fgGetBool("/sim/panel/visibility"))
343 fgSetBool("/sim/panel/visibility", false);
345 fgSetBool("/sim/panel/visibility", true);
347 fgReshape(fgGetInt("/sim/startup/xsize"),
348 fgGetInt("/sim/startup/ysize"));
351 //void MenuHideMenuCb(puObject *cb)
352 void hideMenuCb (puObject *cb)
357 void goodBye(puObject *)
359 // SG_LOG( SG_INPUT, SG_ALERT,
360 // "Program exiting normally at user request." );
361 cout << "Program exiting normally at user request." << endl;
363 #ifdef FG_NETWORK_OLK
364 if ( fgGetBool("/sim/networking/network-olk") ) {
365 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
369 // close all external I/O connections
376 void goAwayCb (puObject *me)
378 FG_POP_PUI_DIALOG( dialogBox );
381 void mkDialogInit (void)
383 // printf("mkDialogInit\n");
384 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
385 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
386 dialogBox = new puDialogBox (x, y); // 150, 50
388 dialogFrame = new puFrame (0,0,400,100);
389 dialogBoxMessage = new puText (10, 70);
390 dialogBoxMessage -> setLabel ("");
391 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
392 dialogBoxOkButton -> setLegend (gui_msg_OK);
393 dialogBoxOkButton -> makeReturnDefault (TRUE );
394 dialogBoxOkButton -> setCallback (goAwayCb);
396 FG_FINALIZE_PUI_DIALOG( dialogBox );
399 void MayBeGoodBye(puObject *)
404 void goAwayYesNoCb(puObject *me)
406 FG_POP_PUI_DIALOG( YNdialogBox);
409 void ConfirmExitDialogInit(void)
411 char msg[] = "Really Quit";
414 // printf("ConfirmExitDialogInit\n");
415 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
417 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
418 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
420 YNdialogBox = new puDialogBox (x, y); // 150, 50
421 // YNdialogBox = new puDialogBox (150, 50);
423 YNdialogFrame = new puFrame (0,0,400, 100);
425 YNdialogBoxMessage = new puText (len, 70);
426 YNdialogBoxMessage -> setDefaultValue (msg);
427 YNdialogBoxMessage -> getDefaultValue (&s);
428 YNdialogBoxMessage -> setLabel (s);
430 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
431 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
432 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
433 YNdialogBoxOkButton -> setCallback (goodBye);
435 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
436 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
437 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
439 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
442 void notCb (puObject *)
444 mkDialog ("This function isn't implemented yet");
447 void helpCb (puObject *)
451 #if defined(FX) && !defined(WIN32)
452 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
453 if ( global_fullscreen ) {
454 global_fullscreen = false;
455 XMesaSetFXmode( XMESA_FX_WINDOW );
460 SGPath path( globals->get_fg_root() );
461 path.append( "Docs/index.html" );
463 string help_app = fgGetString("/sim/startup/browser-app");
465 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
466 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
468 command = help_app + " " + path.str();
474 system( command.c_str() );
475 mkDialog ("Help started in netscape window.");
478 #define TR_HIRES_SNAP
479 #if defined( TR_HIRES_SNAP)
480 #include <simgear/screen/tr.h>
481 extern void trRenderFrame( void );
482 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
483 GLfloat x_end, GLfloat y_end );
489 bool show_pu_cursor = false;
490 bool show_menu = false;
491 char *filename = new char [24];
492 static int count = 1;
494 int freeze = globals->get_freeze();
496 globals->set_freeze( true );
503 if ( !puCursorIsHidden() ) {
504 show_pu_cursor = true;
509 fgReshape( fgGetInt("/sim/startup/xsize"),
510 fgGetInt("/sim/startup/ysize") );
512 // we need two render frames here to clear the menu and cursor
513 // ... not sure why but doing an extra fgRenderFrame() shouldn't
518 // Make sure we have SSG projection primed for current view
519 glMatrixMode(GL_MODELVIEW);
521 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
522 float fov = globals->get_current_view()->get_fov();
523 ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
524 // ssgSetNearFar( 10.0f, 120000.0f );
525 ssgSetNearFar( 0.5f, 1200000.0f );
528 // This ImageSize stuff is a temporary hack
529 // should probably use 128x128 tile size and
530 // support any image size
532 // This should be a requester to get multiplier from user
534 int width = fgGetInt("/sim/startup/xsize");
535 int height = fgGetInt("/sim/startup/ysize");
537 /* allocate buffer large enough to store one tile */
538 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
540 printf("Malloc of tile buffer failed!\n");
544 int imageWidth = multiplier*width;
545 int imageHeight = multiplier*height;
547 /* allocate buffer to hold a row of tiles */
549 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
552 printf("Malloc of tile row buffer failed!\n");
555 TRcontext *tr = trNew();
556 trTileSize(tr, width, height, 0);
557 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
558 trImageSize(tr, imageWidth, imageHeight);
559 trRowOrder(tr, TR_TOP_TO_BOTTOM);
560 sgFrustum *frustum = ssgGetFrustum();
562 frustum->getLeft(), frustum->getRight(),
563 frustum->getBot(), frustum->getTop(),
564 frustum->getNear(), frustum->getFar());
566 /* Prepare ppm output file */
567 while (count < 1000) {
568 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
569 if ( (f = fopen(filename, "r")) == NULL )
573 f = fopen(filename, "wb");
575 printf("Couldn't open image file: %s\n", filename);
581 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
582 fprintf(f,"%i %i\n", imageWidth, imageHeight);
585 /* just to be safe... */
586 glPixelStorei(GL_PACK_ALIGNMENT, 1);
588 /* Because the HUD and Panel change the ViewPort we will
589 * need to handle some lowlevel stuff ourselves */
590 int ncols = trGet(tr, TR_COLUMNS);
591 int nrows = trGet(tr, TR_ROWS);
593 bool do_hud = fgGetBool("/sim/hud/visibility");
594 GLfloat hud_col_step = 640.0 / ncols;
595 GLfloat hud_row_step = 480.0 / nrows;
597 bool do_panel = fgPanelVisible();
598 GLfloat panel_col_step = current_panel->getWidth() / ncols;
599 GLfloat panel_row_step = current_panel->getHeight() / nrows;
605 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
606 int curRow = trGet(tr, TR_CURRENT_ROW);
609 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
610 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
612 current_panel->update( curColumn*panel_col_step, panel_col_step,
613 curRow*panel_row_step, panel_row_step );
614 more = trEndTile(tr);
616 /* save tile into tile row buffer*/
617 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
618 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
619 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
620 int xOffset = curColumn * bytesPerTileRow;
621 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
623 for (i=0;i<height;i++) {
624 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
625 tile + i*bytesPerTileRow, /* Src */
626 bytesPerCurrentTileRow); /* Byte count*/
629 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
630 /* write this buffered row of tiles to the file */
631 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
632 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
634 for (i=0;i<curTileHeight;i++) {
635 /* Remember, OpenGL images are bottom to top. Have to reverse. */
636 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
637 fwrite(rowPtr, 1, imageWidth*3, f);
643 fgReshape( width, height );
649 message = "Snap shot saved to ";
651 mkDialog (message.c_str());
656 // message = "Snap shot saved to ";
657 // message += filename;
658 // mkDialog (message.c_str());
665 if ( show_pu_cursor ) {
670 globals->set_freeze( false );
672 #endif // #if defined( TR_HIRES_SNAP)
675 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
677 static void rotateView( double roll, double pitch, double yaw )
682 static GlBitmap *b1 = NULL;
683 extern FGInterface cur_view_fdm;
684 GLubyte *hiResScreenCapture( int multiplier )
686 float oldfov = fgGetDouble("/sim/field-of-view");
687 float fov = oldfov / multiplier;
688 FGViewer *v = globals->get_current_view();
689 fgSetDouble("/sim/field-of-view", fov);
691 int cur_width = fgGetInt("/sim/startup/xsize");
692 int cur_height = fgGetInt("/sim/startup/ysize");
693 if (b1) delete( b1 );
694 // New empty (mostly) bitmap
695 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
697 for ( y = 0; y < multiplier; y++ ) {
698 for ( x = 0; x < multiplier; x++ ) {
699 fgReshape( cur_width, cur_height );
701 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
705 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
708 fgSetDouble("/sim/field-of-view", oldfov);
709 return b1->getBitmap();
714 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
715 // win32 print screen function
716 void printScreen ( puObject *obj ) {
717 bool show_pu_cursor = false;
719 if ( !puCursorIsHidden() ) {
720 show_pu_cursor = true;
726 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
727 int cur_width = fgGetInt("/sim/startup/xsize");
728 int cur_height = fgGetInt("/sim/startup/ysize");
729 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
730 p.End( hiResScreenCapture(3) );
733 mainMenuBar->reveal();
736 if ( show_pu_cursor ) {
741 #endif // #ifdef WIN32
744 void dumpSnapShot ( puObject *obj ) {
749 void dumpHiResSnapShot ( puObject *obj ) {
754 // do a screen snap shot
755 void fgDumpSnapShot () {
756 bool show_pu_cursor = false;
757 char *filename = new char [24];
759 static int count = 1;
761 int freeze = globals->get_freeze();
763 globals->set_freeze( true );
767 if ( !puCursorIsHidden() ) {
768 show_pu_cursor = true;
773 fgReshape( fgGetInt("/sim/startup/xsize"),
774 fgGetInt("/sim/startup/ysize") );
776 // we need two render frames here to clear the menu and cursor
777 // ... not sure why but doing an extra fgRenderFrame() shouldn't
782 while (count < 1000) {
784 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
785 if ( (fp = fopen(filename, "r")) == NULL )
790 if ( sg_glDumpWindow( filename,
791 fgGetInt("/sim/startup/xsize"),
792 fgGetInt("/sim/startup/ysize")) ) {
793 message = "Snap shot saved to ";
796 message = "Failed to save to ";
800 mkDialog (message.c_str());
804 if ( show_pu_cursor ) {
810 mainMenuBar->reveal();
814 globals->set_freeze( false );
817 #ifdef FG_NETWORK_OLK
818 static void net_display_toggle( puObject *cb)
820 net_hud_display = (net_hud_display) ? 0 : 1;
821 printf("Toggle net_hud_display : %d\n", net_hud_display);
824 static void net_register( puObject *cb)
826 fgd_send_com( "1", FGFS_host );
827 net_is_registered = 0;
828 printf("Registering to deamon\n");
831 static void net_unregister( puObject *cb)
833 fgd_send_com( "8", FGFS_host );
834 net_is_registered = -1;
835 printf("Unregistering from deamon\n");
838 extern void net_fgd_scan(puObject *cb);
839 #endif // #ifdef FG_NETWORK_OLK
841 /* -----------------------------------------------------------------------
843 ---------------------------------------------------------------------*/
844 char *fileSubmenu [] = {
845 "Exit", /* "Close", "---------", */
846 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
857 puCallback fileSubmenuCb [] = {
858 MayBeGoodBye, /* hideMenuCb, NULL, */
859 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
873 char *editSubmenu [] = {
876 puCallback editSubmenuCb [] = {
881 extern void fgHUDalphaAdjust( puObject * );
882 char *viewSubmenu [] = {
885 /* "Cockpit View > ", "View >","------------", */
886 "Toggle Panel...", NULL
888 puCallback viewSubmenuCb [] = {
891 /* notCb, notCb, NULL, */
897 char *autopilotSubmenu [] = {
898 "Toggle HUD Format", "Adjust AP Settings",
900 "Clear Route", "Skip Current Waypoint", "Add Waypoint",
902 "Set Altitude", "Set Heading",
906 puCallback autopilotSubmenuCb [] = {
907 fgLatLonFormatToggle, fgAPAdjust,
909 ClearRoute, PopWayPoint, AddWayPoint,
911 NewAltitude, NewHeading,
915 char *environmentSubmenu [] = {
916 "Goto Airport", /* "Terrain", "Weather", */ NULL
918 puCallback environmentSubmenuCb [] = {
919 NewAirport, /* notCb, notCb, */ NULL
923 char *optionsSubmenu [] = {
924 "Preferences", "Realism & Reliablity...", NULL
926 puCallback optionsSubmenuCb [] = {
931 #ifdef FG_NETWORK_OLK
932 char *networkSubmenu [] = {
933 "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
935 "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
936 "Toggle Display", NULL
938 puCallback networkSubmenuCb [] = {
939 /* notCb, notCb, notCb, notCb, */
942 net_fgd_scan, NewCallSign,
943 net_display_toggle, NULL
947 char *helpSubmenu [] = {
948 /* "About...", */ "Help", NULL
950 puCallback helpSubmenuCb [] = {
951 /* notCb, */ helpCb, NULL
955 /* -------------------------------------------------------------------------
957 _____________________________________________________________________*/
962 char *mesa_win_state;
966 puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
967 puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
969 // Initialize our GLOBAL GUI STRINGS
970 gui_msg_OK = msg_OK; // "OK"
971 gui_msg_NO = msg_NO; // "NO"
972 gui_msg_YES = msg_YES; // "YES"
973 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
974 gui_msg_RESET = msg_RESET; // "RESET"
976 // Next check home directory
978 char* envp = ::getenv( "FG_FONTS" );
979 if ( envp != NULL ) {
982 fntpath.set( globals->get_fg_root() );
983 fntpath.append( "Fonts" );
986 // Install our fast fonts
987 fntpath.append( "typewriter.txf" );
988 guiFntHandle = new fntTexFont ;
989 guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
990 puFont GuiFont ( guiFntHandle, 15 ) ;
991 puSetDefaultFonts( GuiFont, GuiFont ) ;
992 guiFnt = puGetDefaultLabelFont();
994 if (!fgHasNode("/sim/startup/mouse-pointer")) {
995 // no preference specified for mouse pointer, attempt to autodetect...
996 // Determine if we need to render the cursor, or if the windowing
997 // system will do it. First test if we are rendering with glide.
998 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
999 // Test for the MESA_GLX_FX env variable
1000 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
1001 // test if we are fullscreen mesa/glide
1002 if ( (mesa_win_state[0] == 'f') ||
1003 (mesa_win_state[0] == 'F') ) {
1008 // mouse_active = ~mouse_active;
1009 } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
1010 // don't show pointer
1012 // force showing pointer
1014 // mouse_active = ~mouse_active;
1017 // MOUSE_VIEW mode stuff
1020 // Set up our Dialog Boxes
1021 ConfirmExitDialogInit();
1023 #ifdef FG_NETWORK_OLK
1030 // Make the menu bar
1031 mainMenuBar = new puMenuBar ();
1032 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
1033 // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
1034 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
1035 mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
1036 mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
1037 // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
1038 #ifdef FG_NETWORK_OLK
1039 if ( fgGetBool("/sim/networking/network-olk") ) {
1040 mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
1043 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
1044 mainMenuBar-> close ();
1045 // Set up menu bar toggle
1048 if (fgGetString("/sim/flight-model") == "ada") {
1049 guiToggleMenu(); // Menu off by default