1998-07-03 13:16:27 +00:00
|
|
|
|
|
|
|
#include "hud.hxx"
|
|
|
|
|
2000-02-15 03:30:01 +00:00
|
|
|
|
1998-07-13 21:00:45 +00:00
|
|
|
UINT instr_item :: instances = 0; // Initial value of zero
|
2006-06-07 21:35:11 +00:00
|
|
|
int instr_item :: brightness = 5;/*HUD_BRT_MEDIUM*/
|
2001-09-19 22:23:25 +00:00
|
|
|
//glRGBTRIPLE instr_item :: color = {0.1, 0.7, 0.0};
|
|
|
|
glRGBTRIPLE instr_item :: color = {0.0, 1.0, 0.0};
|
1998-07-03 13:16:27 +00:00
|
|
|
|
|
|
|
// constructor ( No default provided )
|
2006-06-14 10:30:10 +00:00
|
|
|
instr_item::instr_item(
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
UINT width,
|
|
|
|
UINT height,
|
|
|
|
FLTFNPTR data_source,
|
|
|
|
float data_scaling,
|
|
|
|
UINT options,
|
|
|
|
bool working,
|
|
|
|
int digit) :
|
|
|
|
handle ( ++instances ),
|
|
|
|
load_value_fn ( data_source ),
|
|
|
|
disp_factor ( data_scaling ),
|
|
|
|
opts ( options ),
|
|
|
|
is_enabled ( working ),
|
|
|
|
broken ( FALSE ),
|
|
|
|
digits ( digit )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 10:30:10 +00:00
|
|
|
scrn_pos.left = x;
|
|
|
|
scrn_pos.top = y;
|
|
|
|
scrn_pos.right = width;
|
|
|
|
scrn_pos.bottom = height;
|
|
|
|
|
|
|
|
// Set up convenience values for centroid of the box and
|
|
|
|
// the span values according to orientation
|
|
|
|
|
|
|
|
if (opts & HUDS_VERT) { // Vertical style
|
|
|
|
// Insure that the midpoint marker will fall exactly at the
|
|
|
|
// middle of the bar.
|
|
|
|
if (!(scrn_pos.bottom % 2))
|
|
|
|
scrn_pos.bottom++;
|
|
|
|
|
|
|
|
scr_span = scrn_pos.bottom;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// Insure that the midpoint marker will fall exactly at the
|
|
|
|
// middle of the bar.
|
|
|
|
if (!(scrn_pos.right % 2))
|
|
|
|
scrn_pos.right++;
|
|
|
|
|
|
|
|
scr_span = scrn_pos.right;
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
2006-06-14 10:30:10 +00:00
|
|
|
|
|
|
|
// Here we work out the centroid for the corrected box.
|
|
|
|
mid_span.x = scrn_pos.left + (scrn_pos.right >> 1);
|
|
|
|
mid_span.y = scrn_pos.top + (scrn_pos.bottom >> 1);
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// copy constructor
|
2006-06-14 10:30:10 +00:00
|
|
|
instr_item::instr_item( const instr_item & image ) :
|
|
|
|
handle ( ++instances ),
|
|
|
|
scrn_pos ( image.scrn_pos ),
|
|
|
|
load_value_fn( image.load_value_fn),
|
|
|
|
disp_factor ( image.disp_factor ),
|
|
|
|
opts ( image.opts ),
|
|
|
|
is_enabled ( image.is_enabled ),
|
|
|
|
broken ( image.broken ),
|
|
|
|
scr_span ( image.scr_span ),
|
|
|
|
mid_span ( image.mid_span )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
instr_item::~instr_item ()
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 10:30:10 +00:00
|
|
|
if (instances)
|
|
|
|
instances--;
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
|
|
|
|
void instr_item::update( void )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// break_display This is emplaced to provide hooks for making
|
|
|
|
// instruments unreliable. The default behavior is
|
|
|
|
// to simply not display, but more sophisticated behavior is available
|
|
|
|
// by over riding the function which is virtual in this class.
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
void instr_item::break_display ( bool bad )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 10:30:10 +00:00
|
|
|
broken = !!bad;
|
|
|
|
is_enabled = FALSE;
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
|
|
|
|
void instr_item::SetBrightness ( int level )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 10:30:10 +00:00
|
|
|
brightness = level; // This is all we will do for now. Later the
|
|
|
|
// brightness levels will be sensitive both to
|
|
|
|
// the control knob and the outside light levels
|
|
|
|
// to emulated night vision effects.
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
|
|
|
|
UINT instr_item::get_Handle( void )
|
1998-07-03 13:16:27 +00:00
|
|
|
{
|
2006-06-14 10:30:10 +00:00
|
|
|
return handle;
|
1998-07-03 13:16:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-14 10:30:10 +00:00
|
|
|
|