]> git.mxchange.org Git - flightgear.git/commitdiff
Move current_panel to globals
authorehofman <ehofman>
Sun, 30 Mar 2003 12:46:08 +0000 (12:46 +0000)
committerehofman <ehofman>
Sun, 30 Mar 2003 12:46:08 +0000 (12:46 +0000)
src/Cockpit/panel.cxx
src/GUI/gui_funcs.cxx
src/GUI/mouse.cxx
src/Input/input.cxx
src/Main/fg_commands.cxx
src/Main/fg_init.cxx
src/Main/globals.hxx
src/Main/main.cxx

index 965d8c04de38fe9c88254f8d353c1210d48b97c2..1be381486bb961b4d0b3d8dd16e3b97f7b65f673 100644 (file)
@@ -80,9 +80,9 @@ get_aspect_adjust (int xsize, int ysize)
 bool
 fgPanelVisible ()
 {
-     if(current_panel == 0)
+     if(globals->get_current_panel() == 0)
        return false;
-     if(current_panel->getVisibility() == 0)
+     if(globals->get_current_panel()->getVisibility() == 0)
        return false;
      if(globals->get_viewmgr()->get_current() != 0)
        return false;
@@ -163,7 +163,6 @@ FGCroppedTexture::getTexture ()
 // Implementation of FGPanel.
 ////////////////////////////////////////////////////////////////////////
 
-FGPanel * current_panel = NULL;
 static fntRenderer text_renderer;
 static fntTexFont *default_font = 0;
 static fntTexFont *led_font = 0;
index e802c1d6263fcd78daaaf721d7e8e7d1da5a2e9f..9793cdcc89399eed3fe1064dab9859b38d7f213e 100644 (file)
@@ -693,8 +693,8 @@ void fgHiResDump()
     GLfloat hud_row_step = 480.0 / nrows;
        
     bool do_panel = fgPanelVisible();
-    GLfloat panel_col_step = current_panel->getWidth() / ncols;
-    GLfloat panel_row_step = current_panel->getHeight() / nrows;
+    GLfloat panel_col_step = globals->get_current_panel()->getWidth() / ncols;
+    GLfloat panel_row_step = globals->get_current_panel()->getHeight() / nrows;
        
     /* Draw tiles */
     int more = 1;
@@ -707,7 +707,8 @@ void fgHiResDump()
             fgUpdateHUD( curColumn*hud_col_step,      curRow*hud_row_step,
                          (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
         if (do_panel)
-            current_panel->update( curColumn*panel_col_step, panel_col_step,
+            globals->get_current_panel()->update(
+                                   curColumn*panel_col_step, panel_col_step,
                                    curRow*panel_row_step,    panel_row_step );
         more = trEndTile(tr);
 
index d33f8da39a3f08c2f13f35a95a466a3f5288ba13..4f63d7c4f522a2e26b572b747a78a8e47c9d9c92 100644 (file)
@@ -648,8 +648,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
     // know what's going on.
     if (mouse_mode == MOUSE_POINTER) {
       if (!puMouse (button, updown, x,y)) {
-        if ( current_panel != NULL ) {
-          current_panel->doMouseAction(button, updown, x, y);
+        if ( globals->get_current_panel() != NULL ) {
+          globals->get_current_panel()->doMouseAction(button, updown, x, y);
         }
       }
     }
index 999cf12781630a8708e41e2ea0a26a7ee45d2766..5483fd11b4864f2dd71bd59ddc5d95317e106e0f 100644 (file)
@@ -341,9 +341,9 @@ FGInput::doMouseClick (int b, int updown, int x, int y)
   if (mode.pass_through) {
     if (puMouse(b, updown, x, y))
       return;
-    else if ((current_panel != 0) &&
-             current_panel->getVisibility() &&
-             current_panel->doMouseAction(b, updown, x, y))
+    else if ((globals->get_current_panel() != 0) &&
+             globals->get_current_panel()->getVisibility() &&
+             globals->get_current_panel()->doMouseAction(b, updown, x, y))
       return;
     else if (fgHandle3DPanelMouseEvent(b, updown, x, y))
       return;
index a56a21ef99c81284f127b5ead2096f0e4df62b5d..8218dfa3d31f61476852f13d45799e9595282378 100644 (file)
@@ -324,10 +324,10 @@ do_panel_load (const SGPropertyNode * arg)
     return false;
   }
   SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
-  current_panel->unbind();
-  delete current_panel;
-  current_panel = new_panel;
-  current_panel->bind();
+  globals->get_current_panel()->unbind();
+  delete globals->get_current_panel();
+  globals->set_current_panel( new_panel );
+  globals->get_current_panel()->bind();
   return true;
 }
 
@@ -343,8 +343,8 @@ do_panel_load (const SGPropertyNode * arg)
 static bool
 do_panel_mouse_click (const SGPropertyNode * arg)
 {
-  if (current_panel != 0)
-    return current_panel
+  if (globals->get_current_panel() != 0)
+    return globals->get_current_panel()
       ->doMouseAction(arg->getIntValue("button"),
                      arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
                      arg->getIntValue("x-pos"),
index 34d1345c075e33bcd0a6db1de9b22991ddcafc89..04f8ca1cbe4a293781dfd2c6e1323110586beae9 100644 (file)
@@ -1529,6 +1529,7 @@ bool fgInitSubsystems() {
         globals->get_AI_mgr()->init();
     }
 
+
 #ifdef ENABLE_AUDIO_SUPPORT
     ////////////////////////////////////////////////////////////////////
     // Initialize the sound subsystem.
@@ -1593,17 +1594,22 @@ bool fgInitSubsystems() {
     globals->get_io()->init();
     globals->get_io()->bind();
 
-    // Initialize the 2D panel.
+
+    ////////////////////////////////////////////////////////////////////
+    // Add a new 2D panel.
+    ////////////////////////////////////////////////////////////////////
+
     string panel_path = fgGetString("/sim/panel/path",
                                     "Panels/Default/default.xml");
-    current_panel = fgReadPanel(panel_path);
-    if (current_panel == 0) {
+
+    globals->set_current_panel( fgReadPanel(panel_path) );
+    if (globals->get_current_panel() == 0) {
         SG_LOG( SG_INPUT, SG_ALERT, 
                 "Error reading new panel from " << panel_path );
     } else {
         SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
-        current_panel->init();
-        current_panel->bind();
+        globals->get_current_panel()->init();
+        globals->get_current_panel()->bind();
     }
 
     
index a84d838352f51ae31ee8deb81982c0ff4efbc12c..2b64fcdb8286740266ae34c7f13b242d4448796c 100644 (file)
@@ -72,6 +72,7 @@ class FGScenery;
 class FGMultiplayRxMgr;
 class FGMultiplayTxMgr;
 #endif
+class FGPanel;
 class FGSoundMgr;
 class FGTextureLoader;
 class FGTileMgr;
@@ -126,6 +127,9 @@ private:
     // Global autopilot "route"
     SGRoute *route;
 
+    // 2D panel
+    FGPanel *current_panel;
+
     // sound manager
     FGSoundMgr *soundmgr;
 
@@ -253,6 +257,9 @@ public:
     inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
     inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; }
 
+    inline FGPanel *get_current_panel() const { return current_panel; }
+    inline void set_current_panel( FGPanel *cp ) { current_panel = cp; }
+
     inline FGSoundMgr *get_soundmgr() const { return soundmgr; }
     inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }
 
index 9f3ca07c2aa672b9a759ca3ef02b548e5017f761..7cf2a67f853854dca3c6487baf2e014ded087f18 100644 (file)
@@ -377,7 +377,7 @@ void trRenderFrame( void ) {
     if ( fgPanelVisible() ) {
         GLfloat height = fgGetInt("/sim/startup/ysize");
         GLfloat view_h =
-            (current_panel->getViewHeight() - current_panel->getYOffset())
+            (globals->get_current_panel()->getViewHeight() - globals->get_current_panel()->getYOffset())
             * (height / 768.0) + 1;
         glTranslatef( 0.0, view_h, 0.0 );
     }
@@ -898,8 +898,8 @@ void fgRenderFrame() {
        globals->get_ATC_display()->update(delta_time_sec);
 
        // update the panel subsystem
-       if ( current_panel != NULL ) {
-           current_panel->update(delta_time_sec);
+       if ( globals->get_current_panel() != NULL ) {
+           globals->get_current_panel()->update(delta_time_sec);
        }
         fgUpdate3DPanels();
 
@@ -1403,8 +1403,8 @@ void fgReshape( int width, int height ) {
 
     if ( (!fgGetBool("/sim/virtual-cockpit"))
         && fgPanelVisible() && idle_state == 1000 ) {
-       view_h = (int)(height * (current_panel->getViewHeight() -
-                                current_panel->getYOffset()) / 768.0);
+       view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
+                                globals->get_current_panel()->getYOffset()) / 768.0);
     } else {
        view_h = height;
     }