From: ehofman Date: Sun, 30 Mar 2003 12:46:08 +0000 (+0000) Subject: Move current_panel to globals X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4b6242610975228a8471c5221d7cffe0069b5eea;p=flightgear.git Move current_panel to globals --- diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 965d8c04d..1be381486 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -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; diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index e802c1d62..9793cdcc8 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -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); diff --git a/src/GUI/mouse.cxx b/src/GUI/mouse.cxx index d33f8da39..4f63d7c4f 100644 --- a/src/GUI/mouse.cxx +++ b/src/GUI/mouse.cxx @@ -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); } } } diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 999cf1278..5483fd11b 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -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; diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index a56a21ef9..8218dfa3d 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -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"), diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 34d1345c0..04f8ca1cb 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -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(); } diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index a84d83835..2b64fcdb8 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -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; } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 9f3ca07c2..7cf2a67f8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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; }