1
0
Fork 0

Move current_panel to globals

This commit is contained in:
ehofman 2003-03-30 12:46:08 +00:00
parent 68522eb75c
commit 4b62426109
8 changed files with 40 additions and 27 deletions

View file

@ -80,9 +80,9 @@ get_aspect_adjust (int xsize, int ysize)
bool bool
fgPanelVisible () fgPanelVisible ()
{ {
if(current_panel == 0) if(globals->get_current_panel() == 0)
return false; return false;
if(current_panel->getVisibility() == 0) if(globals->get_current_panel()->getVisibility() == 0)
return false; return false;
if(globals->get_viewmgr()->get_current() != 0) if(globals->get_viewmgr()->get_current() != 0)
return false; return false;
@ -163,7 +163,6 @@ FGCroppedTexture::getTexture ()
// Implementation of FGPanel. // Implementation of FGPanel.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
FGPanel * current_panel = NULL;
static fntRenderer text_renderer; static fntRenderer text_renderer;
static fntTexFont *default_font = 0; static fntTexFont *default_font = 0;
static fntTexFont *led_font = 0; static fntTexFont *led_font = 0;

View file

@ -693,8 +693,8 @@ void fgHiResDump()
GLfloat hud_row_step = 480.0 / nrows; GLfloat hud_row_step = 480.0 / nrows;
bool do_panel = fgPanelVisible(); bool do_panel = fgPanelVisible();
GLfloat panel_col_step = current_panel->getWidth() / ncols; GLfloat panel_col_step = globals->get_current_panel()->getWidth() / ncols;
GLfloat panel_row_step = current_panel->getHeight() / nrows; GLfloat panel_row_step = globals->get_current_panel()->getHeight() / nrows;
/* Draw tiles */ /* Draw tiles */
int more = 1; int more = 1;
@ -707,7 +707,8 @@ void fgHiResDump()
fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step, fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
(curColumn+1)*hud_col_step, (curRow+1)*hud_row_step ); (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
if (do_panel) 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 ); curRow*panel_row_step, panel_row_step );
more = trEndTile(tr); more = trEndTile(tr);

View file

@ -648,8 +648,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
// know what's going on. // know what's going on.
if (mouse_mode == MOUSE_POINTER) { if (mouse_mode == MOUSE_POINTER) {
if (!puMouse (button, updown, x,y)) { if (!puMouse (button, updown, x,y)) {
if ( current_panel != NULL ) { if ( globals->get_current_panel() != NULL ) {
current_panel->doMouseAction(button, updown, x, y); globals->get_current_panel()->doMouseAction(button, updown, x, y);
} }
} }
} }

View file

@ -341,9 +341,9 @@ FGInput::doMouseClick (int b, int updown, int x, int y)
if (mode.pass_through) { if (mode.pass_through) {
if (puMouse(b, updown, x, y)) if (puMouse(b, updown, x, y))
return; return;
else if ((current_panel != 0) && else if ((globals->get_current_panel() != 0) &&
current_panel->getVisibility() && globals->get_current_panel()->getVisibility() &&
current_panel->doMouseAction(b, updown, x, y)) globals->get_current_panel()->doMouseAction(b, updown, x, y))
return; return;
else if (fgHandle3DPanelMouseEvent(b, updown, x, y)) else if (fgHandle3DPanelMouseEvent(b, updown, x, y))
return; return;

View file

@ -324,10 +324,10 @@ do_panel_load (const SGPropertyNode * arg)
return false; return false;
} }
SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path); SG_LOG(SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path);
current_panel->unbind(); globals->get_current_panel()->unbind();
delete current_panel; delete globals->get_current_panel();
current_panel = new_panel; globals->set_current_panel( new_panel );
current_panel->bind(); globals->get_current_panel()->bind();
return true; return true;
} }
@ -343,8 +343,8 @@ do_panel_load (const SGPropertyNode * arg)
static bool static bool
do_panel_mouse_click (const SGPropertyNode * arg) do_panel_mouse_click (const SGPropertyNode * arg)
{ {
if (current_panel != 0) if (globals->get_current_panel() != 0)
return current_panel return globals->get_current_panel()
->doMouseAction(arg->getIntValue("button"), ->doMouseAction(arg->getIntValue("button"),
arg->getBoolValue("is-down") ? PU_DOWN : PU_UP, arg->getBoolValue("is-down") ? PU_DOWN : PU_UP,
arg->getIntValue("x-pos"), arg->getIntValue("x-pos"),

View file

@ -1529,6 +1529,7 @@ bool fgInitSubsystems() {
globals->get_AI_mgr()->init(); globals->get_AI_mgr()->init();
} }
#ifdef ENABLE_AUDIO_SUPPORT #ifdef ENABLE_AUDIO_SUPPORT
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialize the sound subsystem. // Initialize the sound subsystem.
@ -1593,17 +1594,22 @@ bool fgInitSubsystems() {
globals->get_io()->init(); globals->get_io()->init();
globals->get_io()->bind(); globals->get_io()->bind();
// Initialize the 2D panel.
////////////////////////////////////////////////////////////////////
// Add a new 2D panel.
////////////////////////////////////////////////////////////////////
string panel_path = fgGetString("/sim/panel/path", string panel_path = fgGetString("/sim/panel/path",
"Panels/Default/default.xml"); "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, SG_LOG( SG_INPUT, SG_ALERT,
"Error reading new panel from " << panel_path ); "Error reading new panel from " << panel_path );
} else { } else {
SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path ); SG_LOG( SG_INPUT, SG_INFO, "Loaded new panel from " << panel_path );
current_panel->init(); globals->get_current_panel()->init();
current_panel->bind(); globals->get_current_panel()->bind();
} }

View file

@ -72,6 +72,7 @@ class FGScenery;
class FGMultiplayRxMgr; class FGMultiplayRxMgr;
class FGMultiplayTxMgr; class FGMultiplayTxMgr;
#endif #endif
class FGPanel;
class FGSoundMgr; class FGSoundMgr;
class FGTextureLoader; class FGTextureLoader;
class FGTileMgr; class FGTileMgr;
@ -126,6 +127,9 @@ private:
// Global autopilot "route" // Global autopilot "route"
SGRoute *route; SGRoute *route;
// 2D panel
FGPanel *current_panel;
// sound manager // sound manager
FGSoundMgr *soundmgr; FGSoundMgr *soundmgr;
@ -253,6 +257,9 @@ public:
inline FGAIMgr *get_AI_mgr() const { return AI_mgr; } inline FGAIMgr *get_AI_mgr() const { return AI_mgr; }
inline void set_AI_mgr( FGAIMgr *a ) {AI_mgr = a; } 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 FGSoundMgr *get_soundmgr() const { return soundmgr; }
inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; } inline void set_soundmgr( FGSoundMgr *sm ) { soundmgr = sm; }

View file

@ -377,7 +377,7 @@ void trRenderFrame( void ) {
if ( fgPanelVisible() ) { if ( fgPanelVisible() ) {
GLfloat height = fgGetInt("/sim/startup/ysize"); GLfloat height = fgGetInt("/sim/startup/ysize");
GLfloat view_h = GLfloat view_h =
(current_panel->getViewHeight() - current_panel->getYOffset()) (globals->get_current_panel()->getViewHeight() - globals->get_current_panel()->getYOffset())
* (height / 768.0) + 1; * (height / 768.0) + 1;
glTranslatef( 0.0, view_h, 0.0 ); glTranslatef( 0.0, view_h, 0.0 );
} }
@ -898,8 +898,8 @@ void fgRenderFrame() {
globals->get_ATC_display()->update(delta_time_sec); globals->get_ATC_display()->update(delta_time_sec);
// update the panel subsystem // update the panel subsystem
if ( current_panel != NULL ) { if ( globals->get_current_panel() != NULL ) {
current_panel->update(delta_time_sec); globals->get_current_panel()->update(delta_time_sec);
} }
fgUpdate3DPanels(); fgUpdate3DPanels();
@ -1403,8 +1403,8 @@ void fgReshape( int width, int height ) {
if ( (!fgGetBool("/sim/virtual-cockpit")) if ( (!fgGetBool("/sim/virtual-cockpit"))
&& fgPanelVisible() && idle_state == 1000 ) { && fgPanelVisible() && idle_state == 1000 ) {
view_h = (int)(height * (current_panel->getViewHeight() - view_h = (int)(height * (globals->get_current_panel()->getViewHeight() -
current_panel->getYOffset()) / 768.0); globals->get_current_panel()->getYOffset()) / 768.0);
} else { } else {
view_h = height; view_h = height;
} }