Move current_panel to globals
This commit is contained in:
parent
68522eb75c
commit
4b62426109
8 changed files with 40 additions and 27 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue