]> git.mxchange.org Git - flightgear.git/blob - src/GUI/gui_local.cxx
Restructured the 'freeze' property a bit. We now have
[flightgear.git] / src / GUI / gui_local.cxx
1 #ifdef HAVE_CONFIG_H
2 #  include <config.h>
3 #endif
4
5 #ifdef HAVE_WINDOWS_H
6 #  include <windows.h>
7 #endif
8
9 #include <GL/glut.h>        // needed before pu.h
10 #include <plib/pu.h>        // plib include
11
12 #include <FDM/flight.hxx>
13
14 #include <Main/globals.hxx>
15 #include <Main/fg_init.hxx>
16 #include <Main/fg_props.hxx>
17 #include <Scenery/tilemgr.hxx>
18 #include <Time/light.hxx>
19
20 #include "gui.h"
21 #include "trackball.h"
22
23 // from main.cxx
24 extern void fgReshape(int, int);
25
26 // FOR MOUSE VIEW MODE
27 // stashed trackball(_quat0, 0.0, 0.0, 0.0, 0.0);
28 static float _quat0[4];
29
30 float lastGuiQuat[4];
31 float curGuiQuat[4];
32
33 // To apply our mouse rotation quat to VIEW
34 // sgPreMultMat4( VIEW, GuiQuat_mat);
35 // This is here temporarily should be in views.hxx
36 float GuiQuat_mat[4][4];
37
38 void Quat0( void ) {
39     curGuiQuat[0] = _quat0[0];
40     curGuiQuat[1] = _quat0[1];
41     curGuiQuat[2] = _quat0[2];
42     curGuiQuat[3] = _quat0[3];
43 }
44
45 void initMouseQuat(void) {
46     trackball(_quat0, 0.0, 0.0, 0.0, 0.0);  
47     Quat0();
48     build_rotmatrix(GuiQuat_mat, curGuiQuat);
49 }
50
51
52 void reInit(puObject *cb)
53 {
54     // BusyCursor(0);
55     Quat0();
56
57     static const SGPropertyNode *master_freeze
58         = fgGetNode("/sim/freeze/master");
59
60     bool freeze = master_freeze->getBoolValue();
61     if ( !freeze ) {
62         fgSetBool("/sim/freeze/master", true);
63     }
64
65     cur_fdm_state->unbind();
66
67     // in case user has changed window size as
68     // restoreInitialState() overwrites these
69     int xsize = fgGetInt("/sim/startup/xsize");
70     int ysize = fgGetInt("/sim/startup/ysize");
71
72     build_rotmatrix(GuiQuat_mat, curGuiQuat);
73
74     globals->restoreInitialState();
75
76         // Unsuccessful KLUDGE to fix the 'every other time'
77         // problem when doing a 'reset' after a 'goto airport'
78         
79         // string AptId( fgGetString("/sim/startup/airport-id") );
80         // if( AptId.c_str() != "\0" )
81         //      fgSetPosFromAirportID( AptId );
82         
83     fgReInitSubsystems();
84
85     // reduntant(fgReInitSubsystems) ?
86     global_tile_mgr.update( fgGetDouble("/position/longitude-deg"),
87                             fgGetDouble("/position/latitude-deg") );
88     
89     cur_light_params.Update();
90
91     fgReshape( xsize, ysize );
92
93     // BusyCursor(1);
94     
95     if ( !freeze ) {
96         fgSetBool("/sim/freeze/master", false);
97     }
98 }
99