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"
88 #include "prop_picker.hxx"
92 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
96 #if defined(_MSC_VER) || defined(__MINGW32__)
97 #define snprintf _snprintf
100 // main.cxx hack, should come from an include someplace
101 extern void fgInitVisuals( void );
102 extern void fgReshape( int width, int height );
103 extern void fgRenderFrame( void );
106 fntTexFont *guiFntHandle = 0;
108 static puMenuBar *mainMenuBar = 0;
109 //static puButton *hideMenuButton = 0;
111 static puDialogBox *dialogBox = 0;
112 static puFrame *dialogFrame = 0;
113 static puText *dialogBoxMessage = 0;
114 static puOneShot *dialogBoxOkButton = 0;
117 static puDialogBox *YNdialogBox = 0;
118 static puFrame *YNdialogFrame = 0;
119 static puText *YNdialogBoxMessage = 0;
120 static puOneShot *YNdialogBoxOkButton = 0;
121 static puOneShot *YNdialogBoxNoButton = 0;
123 static char msg_OK[] = "OK";
124 static char msg_NO[] = "NO";
125 static char msg_YES[] = "YES";
126 static char msg_CANCEL[] = "Cancel";
127 static char msg_RESET[] = "Reset";
129 char *gui_msg_OK; // "OK"
130 char *gui_msg_NO; // "NO"
131 char *gui_msg_YES; // "YES"
132 char *gui_msg_CANCEL; // "CANCEL"
133 char *gui_msg_RESET; // "RESET"
135 static char global_dialog_string[256];
138 extern void fgLatLonFormatToggle( puObject *);
141 /* ================ General Purpose Functions ================ */
143 // Intercept the Escape Key
144 void ConfirmExitDialog(void)
146 FG_PUSH_PUI_DIALOG( YNdialogBox );
149 // General Purpose Message Box
150 void mkDialog (const char *txt)
152 strncpy(global_dialog_string, txt, 256);
153 dialogBoxMessage->setLabel(global_dialog_string);
154 FG_PUSH_PUI_DIALOG( dialogBox );
157 // Message Box to report an error.
158 void guiErrorMessage (const char *txt)
160 SG_LOG(SG_GENERAL, SG_ALERT, txt);
165 // Message Box to report a throwable (usually an exception).
166 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
170 msg += throwable.getFormattedMessage();
171 if (throwable.getOrigin() != (string)"") {
172 msg += "\n (reported by ";
173 msg += throwable.getOrigin();
176 SG_LOG(SG_GENERAL, SG_ALERT, msg);
178 mkDialog(msg.c_str());
181 // Toggle the Menu and Mouse display state
182 void guiToggleMenu(void)
185 // printf("Hiding Menu\n");
186 mainMenuBar->hide ();
187 #if defined(WIN32_CURSOR_TWEAKS_OFF)
188 if( mouse_mode == MOUSE_POINTER )
190 #endif // WIN32_CURSOR_TWEAKS_OFF
192 // printf("Showing Menu\n");
193 mainMenuBar->reveal();
198 gui_menu_on = ~gui_menu_on;
201 /* -----------------------------------------------------------------------
202 the Gui callback functions
203 ____________________________________________________________________*/
206 // Hier Neu :-) This is my newly added code
207 // Added by David Findlay <nedz@bigpond.com>
208 // on Sunday 3rd of December
210 // Start new Save Dialog Box
211 static puDialogBox *SaveDialog = 0;
212 static puFrame *SaveDialogFrame = 0;
213 static puText *SaveDialogMessage = 0;
214 static puInput *SaveDialogInput = 0;
216 static puOneShot *SaveDialogOkButton = 0;
217 static puOneShot *SaveDialogCancelButton = 0;
218 // static puOneShot *SaveDialogResetButton = 0;
220 // Default save filename
221 static char saveFile[256] = "fgfs.sav";
224 void SaveDialogCancel(puObject *) {
225 FG_POP_PUI_DIALOG( SaveDialog );
228 // If press OK do this
229 void SaveDialogOk(puObject*) {
231 FG_POP_PUI_DIALOG( SaveDialog );
234 SaveDialogInput->getValue(&s);
237 cout << saveFile << endl;
238 if (output.good() && fgSaveFlight(output)) {
240 mkDialog("Saved flight");
241 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
243 mkDialog("Cannot save flight");
244 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
249 static void saveFlight(puObject *cv) {
250 SaveDialog = new puDialogBox (150, 50);
252 SaveDialogFrame = new puFrame (0,0,350, 150);
254 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
255 SaveDialogMessage -> setLabel ("File Name:");
257 SaveDialogInput = new puInput (50, 70, 300, 100);
258 SaveDialogInput -> setValue (saveFile);
259 SaveDialogInput -> acceptInput();
261 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
262 SaveDialogOkButton -> setLegend (gui_msg_OK);
263 SaveDialogOkButton -> setCallback ( SaveDialogOk );
264 SaveDialogOkButton -> makeReturnDefault(TRUE);
266 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
267 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
268 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
270 FG_FINALIZE_PUI_DIALOG( SaveDialog );
272 SaveDialog -> reveal();
276 static puDialogBox *LoadDialog = 0;
277 static puFrame *LoadDialogFrame = 0;
278 static puText *LoadDialogMessage = 0;
279 static puInput *LoadDialogInput = 0;
281 static puOneShot *LoadDialogOkButton = 0;
282 static puOneShot *LoadDialogCancelButton = 0;
283 // static puOneShot *LoadDialogResetButton = 0;
285 // Default load filename
286 static char loadFile[256] = "fgfs.sav";
288 // Do this if the person click okay
289 void LoadDialogOk(puObject *) {
291 FG_POP_PUI_DIALOG( LoadDialog );
294 LoadDialogInput->getValue(&l);
297 if (input.good() && fgLoadFlight(input)) {
299 mkDialog("Loaded flight");
300 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
302 mkDialog("Failed to load flight");
303 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
307 // Do this if the person presses cancel
308 void LoadDialogCancel(puObject *) {
309 FG_POP_PUI_DIALOG( LoadDialog );
312 // Create Load Dialog
313 static void loadFlight(puObject *cb)
315 LoadDialog = new puDialogBox (150, 50);
317 LoadDialogFrame = new puFrame (0,0,350, 150);
319 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
320 LoadDialogMessage -> setLabel ("File Name:");
322 LoadDialogInput = new puInput (50, 70, 300, 100);
323 LoadDialogInput -> setValue (loadFile);
324 LoadDialogInput -> acceptInput();
326 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
327 LoadDialogOkButton -> setLegend (gui_msg_OK);
328 LoadDialogOkButton -> setCallback ( LoadDialogOk );
329 LoadDialogOkButton -> makeReturnDefault(TRUE);
331 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
332 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
333 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
335 FG_FINALIZE_PUI_DIALOG( LoadDialog );
337 LoadDialog -> reveal();
340 // This is the accessor function
341 void guiTogglePanel(puObject *cb)
343 if (fgGetBool("/sim/panel/visibility"))
344 fgSetBool("/sim/panel/visibility", false);
346 fgSetBool("/sim/panel/visibility", true);
348 fgReshape(fgGetInt("/sim/startup/xsize"),
349 fgGetInt("/sim/startup/ysize"));
352 //void MenuHideMenuCb(puObject *cb)
353 void hideMenuCb (puObject *cb)
358 void goodBye(puObject *)
360 // SG_LOG( SG_INPUT, SG_ALERT,
361 // "Program exiting normally at user request." );
362 cout << "Program exiting normally at user request." << endl;
364 #ifdef FG_NETWORK_OLK
365 if ( fgGetBool("/sim/networking/network-olk") ) {
366 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
370 // close all external I/O connections
377 void goAwayCb (puObject *me)
379 FG_POP_PUI_DIALOG( dialogBox );
382 void mkDialogInit (void)
384 // printf("mkDialogInit\n");
385 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
386 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
387 dialogBox = new puDialogBox (x, y); // 150, 50
389 dialogFrame = new puFrame (0,0,400,100);
390 dialogBoxMessage = new puText (10, 70);
391 dialogBoxMessage -> setLabel ("");
392 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
393 dialogBoxOkButton -> setLegend (gui_msg_OK);
394 dialogBoxOkButton -> makeReturnDefault (TRUE );
395 dialogBoxOkButton -> setCallback (goAwayCb);
397 FG_FINALIZE_PUI_DIALOG( dialogBox );
400 void MayBeGoodBye(puObject *)
405 void goAwayYesNoCb(puObject *me)
407 FG_POP_PUI_DIALOG( YNdialogBox);
410 void ConfirmExitDialogInit(void)
412 char msg[] = "Really Quit";
415 // printf("ConfirmExitDialogInit\n");
416 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
418 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
419 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
421 YNdialogBox = new puDialogBox (x, y); // 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" );
464 string help_app = fgGetString("/sim/startup/browser-app");
466 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
467 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
469 command = help_app + " " + path.str();
474 command += path.str();
477 system( command.c_str() );
478 mkDialog ("Help started in netscape window.");
481 #define TR_HIRES_SNAP
482 #if defined( TR_HIRES_SNAP)
483 #include <simgear/screen/tr.h>
484 extern void trRenderFrame( void );
485 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
486 GLfloat x_end, GLfloat y_end );
492 bool show_pu_cursor = false;
493 bool show_menu = false;
494 char *filename = new char [24];
495 static int count = 1;
497 int freeze = globals->get_freeze();
499 globals->set_freeze( true );
506 if ( !puCursorIsHidden() ) {
507 show_pu_cursor = true;
512 fgReshape( fgGetInt("/sim/startup/xsize"),
513 fgGetInt("/sim/startup/ysize") );
515 // we need two render frames here to clear the menu and cursor
516 // ... not sure why but doing an extra fgRenderFrame() shouldn't
521 // Make sure we have SSG projection primed for current view
522 glMatrixMode(GL_MODELVIEW);
524 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
525 float fov = globals->get_current_view()->get_fov();
526 ssgSetFOV(fov, fov * globals->get_current_view()->get_fov_ratio());
527 // ssgSetNearFar( 10.0f, 120000.0f );
528 ssgSetNearFar( 0.5f, 1200000.0f );
531 // This ImageSize stuff is a temporary hack
532 // should probably use 128x128 tile size and
533 // support any image size
535 // This should be a requester to get multiplier from user
537 int width = fgGetInt("/sim/startup/xsize");
538 int height = fgGetInt("/sim/startup/ysize");
540 /* allocate buffer large enough to store one tile */
541 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
543 printf("Malloc of tile buffer failed!\n");
547 int imageWidth = multiplier*width;
548 int imageHeight = multiplier*height;
550 /* allocate buffer to hold a row of tiles */
552 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
555 printf("Malloc of tile row buffer failed!\n");
558 TRcontext *tr = trNew();
559 trTileSize(tr, width, height, 0);
560 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
561 trImageSize(tr, imageWidth, imageHeight);
562 trRowOrder(tr, TR_TOP_TO_BOTTOM);
563 sgFrustum *frustum = ssgGetFrustum();
565 frustum->getLeft(), frustum->getRight(),
566 frustum->getBot(), frustum->getTop(),
567 frustum->getNear(), frustum->getFar());
569 /* Prepare ppm output file */
570 while (count < 1000) {
571 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
572 if ( (f = fopen(filename, "r")) == NULL )
576 f = fopen(filename, "wb");
578 printf("Couldn't open image file: %s\n", filename);
584 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
585 fprintf(f,"%i %i\n", imageWidth, imageHeight);
588 /* just to be safe... */
589 glPixelStorei(GL_PACK_ALIGNMENT, 1);
591 /* Because the HUD and Panel change the ViewPort we will
592 * need to handle some lowlevel stuff ourselves */
593 int ncols = trGet(tr, TR_COLUMNS);
594 int nrows = trGet(tr, TR_ROWS);
596 bool do_hud = fgGetBool("/sim/hud/visibility");
597 GLfloat hud_col_step = 640.0 / ncols;
598 GLfloat hud_row_step = 480.0 / nrows;
600 bool do_panel = fgPanelVisible();
601 GLfloat panel_col_step = current_panel->getWidth() / ncols;
602 GLfloat panel_row_step = current_panel->getHeight() / nrows;
608 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
609 int curRow = trGet(tr, TR_CURRENT_ROW);
612 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
613 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
615 current_panel->update( curColumn*panel_col_step, panel_col_step,
616 curRow*panel_row_step, panel_row_step );
617 more = trEndTile(tr);
619 /* save tile into tile row buffer*/
620 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
621 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
622 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
623 int xOffset = curColumn * bytesPerTileRow;
624 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
626 for (i=0;i<height;i++) {
627 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
628 tile + i*bytesPerTileRow, /* Src */
629 bytesPerCurrentTileRow); /* Byte count*/
632 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
633 /* write this buffered row of tiles to the file */
634 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
635 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
637 for (i=0;i<curTileHeight;i++) {
638 /* Remember, OpenGL images are bottom to top. Have to reverse. */
639 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
640 fwrite(rowPtr, 1, imageWidth*3, f);
646 fgReshape( width, height );
652 message = "Snap shot saved to ";
654 mkDialog (message.c_str());
659 // message = "Snap shot saved to ";
660 // message += filename;
661 // mkDialog (message.c_str());
668 if ( show_pu_cursor ) {
673 globals->set_freeze( false );
675 #endif // #if defined( TR_HIRES_SNAP)
678 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
680 static void rotateView( double roll, double pitch, double yaw )
685 static GlBitmap *b1 = NULL;
686 extern FGInterface cur_view_fdm;
687 GLubyte *hiResScreenCapture( int multiplier )
689 float oldfov = fgGetDouble("/sim/field-of-view");
690 float fov = oldfov / multiplier;
691 FGViewer *v = globals->get_current_view();
692 fgSetDouble("/sim/field-of-view", fov);
694 int cur_width = fgGetInt("/sim/startup/xsize");
695 int cur_height = fgGetInt("/sim/startup/ysize");
696 if (b1) delete( b1 );
697 // New empty (mostly) bitmap
698 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
700 for ( y = 0; y < multiplier; y++ ) {
701 for ( x = 0; x < multiplier; x++ ) {
702 fgReshape( cur_width, cur_height );
704 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
708 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
711 fgSetDouble("/sim/field-of-view", oldfov);
712 return b1->getBitmap();
717 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
718 // win32 print screen function
719 void printScreen ( puObject *obj ) {
720 bool show_pu_cursor = false;
722 if ( !puCursorIsHidden() ) {
723 show_pu_cursor = true;
729 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
730 int cur_width = fgGetInt("/sim/startup/xsize");
731 int cur_height = fgGetInt("/sim/startup/ysize");
732 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
733 p.End( hiResScreenCapture(3) );
736 mainMenuBar->reveal();
739 if ( show_pu_cursor ) {
744 #endif // #ifdef WIN32
747 void dumpSnapShot ( puObject *obj ) {
752 void dumpHiResSnapShot ( puObject *obj ) {
757 // do a screen snap shot
758 void fgDumpSnapShot () {
759 bool show_pu_cursor = false;
760 char *filename = new char [24];
762 static int count = 1;
764 int freeze = globals->get_freeze();
766 globals->set_freeze( true );
770 if ( !puCursorIsHidden() ) {
771 show_pu_cursor = true;
776 fgReshape( fgGetInt("/sim/startup/xsize"),
777 fgGetInt("/sim/startup/ysize") );
779 // we need two render frames here to clear the menu and cursor
780 // ... not sure why but doing an extra fgRenderFrame() shouldn't
785 while (count < 1000) {
787 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
788 if ( (fp = fopen(filename, "r")) == NULL )
793 if ( sg_glDumpWindow( filename,
794 fgGetInt("/sim/startup/xsize"),
795 fgGetInt("/sim/startup/ysize")) ) {
796 message = "Snap shot saved to ";
799 message = "Failed to save to ";
803 mkDialog (message.c_str());
807 if ( show_pu_cursor ) {
813 mainMenuBar->reveal();
817 globals->set_freeze( false );
820 #ifdef FG_NETWORK_OLK
821 static void net_display_toggle( puObject *cb)
823 net_hud_display = (net_hud_display) ? 0 : 1;
824 printf("Toggle net_hud_display : %d\n", net_hud_display);
827 static void net_register( puObject *cb)
829 fgd_send_com( "1", FGFS_host );
830 net_is_registered = 0;
831 printf("Registering to deamon\n");
834 static void net_unregister( puObject *cb)
836 fgd_send_com( "8", FGFS_host );
837 net_is_registered = -1;
838 printf("Unregistering from deamon\n");
841 extern void net_fgd_scan(puObject *cb);
842 #endif // #ifdef FG_NETWORK_OLK
844 /* -----------------------------------------------------------------------
846 ---------------------------------------------------------------------*/
847 char *fileSubmenu [] = {
848 "Exit", /* "Close", "---------", */
849 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
860 puCallback fileSubmenuCb [] = {
861 MayBeGoodBye, /* hideMenuCb, NULL, */
862 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
876 char *editSubmenu [] = {
879 puCallback editSubmenuCb [] = {
884 extern void fgHUDalphaAdjust( puObject * );
885 char *viewSubmenu [] = {
889 /* "Cockpit View > ", "View >","------------", */
890 "Toggle Panel...", NULL
892 puCallback viewSubmenuCb [] = {
896 /* notCb, notCb, NULL, */
902 char *autopilotSubmenu [] = {
903 "Toggle HUD Format", "Adjust AP Settings",
905 "Clear Route", "Skip Current Waypoint", "Add Waypoint",
907 "Set Altitude", "Set Heading",
911 puCallback autopilotSubmenuCb [] = {
912 fgLatLonFormatToggle, fgAPAdjust,
914 ClearRoute, PopWayPoint, AddWayPoint,
916 NewAltitude, NewHeading,
920 char *environmentSubmenu [] = {
921 "Goto Airport", /* "Terrain", "Weather", */ NULL
923 puCallback environmentSubmenuCb [] = {
924 NewAirport, /* notCb, notCb, */ NULL
928 char *optionsSubmenu [] = {
929 "Preferences", "Realism & Reliablity...", NULL
931 puCallback optionsSubmenuCb [] = {
936 #ifdef FG_NETWORK_OLK
937 char *networkSubmenu [] = {
938 "Unregister from FGD ", /* "Send MSG to All", "Send MSG", "Show Pilots", */
940 "Scan for Deamons", "Enter Callsign", /* "Display Netinfos", */
941 "Toggle Display", NULL
943 puCallback networkSubmenuCb [] = {
944 /* notCb, notCb, notCb, notCb, */
947 net_fgd_scan, NewCallSign,
948 net_display_toggle, NULL
952 char *helpSubmenu [] = {
953 /* "About...", */ "Help", NULL
955 puCallback helpSubmenuCb [] = {
956 /* notCb, */ helpCb, NULL
960 /* -------------------------------------------------------------------------
962 _____________________________________________________________________*/
967 char *mesa_win_state;
971 puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
972 puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
974 // Initialize our GLOBAL GUI STRINGS
975 gui_msg_OK = msg_OK; // "OK"
976 gui_msg_NO = msg_NO; // "NO"
977 gui_msg_YES = msg_YES; // "YES"
978 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
979 gui_msg_RESET = msg_RESET; // "RESET"
981 // Next check home directory
983 char* envp = ::getenv( "FG_FONTS" );
984 if ( envp != NULL ) {
987 fntpath.set( globals->get_fg_root() );
988 fntpath.append( "Fonts" );
991 // Install our fast fonts
992 fntpath.append( "typewriter.txf" );
993 guiFntHandle = new fntTexFont ;
994 guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
995 puFont GuiFont ( guiFntHandle, 15 ) ;
996 puSetDefaultFonts( GuiFont, GuiFont ) ;
997 guiFnt = puGetDefaultLabelFont();
999 if (!fgHasNode("/sim/startup/mouse-pointer")) {
1000 // no preference specified for mouse pointer, attempt to autodetect...
1001 // Determine if we need to render the cursor, or if the windowing
1002 // system will do it. First test if we are rendering with glide.
1003 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
1004 // Test for the MESA_GLX_FX env variable
1005 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
1006 // test if we are fullscreen mesa/glide
1007 if ( (mesa_win_state[0] == 'f') ||
1008 (mesa_win_state[0] == 'F') ) {
1013 // mouse_active = ~mouse_active;
1014 } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
1015 // don't show pointer
1017 // force showing pointer
1019 // mouse_active = ~mouse_active;
1022 // MOUSE_VIEW mode stuff
1025 // Set up our Dialog Boxes
1026 ConfirmExitDialogInit();
1028 #ifdef FG_NETWORK_OLK
1035 // Make the menu bar
1036 mainMenuBar = new puMenuBar ();
1037 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
1038 // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
1039 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
1040 mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
1041 mainMenuBar -> add_submenu ("Autopilot", autopilotSubmenu, autopilotSubmenuCb);
1042 // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
1043 #ifdef FG_NETWORK_OLK
1044 if ( fgGetBool("/sim/networking/network-olk") ) {
1045 mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
1048 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
1049 mainMenuBar-> close ();
1050 // Set up menu bar toggle
1053 if (fgGetString("/sim/flight-model") == "ada") {
1054 guiToggleMenu(); // Menu off by default