#include <plib/fnt.h>
#include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgpath.hxx>
-#include <Main/options.hxx>
-#include <Main/views.hxx>
+#include <simgear/misc/sg_path.hxx>
+
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
#include <Objects/texload.h>
+#include <Time/light.hxx>
#include "hud.hxx"
#include "panel.hxx"
+bool
+fgPanelVisible ()
+{
+ return ((current_panel != 0) &&
+ (current_panel->getVisibility()) &&
+ (globals->get_viewmgr()->get_current() == 0) &&
+ (globals->get_current_view()->get_view_offset() == 0.0));
+}
+
+
\f
////////////////////////////////////////////////////////////////////////
// Implementation of FGTextureManager.
ssgTexture * texture = _textureMap[relativePath];
if (texture == 0) {
cerr << "Texture " << relativePath << " does not yet exist" << endl;
- FGPath tpath(current_options.get_fg_root());
+ SGPath tpath(globals->get_fg_root());
tpath.append(relativePath);
texture = new ssgTexture((char *)tpath.c_str(), false, false);
_textureMap[relativePath] = texture;
_width(_winw), _height(int(_winh * 0.5768 + 1)),
_x_offset(0), _y_offset(0), _view_height(int(_winh * 0.4232))
{
- setVisibility(current_options.get_panel_status());
+ setVisibility(fgPanelVisible());
}
*/
FGPanel::~FGPanel ()
{
+ unbind();
for (instrument_list_type::iterator it = _instruments.begin();
it != _instruments.end();
it++) {
}
+/**
+ * Initialize the panel.
+ */
+void
+FGPanel::init ()
+{
+ // NO-OP
+}
+
+
+/**
+ * Bind panel properties.
+ */
+void
+FGPanel::bind ()
+{
+ fgTie("/sim/panel/visibility", &_visibility);
+ fgTie("/sim/panel/x-offset", &_x_offset);
+ fgTie("/sim/panel/y-offset", &_y_offset);
+}
+
+
+/**
+ * Unbind panel properties.
+ */
+void
+FGPanel::unbind ()
+{
+ fgUntie("/sim/panel/visibility");
+ fgUntie("/sim/panel/x-offset");
+ fgUntie("/sim/panel/y-offset");
+}
+
+
/**
* Update the panel.
*/
void
-FGPanel::update () const
+FGPanel::update ()
{
// Do nothing if the panel isn't visible.
- if (!_visibility)
+ if (!fgPanelVisible())
return;
// If the mouse is down, do something
glEnable(GL_ALPHA_TEST);
glEnable(GL_COLOR_MATERIAL);
// glColor4f(1.0, 1.0, 1.0, 1.0);
- if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+ if ( cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES < 95.0 ) {
glColor4fv( cur_light_params.scene_diffuse );
} else {
glColor4f(0.7, 0.2, 0.2, 1.0);
}
// Scale for the real window size.
- x = int(((float)x / current_view.get_winWidth()) * _winw);
- y = int(_winh - (((float)y / current_view.get_winHeight()) * _winh));
+ x = int(((float)x / fgGetInt("/sim/startup/xsize")) * _winw);
+ y = int(_winh - (((float)y / fgGetInt("/sim/startup/ysize"))
+ * _winh));
// Adjust for offsets.
x -= _x_offset;
////////////////////////////////////////////////////////////////////////
FGPanelTransformation::FGPanelTransformation ()
+ : table(0)
{
}
} else if (val > t->max) {
val = t->max;
}
- val = val * t->factor + t->offset;
+ if(t->table==0) {
+ val = val * t->factor + t->offset;
+ } else {
+ val = t->table->interpolate(val) * t->factor + t->offset;
+ }
switch (t->type) {
case FGPanelTransformation::XSHIFT:
// From Curt: turn on the panel
// lights after sundown.
- if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+ if ( cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES < 95.0 ) {
glColor4fv( cur_light_params.scene_diffuse );
} else {
glColor4f(0.7, 0.2, 0.2, 1.0);