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 <Include/compiler.h>
33 #ifdef FG_MATH_EXCEPTION_CLASH
44 #if defined(FX) && defined(XMESA)
45 # include <GL/xmesa.h>
53 #include <Include/general.hxx>
54 #include <Debug/logstream.hxx>
55 #include <Aircraft/aircraft.hxx>
56 #include <Airports/simple.hxx>
57 #include <Cockpit/panel.hxx>
58 #include <FDM/flight.hxx>
59 #include <Main/options.hxx>
60 #include <Main/fg_init.hxx>
61 #include <Main/views.hxx>
62 #include <Misc/fgpath.hxx>
63 #include <Network/network.h>
64 #include <Screen/screen-dump.hxx>
65 #include <Time/fg_time.hxx>
68 # include <Screen/win32-printer.h>
75 #ifndef FG_HAVE_NATIVE_SGI_COMPILERS
79 // hack, should come from an include someplace
80 extern void fgInitVisuals( void );
81 extern void fgReshape( int width, int height );
82 extern void fgRenderFrame( void );
85 fntTexFont *guiFntHandle = 0;
87 static puMenuBar *mainMenuBar = 0;
88 //static puButton *hideMenuButton = 0;
90 static puDialogBox *dialogBox = 0;
91 static puFrame *dialogFrame = 0;
92 static puText *dialogBoxMessage = 0;
93 static puOneShot *dialogBoxOkButton = 0;
96 static puDialogBox *YNdialogBox = 0;
97 static puFrame *YNdialogFrame = 0;
98 static puText *YNdialogBoxMessage = 0;
99 static puOneShot *YNdialogBoxOkButton = 0;
100 static puOneShot *YNdialogBoxNoButton = 0;
102 static char msg_OK[] = "OK";
103 static char msg_NO[] = "NO";
104 static char msg_YES[] = "YES";
105 static char msg_CANCEL[] = "Cancel";
106 static char msg_RESET[] = "Reset";
108 char *gui_msg_OK; // "OK"
109 char *gui_msg_NO; // "NO"
110 char *gui_msg_YES; // "YES"
111 char *gui_msg_CANCEL; // "CANCEL"
112 char *gui_msg_RESET; // "RESET"
114 static char global_dialog_string[256];
116 extern void NewAltitude( puObject *cb );
117 extern void NewHeading( puObject *cb );
118 extern void fgAPAdjust( puObject * );
119 extern void fgLatLonFormatToggle( puObject *);
120 extern void NewTgtAirport( puObject *cb );
122 /* --------------------------------------------------------------------
124 ---------------------------------------------------------------------*/
128 static int _savedX = 0;
129 static int _savedY = 0;
130 static int last_buttons = 0 ;
131 static int mouse_active = 0;
132 static int menu_on = 0;
134 /* --------------------------------------------------------------------
135 Support for mouse as control yoke (david@megginson.com)
137 - right button toggles between pointer and yoke
138 - horizontal drag with no buttons moves ailerons
139 - vertical drag with no buttons moves elevators
140 - horizontal drag with left button moves brakes (left=on)
141 - vertical drag with left button moves throttle (up=more)
142 - horizontal drag with middle button moves rudder
143 - vertical drag with middle button moves trim
145 For the *_sensitivity variables, a lower number means more sensitive.
147 TODO: figure out how to keep pointer from leaving window in yoke mode.
148 TODO: add thresholds and null zones
149 TODO: sensitivity should be configurable at user option.
150 TODO: allow differential braking (this will be useful if FlightGear
151 ever supports tail-draggers like the DC-3)
152 ---------------------------------------------------------------------*/
160 MouseMode mouse_mode = MOUSE_POINTER;
161 static float aileron_sensitivity = 500.0;
162 static float elevator_sensitivity = 500.0;
163 static float brake_sensitivity = 250.0;
164 static float throttle_sensitivity = 250.0;
165 static float rudder_sensitivity = 500.0;
166 static float trim_sensitivity = 1000.0;
168 void guiMotionFunc ( int x, int y )
170 if (mouse_mode == MOUSE_POINTER) {
172 glutPostRedisplay () ;
174 int ww = current_view.get_winWidth();
175 int wh = current_view.get_winHeight();
178 if (mouse_mode == MOUSE_YOKE) {
179 if (last_buttons & (1 << GLUT_LEFT_BUTTON)) {
180 float brake_offset = (_mX - x) / brake_sensitivity;
181 float throttle_offset = (_mY - y) / throttle_sensitivity;
182 controls.move_brake(FGControls::ALL_WHEELS, brake_offset);
183 controls.move_throttle(FGControls::ALL_ENGINES, throttle_offset);
184 } else if (last_buttons & (1 << GLUT_MIDDLE_BUTTON)) {
185 float rudder_offset = (x - _mX) / rudder_sensitivity;
186 float trim_offset = (_mY - y) / trim_sensitivity;
187 controls.move_rudder(rudder_offset);
188 controls.move_elevator_trim(trim_offset);
190 float aileron_offset = (x - _mX) / aileron_sensitivity;
191 float elevator_offset = (_mY - y) / elevator_sensitivity;
192 controls.move_aileron(aileron_offset);
193 controls.move_elevator(elevator_offset);
198 FGView * v = ¤t_view;
199 double offset = v->get_goal_view_offset();
200 double full = FG_PI * 2.0;
201 offset += (_mX - x) / 500.0;
205 while (offset > full) {
208 v->set_view_offset(offset);
209 v->set_goal_view_offset(offset);
212 // Keep the mouse in the window.
213 if (x < 5 || x > ww-5 || y < 5 || y > wh-5) {
216 glutWarpPointer(x, y);
220 // Record the new mouse position.
225 void guiMouseFunc(int button, int updown, int x, int y)
227 // Was the left button pressed?
228 if (updown == GLUT_DOWN && button == GLUT_LEFT_BUTTON) {
229 switch (mouse_mode) {
235 current_view.set_view_offset( 0.00 );
236 current_view.set_goal_view_offset( 0.00 );
240 // Or was it the right button?
241 } else if (updown == GLUT_DOWN && button == GLUT_RIGHT_BUTTON) {
242 switch (mouse_mode) {
244 mouse_mode = MOUSE_YOKE;
247 glutSetCursor(GLUT_CURSOR_NONE);
248 FG_LOG( FG_INPUT, FG_INFO, "Mouse in yoke mode" );
251 mouse_mode = MOUSE_VIEW;
252 FG_LOG( FG_INPUT, FG_INFO, "Mouse in view mode" );
255 mouse_mode = MOUSE_POINTER;
258 glutWarpPointer(x, y);
259 glutSetCursor(GLUT_CURSOR_INHERIT);
260 FG_LOG( FG_INPUT, FG_INFO, "Mouse in pointer mode" );
265 // Register the new position (if it
266 // hasn't been registered already).
270 // Note which button is pressed.
271 if ( updown == GLUT_DOWN ) {
272 last_buttons |= ( 1 << button ) ;
274 last_buttons &= ~( 1 << button ) ;
277 // If we're in pointer mode, let PUI
278 // know what's going on.
279 if (mouse_mode == MOUSE_POINTER) {
280 puMouse (button, updown, x,y);
281 glutPostRedisplay ();
285 int guiGetMouseButton(void)
290 void guiGetMouse(int *x, int *y)
296 static inline void TurnCursorOn( void )
299 #if defined ( WIN32 ) || defined(__CYGWIN32__)
300 glutSetCursor(GLUT_CURSOR_INHERIT);
302 #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
303 glutWarpPointer( glutGet((GLenum)GLUT_SCREEN_WIDTH)/2, glutGet((GLenum)GLUT_SCREEN_HEIGHT)/2);
307 static inline void TurnCursorOff( void )
310 #if defined ( WIN32 ) || defined(__CYGWIN32__)
311 glutSetCursor(GLUT_CURSOR_NONE);
312 #else // I guess this is what we want to do ??
313 #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
314 glutWarpPointer( glutGet((GLenum)GLUT_SCREEN_WIDTH), glutGet((GLenum)GLUT_SCREEN_HEIGHT));
319 void maybeToggleMouse( void )
322 static int first_time = ~0;
323 static int mouse_changed = 0;
327 mouse_changed = ~mouse_changed;
331 if( mouse_changed ) {
332 mouse_changed = ~mouse_changed;
338 first_time = ~first_time;
339 #endif // #ifdef WIN32
342 // Call with FALSE to init and TRUE to restore
343 void BusyCursor( int restore )
345 static int cursor = 0;
347 glutSetCursor(cursor);
349 cursor = glutGet( (GLenum)GLUT_WINDOW_CURSOR );
353 glutSetCursor( GLUT_CURSOR_WAIT );
356 /* ================ General Purpose Functions ================ */
358 // Intercept the Escape Key
359 void ConfirmExitDialog(void)
361 FG_PUSH_PUI_DIALOG( YNdialogBox );
364 // General Purpose Message Box
365 void mkDialog (const char *txt)
367 strncpy(global_dialog_string, txt, 256);
368 dialogBoxMessage->setLabel(global_dialog_string);
369 FG_PUSH_PUI_DIALOG( dialogBox );
372 // Repair any damage done to the Panel by other Gui Items
373 void guiFixPanel( void )
377 if ( current_options.get_panel_status() ) {
378 FGView *v = ¤t_view;
379 FGTime *t = FGTime::cur_time_params;
381 if( (toggle_pause = !t->getPause()) )
382 t->togglePauseMode();
384 // this seems to be the only way to do this :-(
385 // problem is the viewport has been mucked with
386 xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
387 FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
390 t->togglePauseMode();
394 // Toggle the Menu and Mouse display state
395 void guiToggleMenu(void)
398 // printf("Hiding Menu\n");
399 mainMenuBar->hide ();
402 #endif // #ifdef WIN32
404 // printf("Showing Menu\n");
405 mainMenuBar->reveal();
408 #endif // #ifdef WIN32
413 /* -----------------------------------------------------------------------
414 the Gui callback functions
415 ____________________________________________________________________*/
417 void reInit(puObject *cb)
420 fgReInitSubsystems();
424 // This is the accessor function
425 void guiTogglePanel(puObject *cb)
427 current_options.toggle_panel();
430 //void MenuHideMenuCb(puObject *cb)
431 void hideMenuCb (puObject *cb)
436 void goodBye(puObject *)
438 // FG_LOG( FG_INPUT, FG_ALERT,
439 // "Program exiting normally at user request." );
440 cout << "Program exiting normally at user request." << endl;
449 void goAwayCb (puObject *me)
451 FG_POP_PUI_DIALOG( dialogBox );
454 void mkDialogInit (void)
456 // printf("mkDialogInit\n");
457 int x = (current_options.get_xsize()/2 - 400/2);
458 int y = (current_options.get_ysize()/2 - 100/2);
459 dialogBox = new puDialogBox (x, y); // 150, 50
461 dialogFrame = new puFrame (0,0,400,100);
462 dialogBoxMessage = new puText (10, 70);
463 dialogBoxMessage -> setLabel ("");
464 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
465 dialogBoxOkButton -> setLegend (gui_msg_OK);
466 dialogBoxOkButton -> makeReturnDefault (TRUE );
467 dialogBoxOkButton -> setCallback (goAwayCb);
469 FG_FINALIZE_PUI_DIALOG( dialogBox );
472 void MayBeGoodBye(puObject *)
477 void goAwayYesNoCb(puObject *me)
479 FG_POP_PUI_DIALOG( YNdialogBox);
482 void ConfirmExitDialogInit(void)
484 char msg[] = "Really Quit";
487 // printf("ConfirmExitDialogInit\n");
488 int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
490 int x = (current_options.get_xsize()/2 - 400/2);
491 int y = (current_options.get_ysize()/2 - 100/2);
493 YNdialogBox = new puDialogBox (x, y); // 150, 50
494 // YNdialogBox = new puDialogBox (150, 50);
496 YNdialogFrame = new puFrame (0,0,400, 100);
498 YNdialogBoxMessage = new puText (len, 70);
499 YNdialogBoxMessage -> setDefaultValue (msg);
500 YNdialogBoxMessage -> getDefaultValue (&s);
501 YNdialogBoxMessage -> setLabel (s);
503 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
504 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
505 YNdialogBoxOkButton -> setCallback (goodBye);
507 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
508 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
509 // YNdialogBoxNoButton -> makeReturnDefault (TRUE );
510 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
512 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
515 void notCb (puObject *)
517 mkDialog ("This function isn't implemented yet");
520 void helpCb (puObject *)
524 #if defined(FX) && !defined(WIN32)
525 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
526 if ( global_fullscreen ) {
527 global_fullscreen = false;
528 XMesaSetFXmode( XMESA_FX_WINDOW );
534 string url = "http://www.flightgear.org/Docs/InstallGuide/getstart.html";
536 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
537 command = "netscape -remote \"openURL(" + url + ")\" &";
539 command = "netscape " + url + " &";
542 command = "webrun.bat";
545 system( command.c_str() );
546 //string text = "Help started in netscape window.";
548 //mkDialog (text.c_str());
549 mkDialog ("Help started in netscape window.");
555 // win32 print screen function
556 void printScreen ( puObject *obj ) {
557 bool show_pu_cursor = false;
559 if ( !puCursorIsHidden() ) {
560 show_pu_cursor = true;
567 p.Begin( "FlightGear" );
569 fgReshape( p.GetHorzRes(), p.GetVertRes() );
574 mainMenuBar->reveal();
577 if ( show_pu_cursor ) {
582 #endif // #ifdef WIN32
586 void dumpScreen ( puObject *obj ) {
587 bool show_pu_cursor = false;
591 if ( !puCursorIsHidden() ) {
592 show_pu_cursor = true;
597 fgReshape( current_options.get_xsize(), current_options.get_ysize() );
599 // we need two render frames here to clear the menu and cursor
600 // ... not sure why but doing an extra fgFenderFrame() shoulnd't
605 my_glDumpWindow( "fgfs-screen.ppm",
606 current_options.get_xsize(),
607 current_options.get_ysize() );
609 mkDialog ("Screen dump saved to fgfs-screen.ppm");
611 if ( show_pu_cursor ) {
617 mainMenuBar->reveal();
623 /// The beginnings of teleportation :-)
624 // Needs cleaning up but works
625 // These statics should disapear when this is a class
626 static puDialogBox *AptDialog = 0;
627 static puFrame *AptDialogFrame = 0;
628 static puText *AptDialogMessage = 0;
629 static puInput *AptDialogInput = 0;
631 static char NewAirportId[16];
632 static char NewAirportLabel[] = "Enter New Airport ID";
634 static puOneShot *AptDialogOkButton = 0;
635 static puOneShot *AptDialogCancelButton = 0;
636 static puOneShot *AptDialogResetButton = 0;
638 void AptDialog_Cancel(puObject *)
640 FG_POP_PUI_DIALOG( AptDialog );
643 void AptDialog_OK (puObject *)
648 FGTime *t = FGTime::cur_time_params;
649 int PauseMode = t->getPause();
651 t->togglePauseMode();
654 AptDialogInput->getValue(&s);
657 cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
659 AptDialog_Cancel( NULL );
661 if ( AptId.length() ) {
662 // set initial position from airport id
663 FG_LOG( FG_GENERAL, FG_INFO,
664 "Attempting to set starting position from airport code "
667 airports.load("apt_simple");
668 if ( airports.search( AptId, &a ) )
670 current_options.set_airport_id( AptId.c_str() );
672 fgReInitSubsystems();
675 AptId += " not in database.";
676 mkDialog(AptId.c_str());
679 if( PauseMode != t->getPause() )
680 t->togglePauseMode();
683 void AptDialog_Reset(puObject *)
685 // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
686 sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
687 AptDialogInput->setValue ( NewAirportId );
688 AptDialogInput->setCursor( 0 ) ;
691 void NewAirport(puObject *cb)
693 // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
694 sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
695 // cout << "NewAirport " << NewAirportId << endl;
696 AptDialogInput->setValue( NewAirportId );
698 FG_PUSH_PUI_DIALOG( AptDialog );
701 static void NewAirportInit(void)
703 sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
704 int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
705 NewAirportLabel ) / 2;
707 AptDialog = new puDialogBox (150, 50);
709 AptDialogFrame = new puFrame (0,0,350, 150);
710 AptDialogMessage = new puText (len, 110);
711 AptDialogMessage -> setLabel (NewAirportLabel);
713 AptDialogInput = new puInput (50, 70, 300, 100);
714 AptDialogInput -> setValue (NewAirportId);
715 AptDialogInput -> acceptInput();
717 AptDialogOkButton = new puOneShot (50, 10, 110, 50);
718 AptDialogOkButton -> setLegend (gui_msg_OK);
719 AptDialogOkButton -> setCallback (AptDialog_OK);
720 AptDialogOkButton -> makeReturnDefault(TRUE);
722 AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
723 AptDialogCancelButton -> setLegend (gui_msg_CANCEL);
724 AptDialogCancelButton -> setCallback (AptDialog_Cancel);
726 AptDialogResetButton = new puOneShot (240, 10, 300, 50);
727 AptDialogResetButton -> setLegend (gui_msg_RESET);
728 AptDialogResetButton -> setCallback (AptDialog_Reset);
730 cout << "NewAirportInit " << NewAirportId << endl;
731 FG_FINALIZE_PUI_DIALOG( AptDialog );
734 /// The beginnings of networking :-)
735 // Needs cleaning up but works
736 // These statics should disapear when this is a class
737 static puDialogBox *NetIdDialog = 0;
738 static puFrame *NetIdDialogFrame = 0;
739 static puText *NetIdDialogMessage = 0;
740 static puInput *NetIdDialogInput = 0;
742 static char NewNetId[16];
743 static char NewNetIdLabel[] = "Enter New Callsign";
745 static puOneShot *NetIdDialogOkButton = 0;
746 static puOneShot *NetIdDialogCancelButton = 0;
748 void NetIdDialog_Cancel(puObject *)
750 FG_POP_PUI_DIALOG( NetIdDialog );
753 void NetIdDialog_OK (puObject *)
757 FGTime *t = FGTime::cur_time_params;
758 int PauseMode = t->getPause();
760 t->togglePauseMode();
762 The following needs some cleanup because
763 "string options.NetId" and "char *net_callsign"
765 NetIdDialogInput->getValue(&net_callsign);
766 NetId = net_callsign;
768 NetIdDialog_Cancel( NULL );
769 current_options.set_net_id( NetId.c_str() );
770 /* Entering a callsign indicates : user wants Net HUD Info */
773 if( PauseMode != t->getPause() )
774 t->togglePauseMode();
777 void NewCallSign(puObject *cb)
779 sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
780 NetIdDialogInput->setValue( NewNetId );
782 FG_PUSH_PUI_DIALOG( NetIdDialog );
785 static void NewNetIdInit(void)
787 sprintf( NewNetId, "%s", current_options.get_net_id().c_str() );
788 int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
791 NetIdDialog = new puDialogBox (150, 50);
793 NetIdDialogFrame = new puFrame (0,0,350, 150);
794 NetIdDialogMessage = new puText (len, 110);
795 NetIdDialogMessage -> setLabel (NewNetIdLabel);
797 NetIdDialogInput = new puInput (50, 70, 300, 100);
798 NetIdDialogInput -> setValue (NewNetId);
799 NetIdDialogInput -> acceptInput();
801 NetIdDialogOkButton = new puOneShot (50, 10, 110, 50);
802 NetIdDialogOkButton -> setLegend (gui_msg_OK);
803 NetIdDialogOkButton -> setCallback (NetIdDialog_OK);
804 NetIdDialogOkButton -> makeReturnDefault(TRUE);
806 NetIdDialogCancelButton = new puOneShot (240, 10, 300, 50);
807 NetIdDialogCancelButton -> setLegend (gui_msg_CANCEL);
808 NetIdDialogCancelButton -> setCallback (NetIdDialog_Cancel);
811 FG_FINALIZE_PUI_DIALOG( NetIdDialog );
814 static void net_display_toggle( puObject *cb)
816 net_hud_display = (net_hud_display) ? 0 : 1;
817 printf("Toggle net_hud_display : %d\n", net_hud_display);
820 static void net_blaster_toggle( puObject *cb)
822 net_blast_toggle = (net_blast_toggle) ? 0 : -1;
823 printf("Toggle net_blast : %d\n", net_blast_toggle);
826 /*************** End Networking **************/
830 /* -----------------------------------------------------------------------
832 ---------------------------------------------------------------------*/
833 char *fileSubmenu [] = {
834 "Exit", /* "Close", "---------", */
839 /* "---------", "Save", */
842 puCallback fileSubmenuCb [] = {
843 MayBeGoodBye, /* hideMenuCb, NULL, */
853 char *editSubmenu [] = {
856 puCallback editSubmenuCb [] = {
861 char *viewSubmenu [] = {
862 /* "Cockpit View > ", "View >","------------", */ "Toggle Panel...", NULL
864 puCallback viewSubmenuCb [] = {
865 /* notCb, notCb, NULL, guiTogglePanel, */ NULL
868 char *aircraftSubmenu [] = {
869 "Autopilot", "Heading", "Altitude", "Navigation", "Airport",
870 /* "Communication", */ NULL
872 puCallback aircraftSubmenuCb [] = {
873 fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, NewTgtAirport,
877 char *environmentSubmenu [] = {
878 "Airport", /* "Terrain", "Weather", */ NULL
880 puCallback environmentSubmenuCb [] = {
881 NewAirport, /* notCb, notCb, */ NULL
885 char *optionsSubmenu [] = {
886 "Preferences", "Realism & Reliablity...", NULL
888 puCallback optionsSubmenuCb [] = {
893 #ifdef FG_NETWORK_OLK
894 char *networkSubmenu [] = {
895 /* "Unregister from FGD ", "Send MSG to All", "Send MSG", "Show Pilots", */
896 /* "Register to FGD", */
897 /* "Scan for Deamons", */ "Enter Callsign", /* "Display Netinfos", */
901 puCallback networkSubmenuCb [] = {
902 /* notCb, notCb, notCb, notCb, notCb, notCb, */ NewCallSign, /* notCb, */
903 net_display_toggle, net_blaster_toggle, NULL
907 char *helpSubmenu [] = {
908 /* "About...", */ "Help", NULL
910 puCallback helpSubmenuCb [] = {
911 /* notCb, */ helpCb, NULL
915 /* -------------------------------------------------------------------------
917 _____________________________________________________________________*/
922 char *mesa_win_state;
926 puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
927 puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
929 // Initialize our GLOBAL GUI STRINGS
930 gui_msg_OK = msg_OK; // "OK"
931 gui_msg_NO = msg_NO; // "NO"
932 gui_msg_YES = msg_YES; // "YES"
933 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
934 gui_msg_RESET = msg_RESET; // "RESET"
936 // Next check home directory
938 char* envp = ::getenv( "FG_FONTS" );
939 if ( envp != NULL ) {
942 fntpath.set( current_options.get_fg_root() );
943 fntpath.append( "Fonts" );
946 // Install our fast fonts
947 fntpath.append( "typewriter.txf" );
948 guiFntHandle = new fntTexFont ;
949 guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
950 puFont GuiFont ( guiFntHandle, 15 ) ;
951 puSetDefaultFonts( GuiFont, GuiFont ) ;
952 guiFnt = puGetDefaultLabelFont();
954 if ( current_options.get_mouse_pointer() == 0 ) {
955 // no preference specified for mouse pointer, attempt to autodetect...
956 // Determine if we need to render the cursor, or if the windowing
957 // system will do it. First test if we are rendering with glide.
958 if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
959 // Test for the MESA_GLX_FX env variable
960 if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
961 // test if we are fullscreen mesa/glide
962 if ( (mesa_win_state[0] == 'f') ||
963 (mesa_win_state[0] == 'F') ) {
968 mouse_active = ~mouse_active;
969 } else if ( current_options.get_mouse_pointer() == 1 ) {
970 // don't show pointer
971 } else if ( current_options.get_mouse_pointer() == 2 ) {
972 // force showing pointer
974 mouse_active = ~mouse_active;
977 // Set up our Dialog Boxes
978 ConfirmExitDialogInit();
980 #ifdef FG_NETWORK_OLK
986 mainMenuBar = new puMenuBar ();
987 mainMenuBar -> add_submenu ("File", fileSubmenu, fileSubmenuCb);
988 // mainMenuBar -> add_submenu ("Edit", editSubmenu, editSubmenuCb);
989 mainMenuBar -> add_submenu ("View", viewSubmenu, viewSubmenuCb);
990 mainMenuBar -> add_submenu ("Aircraft", aircraftSubmenu, aircraftSubmenuCb);
991 mainMenuBar -> add_submenu ("Environment", environmentSubmenu, environmentSubmenuCb);
992 // mainMenuBar -> add_submenu ("Options", optionsSubmenu, optionsSubmenuCb);
993 #ifdef FG_NETWORK_OLK
994 mainMenuBar -> add_submenu ("Network", networkSubmenu, networkSubmenuCb);
996 mainMenuBar -> add_submenu ("Help", helpSubmenu, helpSubmenuCb);
997 mainMenuBar-> close ();
998 // Set up menu bar toggle