]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / GUI / gui.cxx
1 /**************************************************************************
2  * gui.cxx
3  *
4  * Written 1998 by Durk Talsma, started Juni, 1998.  For the flight gear
5  * project.
6  *
7  * Additional mouse supported added by David Megginson, 1999.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  *
23  * $Id$
24  **************************************************************************/
25
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #ifdef HAVE_WINDOWS_H
34 #  include <windows.h>
35 #endif
36
37 #include <simgear/misc/exception.hxx>
38 #include <simgear/misc/sg_path.hxx>
39 #include <simgear/props/props.hxx>
40 #include <simgear/props/props_io.hxx>
41
42 #include <plib/pu.h>
43
44 #include <Include/general.hxx>
45 #include <Main/globals.hxx>
46 #include <Main/fg_props.hxx>
47
48 #include "gui.h"
49 #include "gui_local.hxx"
50 #include "net_dlg.hxx"
51 #include "preset_dlg.hxx"
52
53
54 // main.cxx hack, should come from an include someplace
55 extern void fgInitVisuals( void );
56 extern void fgRenderFrame( void );
57
58 extern void initDialog (void);
59 extern void mkDialogInit (void);
60 extern void ConfirmExitDialogInit(void);
61
62
63 puFont guiFnt = 0;
64 fntTexFont *guiFntHandle = 0;
65
66
67 /* -------------------------------------------------------------------------
68 init the gui
69 _____________________________________________________________________*/
70
71
72 void guiInit()
73 {
74     char *mesa_win_state;
75
76     // Initialize PUI
77     puInit();
78     puSetDefaultStyle         ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
79     puSetDefaultColourScheme  (0.8, 0.8, 0.9, 0.8);
80
81     initDialog();
82
83     // Next check home directory
84     SGPath fntpath;
85     char* envp = ::getenv( "FG_FONTS" );
86     if ( envp != NULL ) {
87         fntpath.set( envp );
88     } else {
89         fntpath.set( globals->get_fg_root() );
90         fntpath.append( "Fonts" );
91     }
92
93     // Install our fast fonts
94     SGPropertyNode *locale = globals->get_locale();
95     fntpath.append(locale->getStringValue("font", "typewriter.txf"));
96     guiFntHandle = new fntTexFont ;
97     guiFntHandle -> load ( (char *)fntpath.c_str() ) ;
98     puFont GuiFont ( guiFntHandle, 15 ) ;
99     puSetDefaultFonts( GuiFont, GuiFont ) ;
100     guiFnt = puGetDefaultLabelFont();
101   
102     if (!fgHasNode("/sim/startup/mouse-pointer")) {
103         // no preference specified for mouse pointer, attempt to autodetect...
104         // Determine if we need to render the cursor, or if the windowing
105         // system will do it.  First test if we are rendering with glide.
106         if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
107             // Test for the MESA_GLX_FX env variable
108             if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
109                 // test if we are fullscreen mesa/glide
110                 if ( (mesa_win_state[0] == 'f') ||
111                      (mesa_win_state[0] == 'F') ) {
112                     puShowCursor ();
113                 }
114             }
115         }
116 //        mouse_active = ~mouse_active;
117     } else if ( !fgGetBool("/sim/startup/mouse-pointer") ) {
118         // don't show pointer
119     } else {
120         // force showing pointer
121         puShowCursor();
122 //        mouse_active = ~mouse_active;
123     }
124         
125     // MOUSE_VIEW mode stuff
126         initMouseQuat();
127
128     // Set up our Dialog Boxes
129     ConfirmExitDialogInit();
130     fgPresetInit();
131         
132 #ifdef FG_NETWORK_OLK
133     NewNetIdInit();
134     NewNetFGDInit();
135 #endif
136
137     mkDialogInit();
138 }