1
0
Fork 0

GUI updates contributed by Norman Vine.

This commit is contained in:
curt 1999-06-01 21:17:10 +00:00
parent 84468dddea
commit 70505137eb
13 changed files with 1425 additions and 1440 deletions

View file

@ -32,12 +32,10 @@
#include "autopilot.hxx" #include "autopilot.hxx"
#include <GUI/gui.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Cockpit/panel.hxx>
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <Main/options.hxx> #include <Main/options.hxx>
#include <Main/views.hxx> #include <GUI/gui.h>
// The below routines were copied right from hud.c ( I hate reinventing // The below routines were copied right from hud.c ( I hate reinventing
@ -103,7 +101,7 @@ static double fgAPget_agl( void )
// Local Prototype section // Local Prototype section
double LinearExtrapolate( double x,double x1, double y1, double x2, double y2); double LinearExtrapolate( double x, double x1, double y1, double x2, double y2);
double NormalizeDegrees( double Input); double NormalizeDegrees( double Input);
// End Local ProtoTypes // End Local ProtoTypes
@ -155,8 +153,7 @@ bool fgAPAutoThrottleEnabled( void )
void fgAPAltitudeAdjust( double inc ) void fgAPAltitudeAdjust( double inc )
{ {
// Remove at a later date // Remove at a later date
fgAPDataPtr APData; fgAPDataPtr APData = APDataGlobal;
APData = APDataGlobal;
// end section // end section
double target_alt, target_agl; double target_alt, target_agl;
@ -181,6 +178,21 @@ void fgAPAltitudeAdjust( double inc )
APData->TargetAGL = target_agl; APData->TargetAGL = target_agl;
} }
void fgAPAltitudeSet( double new_altitude ) {
// Remove at a later date
fgAPDataPtr APData = APDataGlobal;
// end section
double target_alt = new_altitude;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET )
target_alt = new_altitude * FEET_TO_METER;
if( target_alt < scenery.cur_elev )
target_alt = scenery.cur_elev;
APData->TargetAltitude = target_alt;
}
void fgAPHeadingAdjust( double inc ) void fgAPHeadingAdjust( double inc )
{ {
fgAPDataPtr APData; fgAPDataPtr APData;
@ -191,6 +203,13 @@ void fgAPHeadingAdjust( double inc )
APData->TargetHeading = NormalizeDegrees(target); APData->TargetHeading = NormalizeDegrees(target);
} }
void fgAPHeadingSet( double new_heading ) {
fgAPDataPtr APData = APDataGlobal;
new_heading = NormalizeDegrees( new_heading );
APData->TargetHeading = new_heading;
}
void fgAPAutoThrottleAdjust( double inc ) void fgAPAutoThrottleAdjust( double inc )
{ {
fgAPDataPtr APData; fgAPDataPtr APData;
@ -203,6 +222,8 @@ void fgAPAutoThrottleAdjust( double inc )
void fgAPReset(void) void fgAPReset(void)
{ {
fgAPDataPtr APData = APDataGlobal;
if( fgAPTerrainFollowEnabled() ) if( fgAPTerrainFollowEnabled() )
fgAPToggleTerrainFollow( ); fgAPToggleTerrainFollow( );
@ -214,6 +235,10 @@ void fgAPReset(void)
if( fgAPAutoThrottleEnabled() ) if( fgAPAutoThrottleEnabled() )
fgAPToggleAutoThrottle(); fgAPToggleAutoThrottle();
APData->TargetHeading = 0.0; // default direction, due north
APData->TargetAltitude = 3000; // default altitude in meters
APData->alt_error_accum = 0.0;
} }
#define mySlider puSlider #define mySlider puSlider
@ -242,9 +267,6 @@ static puText *APAdjustDialogMessage;
static puFont APAdjustLegendFont; static puFont APAdjustLegendFont;
static puFont APAdjustLabelFont; static puFont APAdjustLabelFont;
static int DialogX = 40;
static int DialogY = 100;
static puOneShot *APAdjustOkButton; static puOneShot *APAdjustOkButton;
static puOneShot *APAdjustResetButton; static puOneShot *APAdjustResetButton;
static puOneShot *APAdjustCancelButton; static puOneShot *APAdjustCancelButton;
@ -268,6 +290,209 @@ static mySlider *APAdjustHS3;
static char SliderText[4][8]; static char SliderText[4][8];
// THIS NEEDS IMPROVEMENT !!!!!!!!!!!!!
static int scan_number(char *s, double *new_value)
{
int ret = 0;
char WordBuf[64];
char *cptr = s;
char *WordBufPtr = WordBuf;
if (*cptr == '+')
cptr++;
if (*cptr == '-') {
*WordBufPtr++ = *cptr++;
}
while (isdigit(*cptr) ) {
*WordBufPtr++ = *cptr++;
ret = 1;
}
if (*cptr == '.')
*WordBufPtr++ = *cptr++; // put the '.' into the string
while (isdigit(*cptr)) {
*WordBufPtr++ = *cptr++;
ret = 1;
}
if( ret == 1 ) {
*WordBufPtr = '\0';
sscanf(WordBuf, "%lf", new_value);
}
return(ret);
} // scan_number
///////// AutoPilot New Heading Dialog
static puDialogBox *ApHeadingDialog;
static puFrame *ApHeadingDialogFrame;
static puText *ApHeadingDialogMessage;
static puInput *ApHeadingDialogInput;
static puOneShot *ApHeadingDialogOkButton;
static puOneShot *ApHeadingDialogCancelButton;
void ApHeadingDialog_Cancel(puObject *)
{
ApHeadingDialogInput->rejectInput();
FG_POP_PUI_DIALOG( ApHeadingDialog );
}
void ApHeadingDialog_OK (puObject *me)
{
int error = 0;
char *c;
string s;
ApHeadingDialogInput -> getValue( &c );
if( strlen(c) ) {
double NewHeading;
if( scan_number( c, &NewHeading ) )
{
if(!fgAPHeadingEnabled())
fgAPToggleHeading();
fgAPHeadingSet( NewHeading );
} else {
error = 1;
s = c;
s += " is not a valid number.";
}
}
ApHeadingDialog_Cancel(me);
if( error ) mkDialog(s.c_str());
}
void NewHeading(puObject *cb)
{
// string ApHeadingLabel( "Enter New Heading" );
// ApHeadingDialogMessage -> setLabel(ApHeadingLabel.c_str());
ApHeadingDialogInput -> acceptInput();
FG_PUSH_PUI_DIALOG( ApHeadingDialog );
}
void NewHeadingInit(void)
{
// printf("NewHeadingInit\n");
char NewHeadingLabel[] = "Enter New Heading";
char *s;
float heading = fgAPget_heading();
int len = 260/2 -
(puGetStringWidth( puGetDefaultLabelFont(), NewHeadingLabel ) /2 );
ApHeadingDialog = new puDialogBox (150, 50);
{
ApHeadingDialogFrame = new puFrame (0, 0, 260, 150);
ApHeadingDialogMessage = new puText (len, 110);
ApHeadingDialogMessage -> setDefaultValue (NewHeadingLabel);
ApHeadingDialogMessage -> getDefaultValue (&s);
ApHeadingDialogMessage -> setLabel (s);
ApHeadingDialogInput = new puInput ( 50, 70, 210, 100 );
ApHeadingDialogInput -> setValue ( heading );
ApHeadingDialogOkButton = new puOneShot (50, 10, 110, 50);
ApHeadingDialogOkButton -> setLegend (gui_msg_OK);
ApHeadingDialogOkButton -> makeReturnDefault (TRUE);
ApHeadingDialogOkButton -> setCallback (ApHeadingDialog_OK);
ApHeadingDialogCancelButton = new puOneShot (140, 10, 210, 50);
ApHeadingDialogCancelButton -> setLegend (gui_msg_CANCEL);
ApHeadingDialogCancelButton -> setCallback (ApHeadingDialog_Cancel);
}
FG_FINALIZE_PUI_DIALOG( ApHeadingDialog );
}
///////// AutoPilot New Altitude Dialog
static puDialogBox *ApAltitudeDialog = 0;
static puFrame *ApAltitudeDialogFrame = 0;
static puText *ApAltitudeDialogMessage = 0;
static puInput *ApAltitudeDialogInput = 0;
static puOneShot *ApAltitudeDialogOkButton = 0;
static puOneShot *ApAltitudeDialogCancelButton = 0;
void ApAltitudeDialog_Cancel(puObject *)
{
ApAltitudeDialogInput -> rejectInput();
FG_POP_PUI_DIALOG( ApAltitudeDialog );
}
void ApAltitudeDialog_OK (puObject *me)
{
int error = 0;
string s;
char *c;
ApAltitudeDialogInput->getValue( &c );
if( strlen( c ) ) {
double NewAltitude;
if( scan_number( c, &NewAltitude) )
{
if(!(fgAPAltitudeEnabled()))
fgAPToggleAltitude();
fgAPAltitudeSet( NewAltitude );
} else {
error = 1;
s = c;
s += " is not a valid number.";
}
}
ApAltitudeDialog_Cancel(me);
if( error ) mkDialog(s.c_str());
}
void NewAltitude(puObject *cb)
{
ApAltitudeDialogInput -> acceptInput();
FG_PUSH_PUI_DIALOG( ApAltitudeDialog );
}
void NewAltitudeInit(void)
{
// printf("NewAltitudeInit\n");
char NewAltitudeLabel[] = "Enter New Altitude";
char *s;
float alt = current_aircraft.fdm_state->get_Altitude();
int len = 260/2 -
(puGetStringWidth( puGetDefaultLabelFont(), NewAltitudeLabel )/2);
ApAltitudeDialog = new puDialogBox (150, 50);
{
ApAltitudeDialogFrame = new puFrame (0, 0, 260, 150);
ApAltitudeDialogMessage = new puText (len, 110);
ApAltitudeDialogMessage -> setDefaultValue (NewAltitudeLabel);
ApAltitudeDialogMessage -> getDefaultValue (&s);
ApAltitudeDialogMessage -> setLabel (s);
ApAltitudeDialogInput = new puInput ( 50, 70, 210, 100 );
ApAltitudeDialogInput -> setValue ( alt );
// Uncomment the next line to have input active on startup
// ApAltitudeDialogInput -> acceptInput ( );
// cursor at begining or end of line ?
//len = strlen(s);
// len = 0;
// ApAltitudeDialogInput -> setCursor ( len );
// ApAltitudeDialogInput -> setSelectRegion ( 5, 9 );
ApAltitudeDialogOkButton = new puOneShot (50, 10, 110, 50);
ApAltitudeDialogOkButton -> setLegend (gui_msg_OK);
ApAltitudeDialogOkButton -> makeReturnDefault (TRUE);
ApAltitudeDialogOkButton -> setCallback (ApAltitudeDialog_OK);
ApAltitudeDialogCancelButton = new puOneShot (140, 10, 210, 50);
ApAltitudeDialogCancelButton -> setLegend (gui_msg_CANCEL);
ApAltitudeDialogCancelButton -> setCallback (ApAltitudeDialog_Cancel);
}
FG_FINALIZE_PUI_DIALOG( ApAltitudeDialog );
}
/////// simple AutoPilot GAIN / LIMITS ADJUSTER
#define fgAP_CLAMP(val,min,max) \ #define fgAP_CLAMP(val,min,max) \
( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) ) ( (val) = (val) > (max) ? (max) : (val) < (min) ? (min) : (val) )
@ -331,21 +556,10 @@ static void rolloutsmooth_adj( puObject *hs )
static void goAwayAPAdjust (puObject *) static void goAwayAPAdjust (puObject *)
{ {
FGView *v = &current_view; FG_POP_PUI_DIALOG( APAdjustDialog );
puPopLiveInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
if ( current_options.get_panel_status() ) {
// this seems to be the only way to do this :-(
// problem is the viewport has been mucked with
// current_options.toggle_panel();
// current_options.toggle_panel();
xglViewport(0, 0, (GLint)(v->winWidth), (GLint)(v->winHeight) );
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
}
} }
void cancelAPAdjust(puObject *) void cancelAPAdjust(puObject *self)
{ {
fgAPDataPtr APData = APDataGlobal; fgAPDataPtr APData = APDataGlobal;
@ -354,12 +568,7 @@ void cancelAPAdjust(puObject *)
APData->MaxAileron = TmpMaxAileronValue; APData->MaxAileron = TmpMaxAileronValue;
APData->RollOutSmooth = TmpRollOutSmoothValue; APData->RollOutSmooth = TmpRollOutSmoothValue;
puPopLiveInterface ( ) ; goAwayAPAdjust(self);
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
} }
void resetAPAdjust(puObject *self) void resetAPAdjust(puObject *self)
@ -371,12 +580,9 @@ void resetAPAdjust(puObject *self)
APData->MaxAileron = MaxAileronAdjust / 2; APData->MaxAileron = MaxAileronAdjust / 2;
APData->RollOutSmooth = RollOutSmoothAdjust / 2; APData->RollOutSmooth = RollOutSmoothAdjust / 2;
puPopLiveInterface ( ) ; FG_POP_PUI_DIALOG( APAdjustDialog );
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide(); fgAPAdjust( self );
fgAPAdjust(self);
} }
void fgAPAdjust( puObject * ) void fgAPAdjust( puObject * )
@ -398,179 +604,139 @@ void fgAPAdjust( puObject * )
APAdjustHS2 -> setValue ( RollOutSmoothValue ) ; APAdjustHS2 -> setValue ( RollOutSmoothValue ) ;
APAdjustHS3 -> setValue ( MaxAileronValue ) ; APAdjustHS3 -> setValue ( MaxAileronValue ) ;
// puPushInterface ( APAdjustDialog ) ; FG_PUSH_PUI_DIALOG( APAdjustDialog );
puPushGroup ( APAdjustDialog ) ;
puPushLiveInterface ( APAdjustDialog ) ;
APAdjustDialog -> reveal();
} }
#ifdef NOT_USED
void dragAPAdjust(puObject *self)
{
return;
int LastX, LastY;
int DeltaX, DeltaY, X, Y;
int button, count;
// button = guiGetMouseButton();
guiGetMouse(&LastX, &LastY);
button = 0;
printf("button %d LastX %d LastY %d\n", button, LastX, LastY);
// count = 0;
// while( guiGetMouseButton() == button )
for(count=0;count<1000;count++)
{
guiGetMouse(&X, &Y);
printf(" X %d Y %d\n", X, Y);
}
DeltaX = X - LastX;
DeltaY = Y - LastY;
// LiveInterface is Dialog Box
puInterface *Interface = puGetBaseLiveInterface();
puObject *dlist = Interface->getFirstChild() ;
// printf("%s %p %s %p\n",
// Interface->getTypeString(), Interface, dlist->getTypeString(), dlist);
Interface -> getPosition ( &X, &Y ) ;
Interface -> setPosition ( X + DeltaX, Y + DeltaY ) ;
// Interface -> recalc_bbox();
for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
{
bo -> getPosition ( &X, &Y ) ;
bo -> setPosition ( X + DeltaX, Y + DeltaY ) ;
bo -> recalc_bbox();
// printf("%s %p X %d Y %d\n", bo->getTypeString(), bo, X, Y);
}
Interface->recalc_bbox();
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
APAdjustDialog -> hide();
fgAPAdjust(dlist);
}
#endif // NOT_USED
// Done once at system initialization // Done once at system initialization
void fgAPAdjustInit( void ) // Done once at system initialization
{ void fgAPAdjustInit( void ) {
// printf("fgAPAdjustInit\n");
#define HORIZONTAL FALSE #define HORIZONTAL FALSE
int DialogX = 40;
int DialogY = 100;
int DialogWidth = 230;
char Label[] = "AutoPilot Adjust";
char *s;
fgAPDataPtr APData = APDataGlobal; fgAPDataPtr APData = APDataGlobal;
TmpMaxRollValue = APData->MaxRoll; int labelX = (DialogWidth / 2) -
TmpRollOutValue = APData->RollOut; (puGetStringWidth( puGetDefaultLabelFont(), Label ) / 2);
TmpMaxAileronValue = APData->MaxAileron; labelX -= 30; // KLUDGEY
TmpRollOutSmoothValue = APData->RollOutSmooth;
MaxRollValue = APData->MaxRoll / MaxRollAdjust; int nSliders = 4;
RollOutValue = APData->RollOut / RollOutAdjust; int slider_x = 10;
MaxAileronValue = APData->MaxAileron / MaxAileronAdjust; int slider_y = 55;
RollOutSmoothValue = APData->RollOutSmooth / RollOutSmoothAdjust; int slider_width = 210;
int slider_title_x = 15;
int slider_value_x = 160;
float slider_delta = 0.1f;
TmpMaxRollValue = APData-> MaxRoll;
TmpRollOutValue = APData-> RollOut;
TmpMaxAileronValue = APData-> MaxAileron;
TmpRollOutSmoothValue = APData-> RollOutSmooth;
MaxRollValue = APData-> MaxRoll / MaxRollAdjust;
RollOutValue = APData-> RollOut / RollOutAdjust;
MaxAileronValue = APData-> MaxAileron / MaxAileronAdjust;
RollOutSmoothValue = APData-> RollOutSmooth / RollOutSmoothAdjust;
puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont ); puGetDefaultFonts ( &APAdjustLegendFont, &APAdjustLabelFont );
APAdjustDialog = new puDialogBox (DialogX, DialogY); APAdjustDialog = new puDialogBox ( DialogX, DialogY ); {
{
int horiz_slider_height = puGetStringHeight (APAdjustLabelFont) + int horiz_slider_height = puGetStringHeight (APAdjustLabelFont) +
puGetStringDescender (APAdjustLabelFont) + puGetStringDescender (APAdjustLabelFont) +
PUSTR_TGAP + PUSTR_BGAP+5; PUSTR_TGAP + PUSTR_BGAP + 5;
APAdjustFrame = new puFrame (0,0,230, 85+4*horiz_slider_height); APAdjustFrame = new puFrame ( 0, 0,
DialogWidth, 85 + nSliders * horiz_slider_height );
APAdjustDialogMessage = new puText (40, 52 + 4*horiz_slider_height); APAdjustDialogMessage = new puText ( labelX, 52 + nSliders * horiz_slider_height );
APAdjustDialogMessage -> setLabel ("AutoPilot Adjust"); APAdjustDialogMessage -> setDefaultValue ( Label );
APAdjustDialogMessage -> getDefaultValue ( &s );
APAdjustDialogMessage -> setLabel ( s );
// APAdjustDragButton = new puButton (0, 75+4*horiz_slider_height, APAdjustHS0 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
// 230, 85+4*horiz_slider_height); APAdjustHS0-> setDelta ( slider_delta ) ;
// APAdjustDragButton -> setLegend ("*"); APAdjustHS0-> setValue ( MaxRollValue ) ;
// APAdjustDragButton -> setCallback (dragAPAdjust); APAdjustHS0-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS0-> setCallback ( maxroll_adj ) ;
int slider_y = 55; sprintf( SliderText[ 0 ], "%05.2f", APData->MaxRoll );
APAdjustHS0 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ; APAdjustMaxRollTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustHS0 -> setDelta ( 0.1 ) ; APAdjustMaxRollTitle-> setDefaultValue ( "MaxRoll" ) ;
APAdjustHS0 -> setValue ( MaxRollValue ) ; APAdjustMaxRollTitle-> getDefaultValue ( &s ) ;
APAdjustHS0 -> setCBMode ( PUSLIDER_DELTA ) ; APAdjustMaxRollTitle-> setLabel ( s ) ;
APAdjustHS0 -> setCallback ( maxroll_adj ) ; APAdjustMaxRollText = new puText ( slider_value_x, slider_y ) ;
APAdjustMaxRollText-> setLabel ( SliderText[ 0 ] ) ;
sprintf(SliderText[0],"%05.2f", APData->MaxRoll );
APAdjustMaxRollTitle = new puText ( 15, slider_y ) ;
APAdjustMaxRollTitle -> setLabel ( "MaxRoll" ) ;
APAdjustMaxRollText = new puText ( 160, slider_y ) ;
APAdjustMaxRollText -> setLabel ( SliderText[0] ) ;
slider_y += horiz_slider_height; slider_y += horiz_slider_height;
APAdjustHS1 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ; APAdjustHS1 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS1 -> setDelta ( 0.1 ) ; APAdjustHS1-> setDelta ( slider_delta ) ;
APAdjustHS1 -> setValue ( RollOutValue ) ; APAdjustHS1-> setValue ( RollOutValue ) ;
APAdjustHS1 -> setCBMode ( PUSLIDER_DELTA ) ; APAdjustHS1-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS1 -> setCallback ( rollout_adj ) ; APAdjustHS1-> setCallback ( rollout_adj ) ;
sprintf(SliderText[1],"%05.2f", APData->RollOut ); sprintf( SliderText[ 1 ], "%05.2f", APData->RollOut );
APAdjustRollOutTitle = new puText ( 15, slider_y ) ; APAdjustRollOutTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustRollOutTitle -> setLabel ( "AdjustRollOut" ) ; APAdjustRollOutTitle-> setDefaultValue ( "AdjustRollOut" ) ;
APAdjustRollOutText = new puText ( 160, slider_y ) ; APAdjustRollOutTitle-> getDefaultValue ( &s ) ;
APAdjustRollOutText -> setLabel ( SliderText[1] ); APAdjustRollOutTitle-> setLabel ( s ) ;
APAdjustRollOutText = new puText ( slider_value_x, slider_y ) ;
APAdjustRollOutText-> setLabel ( SliderText[ 1 ] );
slider_y += horiz_slider_height; slider_y += horiz_slider_height;
APAdjustHS2 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ; APAdjustHS2 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS2 -> setDelta ( 0.1 ) ; APAdjustHS2-> setDelta ( slider_delta ) ;
APAdjustHS2 -> setValue ( RollOutSmoothValue ) ; APAdjustHS2-> setValue ( RollOutSmoothValue ) ;
APAdjustHS2 -> setCBMode ( PUSLIDER_DELTA ) ; APAdjustHS2-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS2 -> setCallback ( rolloutsmooth_adj ) ; APAdjustHS2-> setCallback ( rolloutsmooth_adj ) ;
sprintf(SliderText[2],"%5.2f", APData->RollOutSmooth ); sprintf( SliderText[ 2 ], "%5.2f", APData->RollOutSmooth );
APAdjustRollOutSmoothTitle = new puText ( 15, slider_y ) ; APAdjustRollOutSmoothTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustRollOutSmoothTitle -> setLabel ( "RollOutSmooth" ) ; APAdjustRollOutSmoothTitle-> setDefaultValue ( "RollOutSmooth" ) ;
APAdjustRollOutSmoothText = new puText ( 160, slider_y ) ; APAdjustRollOutSmoothTitle-> getDefaultValue ( &s ) ;
APAdjustRollOutSmoothText -> setLabel ( SliderText[2] ); APAdjustRollOutSmoothTitle-> setLabel ( s ) ;
APAdjustRollOutSmoothText = new puText ( slider_value_x, slider_y ) ;
APAdjustRollOutSmoothText-> setLabel ( SliderText[ 2 ] );
slider_y += horiz_slider_height; slider_y += horiz_slider_height;
APAdjustHS3 = new mySlider ( 10, slider_y, 210, HORIZONTAL ) ; APAdjustHS3 = new mySlider ( slider_x, slider_y, slider_width, HORIZONTAL ) ;
APAdjustHS3 -> setDelta ( 0.1 ) ; APAdjustHS3-> setDelta ( slider_delta ) ;
APAdjustHS3 -> setValue ( MaxAileronValue ) ; APAdjustHS3-> setValue ( MaxAileronValue ) ;
APAdjustHS3 -> setCBMode ( PUSLIDER_DELTA ) ; APAdjustHS3-> setCBMode ( PUSLIDER_DELTA ) ;
APAdjustHS3 -> setCallback ( maxaileron_adj ) ; APAdjustHS3-> setCallback ( maxaileron_adj ) ;
sprintf(SliderText[3],"%05.2f", APData->MaxAileron ); sprintf( SliderText[ 3 ], "%05.2f", APData->MaxAileron );
APAdjustMaxAileronTitle = new puText ( 15, slider_y ) ; APAdjustMaxAileronTitle = new puText ( slider_title_x, slider_y ) ;
APAdjustMaxAileronTitle -> setLabel ( "MaxAileron" ) ; APAdjustMaxAileronTitle-> setDefaultValue ( "MaxAileron" ) ;
APAdjustMaxAileronText = new puText ( 160, slider_y ) ; APAdjustMaxAileronTitle-> getDefaultValue ( &s ) ;
APAdjustMaxAileronText -> setLabel ( SliderText[3] ); APAdjustMaxAileronTitle-> setLabel ( s ) ;
APAdjustMaxAileronText = new puText ( slider_value_x, slider_y ) ;
APAdjustMaxAileronText-> setLabel ( SliderText[ 3 ] );
APAdjustOkButton = new puOneShot (10, 10, 60, 50); APAdjustOkButton = new puOneShot ( 10, 10, 60, 50 );
APAdjustOkButton -> setLegend ("OK"); APAdjustOkButton-> setLegend ( gui_msg_OK );
APAdjustOkButton -> makeReturnDefault (TRUE ); APAdjustOkButton-> makeReturnDefault ( TRUE );
APAdjustOkButton -> setCallback (goAwayAPAdjust); APAdjustOkButton-> setCallback ( goAwayAPAdjust );
APAdjustCancelButton = new puOneShot (70, 10, 150, 50); APAdjustCancelButton = new puOneShot ( 70, 10, 150, 50 );
APAdjustCancelButton -> setLegend ("Cancel"); APAdjustCancelButton-> setLegend ( gui_msg_CANCEL );
APAdjustCancelButton -> makeReturnDefault (TRUE ); APAdjustCancelButton-> setCallback ( cancelAPAdjust );
APAdjustCancelButton -> setCallback (cancelAPAdjust);
APAdjustResetButton = new puOneShot (160, 10, 220, 50); APAdjustResetButton = new puOneShot ( 160, 10, 220, 50 );
APAdjustResetButton -> setLegend ("Reset"); APAdjustResetButton-> setLegend ( gui_msg_RESET );
APAdjustResetButton -> makeReturnDefault (TRUE ); APAdjustResetButton-> setCallback ( resetAPAdjust );
APAdjustResetButton -> setCallback (resetAPAdjust);
} }
APAdjustDialog -> close(); FG_FINALIZE_PUI_DIALOG( APAdjustDialog );
// APAdjustDialog -> reveal();
// Take it off the Stack
puPopLiveInterface ( ) ;
// puPopInterface ( ) ;
puPopGroup ( ) ;
#undef HORIZONTAL #undef HORIZONTAL
} }
@ -632,6 +798,8 @@ void fgAPInit( fgAIRCRAFT *current_aircraft )
#endif // !defined( USING_SLIDER_CLASS ) #endif // !defined( USING_SLIDER_CLASS )
fgAPAdjustInit( ) ; fgAPAdjustInit( ) ;
NewHeadingInit();
NewAltitudeInit();
}; };
int fgAPRun( void ) int fgAPRun( void )

View file

@ -38,7 +38,6 @@
#include <Aircraft/aircraft.hxx> #include <Aircraft/aircraft.hxx>
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <GUI/gui.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Include/general.hxx> #include <Include/general.hxx>
#include <Main/options.hxx> #include <Main/options.hxx>
@ -49,6 +48,7 @@
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx> #include <Time/fg_timer.hxx>
#include <Time/fg_time.hxx> #include <Time/fg_time.hxx>
#include <GUI/gui.h>
#include "cockpit.hxx" #include "cockpit.hxx"
@ -57,7 +57,11 @@
// cockpit/panel/hud system // cockpit/panel/hud system
static pCockpit ac_cockpit; static pCockpit ac_cockpit;
fntRenderer *HUDtext = 0;
float HUD_TextSize = 0;
int HUD_style = 0;
float HUD_matrix[16];
// The following routines obtain information concerntin the aircraft's // The following routines obtain information concerntin the aircraft's
// current state and return it to calling instrument display routines. // current state and return it to calling instrument display routines.
// They should eventually be member functions of the aircraft. // They should eventually be member functions of the aircraft.
@ -65,32 +69,19 @@ static pCockpit ac_cockpit;
float get_latitude( void ) float get_latitude( void )
{ {
// FGState *f;
double lat; double lat;
// current_aircraft.fdm_state
lat = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG; lat = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
float flat = lat; float flat = lat;
return(flat); return(flat);
// if(fabs(lat)<1.0)
// {
// if(lat<0)
// return( -(double)((int)lat) );
// else
// return( (double)((int)lat) );
// }
// return( (double)((int)lat) );
} }
float get_lat_min( void ) float get_lat_min( void )
{ {
// FGState *f;
double a, d; double a, d;
// current_aircraft.fdm_state
a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG; a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;
if (a < 0.0) { if (a < 0.0) {
a = -a; a = -a;
@ -104,23 +95,11 @@ float get_lat_min( void )
float get_longitude( void ) float get_longitude( void )
{ {
double lon; double lon;
// FGState *f;
// current_aircraft.fdm_state
lon = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG; lon = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
float flon = lon; float flon = lon;
return(flon); return(flon);
// if(fabs(lon)<1.0)
// {
// if(lon<0)
// return( -(double)((int)lon) );
// else
// return( (double)((int)lon) );
// }
// return( (double)((int)lon) );
} }
@ -139,11 +118,7 @@ get_formated_gmt_time( void )
float get_long_min( void ) float get_long_min( void )
{ {
// FGState *f;
double a, d; double a, d;
// current_aircraft.fdm_state
a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG; a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;
if (a < 0.0) { if (a < 0.0) {
a = -a; a = -a;
@ -234,10 +209,6 @@ float get_altitude( void )
float get_agl( void ) float get_agl( void )
{ {
// FGState *f;
// f = current_aircraft.fdm_state;
float agl; float agl;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
@ -252,11 +223,7 @@ float get_agl( void )
float get_sideslip( void ) float get_sideslip( void )
{ {
// FGState *f;
// f = current_aircraft.fdm_state;
float sideslip = current_aircraft.fdm_state->get_Beta(); float sideslip = current_aircraft.fdm_state->get_Beta();
return( sideslip ); return( sideslip );
} }
@ -292,10 +259,6 @@ float get_vfc_tris_culled ( void )
float get_climb_rate( void ) float get_climb_rate( void )
{ {
// FGState *f;
// current_aircraft.fdm_state
float climb_rate; float climb_rate;
if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) { if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0; climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
@ -308,22 +271,16 @@ float get_climb_rate( void )
float get_view_direction( void ) float get_view_direction( void )
{ {
// FGState *f;
// FGView *pview;
double view; double view;
// pview = &current_view;
// current_aircraft.fdm_state
view = FG_2PI - current_view.get_view_offset(); view = FG_2PI - current_view.get_view_offset();
view = ( current_aircraft.fdm_state->get_Psi() + view) * RAD_TO_DEG; view = ( current_aircraft.fdm_state->get_Psi() + view) * RAD_TO_DEG;
if(view > 360.) if(view > 360.)
view -= 360.; view -= 360.;
else if(view<0.) else if(view<0.)
view += 360.; view += 360.;
float fview = view; float fview = view;
return( fview ); return( fview );
} }
@ -352,7 +309,7 @@ char *dmshh_format(double degrees)
if (min_part >= 60) if (min_part >= 60)
min_part -= 60, deg_part += 1; min_part -= 60, deg_part += 1;
sprintf(buf,"%02d*%02d\'%05.2f\"",deg_part,min_part,sec_part); sprintf(buf,"%02d*%02d %05.2f",deg_part,min_part,sec_part);
return buf; return buf;
} }
@ -387,7 +344,7 @@ static char *toDMS(float a)
if (neg) if (neg)
d = -d; d = -d;
sprintf(dms, "%.0f*%02.0f'%04.1f\"", d, m, s); sprintf(dms, "%.0f*%02.0f %04.1f", d, m, s);
return dms; return dms;
} }
@ -415,10 +372,12 @@ static char *toDM(float a)
} }
if (neg) d = -d; if (neg) d = -d;
sprintf(dm, "%.0f*%06.3f'", d, m); sprintf(dm, "%.0f*%06.3f", d, m);
return dm; return dm;
} }
// Have to set the LatLon display type
//static char *(*fgLatLonFormat)(float) = toDM;
static char *(*fgLatLonFormat)(float); static char *(*fgLatLonFormat)(float);
char *coord_format_lat(float latitude) char *coord_format_lat(float latitude)
@ -473,105 +432,6 @@ char *coord_format_latlon(double latitude, double longitude)
} }
#endif #endif
#ifdef FAST_TEXT_TEST
#undef FAST_TEXT_TEST
#endif
#ifdef FAST_TEXT_TEST
static unsigned int first=0, last=128;
unsigned int font_base;
#define FONT "-adobe-courier-medium-r-normal--24-240-75-75-m-150-iso8859-1"
HFONT hFont;
void Font_Setup(void)
{
#ifdef _WIN32
int count;
HDC hdc;
HGLRC hglrc;
hdc = wglGetCurrentDC();
hglrc = wglGetCurrentContext();
if (hdc == 0 || hglrc == 0) {
printf("Could not get context or DC\n");
exit(1);
}
if (!wglMakeCurrent(hdc, hglrc)) {
printf("Could not make context current\n");
exit(1);
}
#define FONTBASE 0x1000
/*
hFont = GetStockObject(SYSTEM_FONT);
hFont = CreateFont(h, w, esc, orient, weight,
ital, under, strike, set, out, clip, qual, pitch/fam, face);
*/
hFont = CreateFont(30, 0, 0, 0, FW_NORMAL,
FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY,
FIXED_PITCH | FF_MODERN, "Arial");
if (!hFont) {
MessageBox(WindowFromDC(hdc),
"Failed to find acceptable bitmap font.",
"OpenGL Application Error",
MB_ICONERROR | MB_OK);
exit(1);
}
(void) SelectObject(hdc, hFont);
wglUseFontBitmaps(hdc, 0, 255, FONTBASE);
glListBase(FONTBASE);
#if 0
SelectObject (hdc, GetStockObject (SYSTEM_FONT));
count=last-first+1;
font_base = glGenLists(count);
wglUseFontBitmaps (hdc, first, last, font_base);
if (font_base == 0) {
printf("Could not generate Text_Setup list\n");
exit(1);
}
#endif // 0
#else
Display *Dpy;
XFontStruct *fontInfo;
Font id;
Dpy = XOpenDisplay(NULL);
fontInfo = XLoadQueryFont(Dpy, FONT);
if (fontInfo == NULL)
{
printf("Failed to load font %s\n", FONT);
exit(1);
}
id = fontInfo->fid;
first = fontInfo->min_char_or_byte2;
last = fontInfo->max_char_or_byte2;
base = glGenLists((GLuint) last+1);
if (base == 0) {
printf ("out of display lists\n");
exit (1);
}
glXUseXFont(id, first, last-first+1, base+first);
#endif
}
static void
drawString(char *string, GLfloat x, GLfloat y, GLfloat color[4])
{
glColor4fv(color);
glRasterPos2f(x, y);
glCallLists(strlen(string), GL_BYTE, (GLbyte *) string);
}
#endif // #ifdef FAST_TEXT_TEST
bool fgCockpitInit( fgAIRCRAFT *cur_aircraft ) bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
{ {
@ -589,10 +449,6 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
// HI_Head is now a null pointer so we can generate a new list from the // HI_Head is now a null pointer so we can generate a new list from the
// current aircraft. // current aircraft.
#ifdef FAST_TEXT_TEST
Font_Setup();
#endif // #ifdef FAST_TEXT_TEST
fgHUDInit( cur_aircraft ); fgHUDInit( cur_aircraft );
ac_cockpit = new fg_Cockpit(); ac_cockpit = new fg_Cockpit();
@ -607,19 +463,23 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
" Code " << ac_cockpit->code() << " Status " " Code " << ac_cockpit->code() << " Status "
<< ac_cockpit->status() ); << ac_cockpit->status() );
// HUD_TextSize = (current_options.get_xsize() > 1000) ? 10 : 8;
HUD_TextSize = 10;
HUDtext = new fntRenderer();
HUDtext -> setFont ( guiFntHandle ) ;
HUDtext -> setPointSize ( HUD_TextSize ) ;
HUD_TextList.setFont( HUDtext );
return true; return true;
} }
void fgCockpitUpdate( void ) { void fgCockpitUpdate( void ) {
#define DISPLAY_COUNTER int iwidth = current_view.get_winWidth();
#ifdef DISPLAY_COUNTER int iheight = current_view.get_winHeight();
static float lightCheck[4] = { 0.7F, 0.7F, 0.7F, 1.0F }; float width = iwidth;
char buf[64],*ptr; float height = iheight;
// int fontSize;
int c;
#endif
FG_LOG( FG_COCKPIT, FG_DEBUG, FG_LOG( FG_COCKPIT, FG_DEBUG,
"Cockpit: code " << ac_cockpit->code() << " status " "Cockpit: code " << ac_cockpit->code() << " status "
@ -630,22 +490,21 @@ void fgCockpitUpdate( void ) {
// If these is anything to draw it will. // If these is anything to draw it will.
fgUpdateHUD(); fgUpdateHUD();
} }
#define DISPLAY_COUNTER
#ifdef DISPLAY_COUNTER #ifdef DISPLAY_COUNTER
else else
{ {
char buf[64];
float fps = get_frame_rate(); float fps = get_frame_rate();
float tris = fps * get_vfc_tris_drawn(); // float tris = fps * get_vfc_tris_drawn();
float culled = fps * get_vfc_tris_culled(); // float culled = fps * get_vfc_tris_culled();
// sprintf(buf,"%-4.1f %7.0f %7.0f", fps, tris, culled);
sprintf(buf,"%-5.1f", fps);
int len = sprintf(buf," %4.1f %7.0f %7.0f",
fps, tris, culled);
// sprintf(buf,"Tris Per Sec: %7.0f", t);
// fontSize = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
gluOrtho2D(0, 1024, 0, 768); gluOrtho2D(0, width, 0, height);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
@ -653,33 +512,11 @@ void fgCockpitUpdate( void ) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
// glColor3f (.90, 0.27, 0.67); glColor3f (0.9, 0.4, 0.2);
#ifdef FAST_TEXT_TEST
drawString(buf, 250.0F, 10.0F, lightCheck);
// glRasterPos2f( 220, 10);
// for (int i=0; i < len; i++) {
// glCallList(font_base+buf[i]);
// }
#else
glColor3f (.8, 0.8, 0.8);
glTranslatef( 400, 10, 0);
glScalef(.1, .1, 0.0);
ptr = buf;
while ( ( c = *ptr++) ){
glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
}
#endif // #ifdef FAST_TEXT_TEST
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, ' ');
// ptr = get_formated_gmt_time();
// while ( ( c = *ptr++) ){
// glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
// }
guiFnt.drawString( buf,
width/2 - guiFnt.getStringWidth(buf)/2,
10 );
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@ -687,14 +524,13 @@ void fgCockpitUpdate( void ) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPopMatrix(); glPopMatrix();
} }
#endif // DISPLAY_COUNTER #endif // #ifdef DISPLAY_COUNTER
if ( current_options.get_panel_status() && if( current_options.get_panel_status() &&
(fabs( current_view.get_view_offset() ) < 0.2) ) (fabs( current_view.get_view_offset() ) < 0.2) )
{ {
xglViewport( 0, 0, xglViewport( 0, 0, iwidth, iheight );
current_view.get_winWidth(),
current_view.get_winHeight() );
FGPanel::OurPanel->Update(); FGPanel::OurPanel->Update();
} }
} }

View file

@ -69,14 +69,10 @@ static char units[5];
// //
deque< instr_item * > HUD_deque; deque< instr_item * > HUD_deque;
vector< fgLineSeg2D > HUD_LineList;
vector< fgLineSeg2D > HUD_StippleLineList;
#ifdef USE_HUD_TextList fgTextList HUD_TextList;
vector< fgTextString > HUD_TextList; fgLineList HUD_LineList;
#endif fgLineList HUD_StippleLineList;
//GLFONT *myFont;
class locRECT { class locRECT {
public: public:
@ -158,6 +154,17 @@ void strokeString(int x, int y, char *msg, void *font, float theta)
} }
} }
int getStringWidth ( char *str )
{
if ( HUDtext && str )
{
float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
return 0 ;
}
//========================= End of Class Implementations=================== //========================= End of Class Implementations===================
// fgHUDInit // fgHUDInit
// //
@ -187,11 +194,13 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
unsigned int ladr_w2 = 60; unsigned int ladr_w2 = 60;
int ladr_h2 = 90; int ladr_h2 = 90;
int ladr_t = 35; int ladr_t = 35;
// int compass_w2 = 100; int compass_w = 200;
int gap = 10; int gap = 10;
font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL; font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
HUD_style = 1;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" ); FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
// deque < instr_item * > :: iterator first = HUD_deque.begin(); // deque < instr_item * > :: iterator first = HUD_deque.begin();
@ -223,9 +232,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
HUD_deque.insert( HUD_deque.begin(), HIptr); HUD_deque.insert( HUD_deque.begin(), HIptr);
// case 4: // GYRO COMPASS // case 4: // GYRO COMPASS
HIptr = (instr_item *) new hud_card( cen_x-100, HIptr = (instr_item *) new hud_card( cen_x-(compass_w/2),
max_y, max_y,
200, compass_w,
28, 28,
get_heading, get_heading,
HUDS_TOP, HUDS_TOP,
@ -240,9 +249,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// case 5: // AMSL // case 5: // AMSL
HIptr = (instr_item *) new hud_card( max_x - 35 -15, // 15 to balance speed card HIptr = (instr_item *) new hud_card( max_x - 35 -15, // 15 to balance speed card
cen_y-100, cen_y-(compass_w/2),
35, 35,
200, compass_w,
get_altitude, get_altitude,
// HUDS_RIGHT | HUDS_VERT, // HUDS_RIGHT | HUDS_VERT,
HUDS_LEFT | HUDS_VERT, HUDS_LEFT | HUDS_VERT,
@ -309,9 +318,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// case 2: // KIAS // case 2: // KIAS
HIptr = (instr_item *) new hud_card( min_x +10 +5, //min_x +18, HIptr = (instr_item *) new hud_card( min_x +10 +5, //min_x +18,
cen_y-100, cen_y-(compass_w/2),
28, 28,
200, compass_w,
get_speed, get_speed,
// HUDS_LEFT | HUDS_VERT, // HUDS_LEFT | HUDS_VERT,
HUDS_RIGHT | HUDS_VERT, HUDS_RIGHT | HUDS_VERT,
@ -340,7 +349,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
// Remove this when below uncommented // Remove this when below uncommented
// case 10: // case 10:
HIptr = (instr_item *) new instr_label( 10, HIptr = (instr_item *) new instr_label( 10,
10, 25,
60, 60,
10, 10,
get_frame_rate, get_frame_rate,
@ -355,9 +364,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
TRUE ); TRUE );
HUD_deque.insert( HUD_deque.begin(), HIptr); HUD_deque.insert( HUD_deque.begin(), HIptr);
HIptr = (instr_item *) new lat_label( (cen_x -ladr_w2)/2, HIptr = (instr_item *) new lat_label( (cen_x - (compass_w/2))/2,
max_y, max_y,
60, 1,
text_h, text_h,
get_latitude, get_latitude,
"%s%", //"%.0f", "%s%", //"%.0f",
@ -371,11 +380,9 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
TRUE ); TRUE );
HUD_deque.insert( HUD_deque.begin(), HIptr); HUD_deque.insert( HUD_deque.begin(), HIptr);
HIptr = (instr_item *) new lon_label( HIptr = (instr_item *) new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
//(cen_x+ladr_x2) +((max_x-(cen_x+ladr_x2))/2),
(2*cen_x) - ((cen_x -ladr_w2)/2),
max_y, max_y,
60, text_h, 1, text_h,
get_longitude, get_longitude,
"%s%",//"%.0f", "%s%",//"%.0f",
"", //"Lon ", "", //"Lon ",
@ -644,11 +651,13 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
int ladr_w2 = 60; int ladr_w2 = 60;
// int ladr_h2 = 90; // int ladr_h2 = 90;
// int ladr_t = 35; // int ladr_t = 35;
// int compass_w2 = 100; int compass_w = 200;
// int gap = 10; // int gap = 10;
font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL; font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
HUD_style = 2;
FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" ); FG_LOG( FG_COCKPIT, FG_INFO, "Initializing current aircraft HUD" );
// deque < instr_item * > :: iterator first = HUD_deque.begin(); // deque < instr_item * > :: iterator first = HUD_deque.begin();
@ -672,9 +681,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
instr_item* p; instr_item* p;
// case 4: // GYRO COMPASS // case 4: // GYRO COMPASS
p =new hud_card( cen_x-100, p =new hud_card( cen_x-(compass_w/2),
max_y, max_y,
200, compass_w,
28, 28,
get_view_direction, get_view_direction,
HUDS_TOP, HUDS_TOP,
@ -687,9 +696,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
true); true);
HUD_deque.push_front( p ); HUD_deque.push_front( p );
p = new lat_label( (cen_x -ladr_w2)/2, p = new lat_label( (cen_x - compass_w/2)/2,
max_y, max_y,
60, text_h, 0, text_h,
get_latitude, get_latitude,
"%s%", //"%.0f", "%s%", //"%.0f",
"", //"Lat ", "", //"Lat ",
@ -715,9 +724,9 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
// TRUE ); // TRUE );
// HUD_deque.push_front( p ); // HUD_deque.push_front( p );
p = new lon_label( (2*cen_x) - ((cen_x -ladr_w2)/2), p = new lon_label(((cen_x+compass_w/2)+(2*cen_x))/2,
max_y, max_y,
60, text_h, 1, text_h,
get_longitude, get_longitude,
"%s%",//"%.0f", "%s%",//"%.0f",
"", //"Lon ", "", //"Lon ",
@ -730,72 +739,61 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
TRUE ); TRUE );
HUD_deque.push_front( p ); HUD_deque.push_front( p );
// p = new instr_label( 480, 450, 60, 10, int x_pos = 40;
// get_long_min,
// "%05.2f",
// "",
// NULL,
// 1.0,
// HUDS_TOP,
// CENTER_JUST,
// font_size,
// 0,
// TRUE );
// HUD_deque.push_front( p );
p = new instr_label( 10, 10, 60, 10, p = new instr_label( x_pos, 25, 60, 10,
get_frame_rate, get_frame_rate,
"%7.1f", "%7.1f",
"Frame rate =", "Frame rate =",
NULL, NULL,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
HUD_deque.push_front( p ); HUD_deque.push_front( p );
p = new instr_label( 10, 25, 120, 10, p = new instr_label( x_pos, 40, 120, 10,
get_vfc_tris_culled, get_vfc_tris_culled,
"%7.0f", "%7.0f",
"Culled =", "Culled =",
NULL, NULL,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
HUD_deque.push_front( p ); HUD_deque.push_front( p );
p = new instr_label( 10, 40, 120, 10, p = new instr_label( x_pos, 55, 120, 10,
get_vfc_tris_drawn, get_vfc_tris_drawn,
"%7.0f", "%7.0f",
"Rendered =", "Rendered =",
NULL, NULL,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
HUD_deque.push_front( p ); HUD_deque.push_front( p );
p = new instr_label( 10, 55, 90, 10, p = new instr_label( x_pos, 70, 90, 10,
get_fov, get_fov,
"%7.1f", "%7.1f",
"FOV ", "FOV = ",
NULL, NULL,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
HUD_deque.push_front( p ); HUD_deque.push_front( p );
const int x_pos = 480; x_pos = 480;
p = new instr_label ( x_pos, p = new instr_label ( x_pos,
70, 70,
@ -807,7 +805,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
" Deg", " Deg",
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
@ -820,7 +818,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
" Kts", " Kts",
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
@ -838,7 +836,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
units, units,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
@ -851,7 +849,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
units, units,
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
@ -864,7 +862,7 @@ int fgHUDInit2( fgAIRCRAFT * /* current_aircraft */ )
" Deg", " Deg",
1.0, 1.0,
HUDS_TOP, HUDS_TOP,
RIGHT_JUST, LEFT_JUST,
font_size, font_size,
0, 0,
TRUE ); TRUE );
@ -1001,35 +999,20 @@ int brightness = pHUDInstr->get_brightness();
// all C++. // all C++.
// //
void fgUpdateHUD( void ) { void fgUpdateHUD( void ) {
// int i;
int brightness; int brightness;
// int day_night_sw = current_aircraft.controls->day_night_switch; // int day_night_sw = current_aircraft.controls->day_night_switch;
int day_night_sw = global_day_night_switch; int day_night_sw = global_day_night_switch;
int hud_displays = HUD_deque.size(); int hud_displays = HUD_deque.size();
instr_item *pHUDInstr; instr_item *pHUDInstr;
int line_width; float line_width;
if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards! if( !hud_displays ) { // Trust everyone, but ALWAYS cut the cards!
return; return;
} }
// vector < fgLineSeg2D > :: iterator first_lineSeg = HUD_LineList.begin(); HUD_TextList.erase();
// vector < fgLineSeg2D > :: iterator last_lineSeg = HUD_LineList.end(); HUD_LineList.erase();
// HUD_LineList.erase( first_lineSeg, last_lineSeg); // HUD_StippleLineList.erase();
HUD_LineList.erase( HUD_LineList.begin(), HUD_LineList.end() );
// first = HUD_StippleLineList.begin();
// last = HUD_StippleLineList.end();
// HUD_StippleLineList.erase( first, last);
// HUD_StippleLineList.erase( HUD_StippleLineList.begin(),
// HUD_StippleLineList.end() );
#ifdef USE_HUD_TextList
// vector < fgTextString > :: iterator first_string = HUD_TextList.begin();
// vector < fgTextString > :: iterator last_string = HUD_TextList.end();
// HUD_TextList.erase( first_string, last_string);
HUD_TextList.erase( HUD_TextList.begin(), HUD_TextList.end() );
#endif
line_width = (current_options.get_xsize() > 1000) ? 2 : 1;
pHUDInstr = HUD_deque[0]; pHUDInstr = HUD_deque[0];
brightness = pHUDInstr->get_brightness(); brightness = pHUDInstr->get_brightness();
@ -1040,7 +1023,6 @@ void fgUpdateHUD( void ) {
glLoadIdentity(); glLoadIdentity();
gluOrtho2D(0, 640, 0, 480); gluOrtho2D(0, 640, 0, 480);
// gluOrtho2D(0, 1024, 0, 768);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); glLoadIdentity();
@ -1051,8 +1033,6 @@ void fgUpdateHUD( void ) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(line_width);
// We can do translucency, so why not. :-) // We can do translucency, so why not. :-)
// glEnable ( GL_BLEND ) ; // glEnable ( GL_BLEND ) ;
// glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ; // glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
@ -1060,18 +1040,22 @@ void fgUpdateHUD( void ) {
if( day_night_sw == DAY) { if( day_night_sw == DAY) {
switch (brightness) { switch (brightness) {
case BRT_LIGHT: case BRT_LIGHT:
// glColor4f (0.1, 0.9, 0.1, 0.75);
glColor3f (0.1, 0.9, 0.1); glColor3f (0.1, 0.9, 0.1);
break; break;
case BRT_MEDIUM: case BRT_MEDIUM:
// glColor4f (0.1, 0.7, 0.0, 0.75);
glColor3f (0.1, 0.7, 0.0); glColor3f (0.1, 0.7, 0.0);
break; break;
case BRT_DARK: case BRT_DARK:
glColor3f (0.0, 0.5, 0.0); // glColor4f (0.0, 0.6, 0.0, 0.75);
glColor3f(0.0, 0.6, 0.0);
break; break;
case BRT_BLACK: case BRT_BLACK:
// glColor4f( 0.0, 0.0, 0.0, 0.75);
glColor3f( 0.0, 0.0, 0.0); glColor3f( 0.0, 0.0, 0.0);
break; break;
@ -1082,31 +1066,33 @@ void fgUpdateHUD( void ) {
if( day_night_sw == NIGHT) { if( day_night_sw == NIGHT) {
switch (brightness) { switch (brightness) {
case BRT_LIGHT: case BRT_LIGHT:
// glColor4f (0.9, 0.1, 0.1, 0.75);
glColor3f (0.9, 0.1, 0.1); glColor3f (0.9, 0.1, 0.1);
break; break;
case BRT_MEDIUM: case BRT_MEDIUM:
// glColor4f (0.7, 0.0, 0.1, 0.75);
glColor3f (0.7, 0.0, 0.1); glColor3f (0.7, 0.0, 0.1);
break; break;
case BRT_DARK: case BRT_DARK:
default: default:
glColor3f (0.5, 0.0, 0.0); // glColor4f (0.6, 0.0, 0.0, 0.75);
glColor3f (0.6, 0.0, 0.0);
} }
} }
else { // Just in case default else { // Just in case default
// glColor4f (0.1, 0.9, 0.1, 0.75);
glColor3f (0.1, 0.9, 0.1); glColor3f (0.1, 0.9, 0.1);
} }
} }
deque < instr_item * > :: iterator current = HUD_deque.begin(); deque < instr_item * > :: iterator current = HUD_deque.begin();
deque < instr_item * > :: iterator last = HUD_deque.end(); deque < instr_item * > :: iterator last = HUD_deque.end();
for ( ; current != last; ++current ) { for ( ; current != last; ++current ) {
pHUDInstr = *current; pHUDInstr = *current;
// for( i = hud_displays; i; --i) { // Draw everything
// if( HUD_deque.at(i)->enabled()) {
// pHUDInstr = HUD_deque[i - 1];
if( pHUDInstr->enabled()) { if( pHUDInstr->enabled()) {
// fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n", // fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
// hud->code, hud->status ); // hud->code, hud->status );
@ -1116,51 +1102,21 @@ void fgUpdateHUD( void ) {
} }
} }
vector < fgLineSeg2D > :: iterator curSeg = HUD_LineList.begin(); char *gmt_str = get_formated_gmt_time();
vector < fgLineSeg2D > :: iterator lastSeg = HUD_LineList.end(); HUD_TextList.add( fgText( gmt_str, 40, 10) );
glBegin(GL_LINES); HUD_TextList.draw();
for ( ; curSeg != lastSeg; curSeg++ ) {
curSeg->draw();
}
glEnd();
// curSeg = HUD_StippleLineList.begin(); line_width = (current_options.get_xsize() > 1000) ? 1.0 : 0.5;
// lastSeg = HUD_StippleLineList.end(); glLineWidth(line_width);
HUD_LineList.draw();
// glEnable(GL_LINE_STIPPLE); // glEnable(GL_LINE_STIPPLE);
// glLineStipple( 1, 0x00FF ); // glLineStipple( 1, 0x00FF );
// glBegin(GL_LINES); // HUD_StippleLineList.draw();
// for ( ; curSeg != lastSeg; curSeg++ ) {
// curSeg->draw();
// }
// glEnd();
// glDisable(GL_LINE_STIPPLE); // glDisable(GL_LINE_STIPPLE);
#ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y )
#endif
#ifdef USE_HUD_TextList // glDisable( GL_BLEND );
GLfloat mat[16];
glPushMatrix();
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
HUD_TextList.push_back( fgTextString( GLUT_BITMAP_8_BY_13,
get_formated_gmt_time(),
450, 445)
);
// glFontBegin ( myFont );
vector < fgTextString > :: iterator curString = HUD_TextList.begin();
vector < fgTextString > :: iterator lastString = HUD_TextList.end();
for ( ; curString != lastString; curString++ ) {
glLoadMatrixf( mat );
curString->draw();
}
// glFontEnd ();
glPopMatrix();
#endif
// glDisable ( GL_BLEND ) ;
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);

View file

@ -52,10 +52,8 @@
#include <Aircraft/aircraft.hxx> #include <Aircraft/aircraft.hxx>
#include <FDM/flight.hxx> #include <FDM/flight.hxx>
#include <Controls/controls.hxx> #include <Controls/controls.hxx>
#include <GUI/gui.h>
//#include "glfont.h" #include <Math/mat3.h>
//extern GLFONT *myFont;
FG_USING_STD(deque); FG_USING_STD(deque);
FG_USING_STD(vector); FG_USING_STD(vector);
@ -203,26 +201,10 @@ typedef struct gltagRGBTRIPLE { // rgbt
GLfloat Green; GLfloat Green;
GLfloat Red; GLfloat Red;
} glRGBTRIPLE; } glRGBTRIPLE;
/*
struct fgVertex2D {
UINT x, y;
fgVertex2D( UINT a = 0, UINT b =0 )
: x(a), y(b) {}
fgVertex2D( const fgVertex2D & image )
: x(image.x), y(image.y) {}
fgVertex2D& operator= ( const fgVertex2D & image ) {
x = image.x; y = image.y; return *this;
}
~fgVertex2D() {}
};
*/
class fgLineSeg2D { class fgLineSeg2D {
private: private:
GLfloat x0, y0, x1, y1; //UINT GLfloat x0, y0, x1, y1;
public: public:
fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 ) fgLineSeg2D( GLfloat a = 0, GLfloat b =0, GLfloat c = 0, GLfloat d =0 )
@ -245,89 +227,141 @@ public:
}; };
#define USE_HUD_TextList #define USE_HUD_TextList
#ifdef USE_HUD_TextList extern float HUD_TextSize;
extern fntRenderer *HUDtext;
extern float HUD_matrix[16];
//#define FAST_TEXT_TEST class fgText {
#ifdef FAST_TEXT_TEST
extern void Font_Setup(void);
extern unsigned int font_base;
#endif
class fgTextString {
private: private:
void *font; char msg[32];
char msg[80];
float x, y; float x, y;
// static GLfloat mat[16];
public: public:
fgTextString( void *d = NULL, char *c = NULL, UINT x = 0, UINT y =0 ) fgText( char *c = NULL, float x = 0, float y =0 )
: font(d), x(x), y(y) {strcpy(msg,c);} : x(x), y(y) {strncpy(msg,c,32-1);}
fgTextString( const fgTextString & image ) fgText( float x = 0, float y = 0, char *c = NULL )
: font(image.font), x(image.x), y(image.y) {strcpy(msg,image.msg);} : x(x), y(y) {strncpy(msg,c,32-1);}
fgTextString& operator = ( const fgTextString & image ) { fgText( const fgText & image )
font = image.font; strcpy(msg,image.msg); x = image.x; y = image.y; : x(image.x), y(image.y) {strcpy(msg,image.msg);}
fgText& operator = ( const fgText & image ) {
strcpy(msg,image.msg); x = image.x; y = image.y;
return *this; return *this;
} }
~fgTextString() {msg[0]='\0';} ~fgText() {msg[0]='\0';}
// void set_mat(void) { int getStringWidth ( char *str )
// glScalef(.075, .075, 0.0);
// glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// }
void draw()
{ {
#ifdef FAST_TEXT_TEST if ( HUDtext && str )
glRasterPos2f( x, y); {
int len = (int) strlen(msg); float r, l ;
for (int i=0; i < len; i++) { guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
glCallList(font_base+msg[i]); return FloatToInt( r - l );
}
return 0 ;
} }
// glFontTextOut ( msg, x, y, 0.0f);
#else int StringWidth (void )
#define USE_STROKED_CHAR
#ifdef USE_STROKED_CHAR
int c;
char *buf;
buf = msg;
if(*buf)
{ {
// glRasterPos2f( x, y); if ( HUDtext && strlen( msg ))
glTranslatef( x, y, 0);
glScalef(.075, .075, 0.0);
while ((c=*buf++)) {
glutStrokeCharacter( GLUT_STROKE_MONO_ROMAN, c);
}
}
#else
char *c = msg;
if(*c)
{ {
glRasterPos2f(x, y); float r, l ;
while (*c) { guiFntHandle->getBBox ( msg, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
glutBitmapCharacter(font, *c); return FloatToInt( r - l );
c++;
} }
return 0 ;
} }
#endif // #ifdef USE_STROKED_CHAR
#endif // FAST_TEXT_TEST void Draw(fntRenderer *fnt)
{
fnt->start2f( x, y );
fnt->puts ( msg ) ;
}
void Draw()
{
puDrawString ( guiFnt, msg, FloatToInt(x), FloatToInt(y) );
} }
}; };
typedef vector< fgTextString > TYPE_HUD_TextList; class fgLineList {
extern TYPE_HUD_TextList HUD_TextList; vector < fgLineSeg2D > List;
#endif //#ifdef USE_HUD_TextList public:
fgLineList( void ) {}
~fgLineList( void ) {}
void add( fgLineSeg2D seg ) { List.push_back(seg); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
vector < fgLineSeg2D > :: iterator curSeg;
vector < fgLineSeg2D > :: iterator lastSeg;
curSeg = List.begin();
lastSeg = List.end();
glBegin(GL_LINES);
for ( ; curSeg != lastSeg; curSeg++ ) {
curSeg->draw();
}
glEnd();
}
};
class fgTextList {
fntRenderer *Font;
vector< fgText > List;
public:
fgTextList ( void ) { Font = 0; }
~fgTextList( void ) {}
void setFont( fntRenderer *Renderer ) { Font = Renderer; }
void add( fgText String ) { List.push_back(String); }
void erase( void ) { List.erase( List.begin(), List.end() ); }
void draw( void ) {
vector < fgText > :: iterator curString;
vector < fgText > :: iterator lastString;
if( Font == 0 ) return;
curString = List.begin();
lastString = List.end();
glPushAttrib( GL_COLOR_BUFFER_BIT );
glEnable ( GL_ALPHA_TEST ) ;
glEnable ( GL_BLEND ) ;
glAlphaFunc ( GL_GREATER, 0.1 ) ;
glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ) ;
Font->begin();
for( ; curString != lastString; curString++ ) {
curString->Draw(Font);
}
Font->end();
glDisable ( GL_TEXTURE_2D ) ;
glPopAttrib();
}
};
typedef vector< fgLineSeg2D > TYPE_HUD_LineList; inline void Text( fgTextList &List, float x, float y, char *s)
extern TYPE_HUD_LineList HUD_LineList; {
extern TYPE_HUD_LineList HUD_StippleLineList; List.add( fgText( x, y, s) );
}
inline void Text( fgTextList &List, fgText &me)
{
List.add(me);
}
inline void Line( fgLineList &List, float x1, float y1, float x2, float y2)
{
List.add(fgLineSeg2D(x1,y1,x2,y2));
}
// Declare our externals
extern fgTextList HUD_TextList;
extern fgLineList HUD_LineList;
extern fgLineList HUD_StippleLineList;
class instr_item { // An Abstract Base Class (ABC) class instr_item { // An Abstract Base Class (ABC)
private: private:
@ -390,31 +424,29 @@ class instr_item { // An Abstract Base Class (ABC)
UINT get_Handle( void ); UINT get_Handle( void );
virtual void draw( void ) = 0; // Required method in derived classes virtual void draw( void ) = 0; // Required method in derived classes
void drawOneLine( UINT x1, UINT y1, UINT x2, UINT y2) void drawOneLine( float x1, float y1, float x2, float y2)
{ {
HUD_LineList.push_back(fgLineSeg2D(x1,y1,x2,y2)); HUD_LineList.add(fgLineSeg2D(x1,y1,x2,y2));
// glBegin(GL_LINES);
// glVertex2i(x1, y1);
// glVertex2i(x2, y2);
// glEnd();
} }
void drawOneStippleLine( UINT x1, UINT y1, UINT x2, UINT y2) void drawOneStippleLine( float x1, float y1, float x2, float y2)
{ {
HUD_StippleLineList.push_back(fgLineSeg2D(x1,y1,x2,y2)); HUD_StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
// glEnable(GL_LINE_STIPPLE);
// glLineStipple( 1, 0x00FF );
// glBegin(GL_LINES);
// glVertex2i(x1, y1);
// glVertex2i(x2, y2);
// glEnd();
// glDisable(GL_LINE_STIPPLE);
} }
#ifdef USE_HUD_TextList void TextString( char *msg, float x, float y )
void TextString( void *font, char *msg, UINT x, UINT y )
{ {
HUD_TextList.push_back(fgTextString(font, msg, x, y)); HUD_TextList.add(fgText(msg, x, y));
} }
#endif int getStringWidth ( char *str )
{
if ( HUDtext && str )
{
float r, l ;
guiFntHandle->getBBox ( str, HUD_TextSize, 0, &l, &r, NULL, NULL ) ;
return FloatToInt( r - l );
}
return 0 ;
}
}; };
typedef instr_item *HIptr; typedef instr_item *HIptr;
@ -423,6 +455,7 @@ typedef instr_item *HIptr;
//typedef hud_deque_type::const_iterator hud_deque_const_iterator; //typedef hud_deque_type::const_iterator hud_deque_const_iterator;
extern deque< instr_item *> HUD_deque; extern deque< instr_item *> HUD_deque;
extern int HUD_style;
//extern hud_deque_type HUD_deque; //extern hud_deque_type HUD_deque;
// instr_item This class has no other purpose than to maintain // instr_item This class has no other purpose than to maintain
@ -713,6 +746,10 @@ class HudLadder : public dual_instr_item {
float vmin; float vmin;
float factor; float factor;
fgTextList TextList;
fgLineList LineList;
fgLineList StippleLineList;
public: public:
HudLadder( int x, HudLadder( int x,
int y, int y,
@ -732,6 +769,21 @@ class HudLadder : public dual_instr_item {
HudLadder( const HudLadder & image ); HudLadder( const HudLadder & image );
HudLadder & operator = ( const HudLadder & rhs ); HudLadder & operator = ( const HudLadder & rhs );
virtual void draw( void ); virtual void draw( void );
void Text( float x, float y, char *s)
{
TextList.add( fgText( x, y, s) );
}
void Line( float x1, float y1, float x2, float y2)
{
LineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
void StippleLine( float x1, float y1, float x2, float y2)
{
StippleLineList.add(fgLineSeg2D(x1,y1,x2,y2));
}
}; };

View file

@ -19,7 +19,9 @@
#include "hud.hxx" #include "hud.hxx"
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y ) #define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif #endif
//========== Top of hud_card class member definitions ============= //========== Top of hud_card class member definitions =============

View file

@ -19,13 +19,15 @@
#include "hud.hxx" #include "hud.hxx"
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y ) #define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif #endif
//============== Top of guage_instr class member definitions ============== //============== Top of guage_instr class member definitions ==============
guage_instr :: guage_instr ::
guage_instr( int x, guage_instr( int x,
int y, int y,
UINT width, UINT width,
UINT height, UINT height,
@ -48,39 +50,39 @@ guage_instr ::
modulus, dp_showing, modulus, dp_showing,
working) working)
{ {
// UINT options = get_options(); // UINT options = get_options();
// huds_vert = options & HUDS_VERT; // huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT; // huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT; // huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH; // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS; // huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT; // huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP; // huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM; // huds_bottom = options & HUDS_BOTTOM;
} }
guage_instr :: guage_instr ::
~guage_instr() ~guage_instr()
{ {
} }
guage_instr :: guage_instr ::
guage_instr( const guage_instr & image): guage_instr( const guage_instr & image):
instr_scale( (instr_scale &) image) instr_scale( (instr_scale &) image)
{ {
// UINT options = get_options(); // UINT options = get_options();
// huds_vert = options & HUDS_VERT; // huds_vert = options & HUDS_VERT;
// huds_left = options & HUDS_LEFT; // huds_left = options & HUDS_LEFT;
// huds_right = options & HUDS_RIGHT; // huds_right = options & HUDS_RIGHT;
// huds_both = (options & HUDS_BOTH) == HUDS_BOTH; // huds_both = (options & HUDS_BOTH) == HUDS_BOTH;
// huds_noticks = options & HUDS_NOTICKS; // huds_noticks = options & HUDS_NOTICKS;
// huds_notext = options & HUDS_NOTEXT; // huds_notext = options & HUDS_NOTEXT;
// huds_top = options & HUDS_TOP; // huds_top = options & HUDS_TOP;
// huds_bottom = options & HUDS_BOTTOM; // huds_bottom = options & HUDS_BOTTOM;
} }
guage_instr & guage_instr :: guage_instr & guage_instr ::
operator = (const guage_instr & rhs ) operator = (const guage_instr & rhs )
{ {
if( !(this == &rhs)) { if( !(this == &rhs)) {
instr_scale::operator = (rhs); instr_scale::operator = (rhs);
@ -113,9 +115,8 @@ void guage_instr :: draw (void)
UINT options = get_options(); UINT options = get_options();
width = scrn_rect.left + scrn_rect.right; width = scrn_rect.left + scrn_rect.right;
height = scrn_rect.top + scrn_rect.bottom; height = scrn_rect.top + scrn_rect.bottom,
bottom_4 = scrn_rect.bottom / 4; bottom_4 = scrn_rect.bottom / 4;
// Draw the basic markings for the scale... // Draw the basic markings for the scale...
if( huds_vert(options) ) { // Vertical scale if( huds_vert(options) ) { // Vertical scale
@ -166,7 +167,7 @@ void guage_instr :: draw (void)
int last = (int)vmax + 1; //FloatToInt(vmax)+1; int last = (int)vmax + 1; //FloatToInt(vmax)+1;
i = (int)vmin; //FloatToInt(vmin); i = (int)vmin; //FloatToInt(vmin);
for(; i <last ; i++ ) { for(; i <last ; i++ ) {
// for( i = (int)vmin; i <= (int)vmax; i++ ) { // for( i = (int)vmin; i <= (int)vmax; i++ ) {
// Calculate the location of this tick // Calculate the location of this tick
marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/); marker_ys = scrn_rect.top + FloatToInt((i - vmin) * factor()/* +.5f*/);
@ -211,18 +212,20 @@ void guage_instr :: draw (void)
if( !huds_notext(options) ) { if( !huds_notext(options) ) {
disp_val = i; disp_val = i;
lenstr = sprintf( TextScale, "%d", sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/*+.5*/ )); FloatToInt(disp_val * data_scaling()/*+.5*/ ));
lenstr = getStringWidth( TextScale );
if( huds_left(options) && huds_right(options) ) { if( huds_left(options) && huds_right(options) ) {
text_x = mid_scr.x - 2 - ((3 * lenstr) >> 1); text_x = mid_scr.x - lenstr/2 ;
} }
else { else {
if( huds_left(options) ) { if( huds_left(options) ) {
text_x = marker_xs - 2 - 3 * lenstr; text_x = marker_xs - lenstr;
} }
else { else {
text_x = marker_xe + 10 - lenstr; text_x = marker_xe - lenstr;
} }
} }
// Now we know where to put the text. // Now we know where to put the text.
@ -238,7 +241,7 @@ void guage_instr :: draw (void)
// with the marker start stops to produce a pointer for each side reading // with the marker start stops to produce a pointer for each side reading
text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/); text_y = scrn_rect.top + FloatToInt((cur_value - vmin) * factor() /*+.5f*/);
// text_x = marker_xs - scrn_rect.left; // text_x = marker_xs - scrn_rect.left;
if( huds_right(options) ) { if( huds_right(options) ) {
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
@ -310,7 +313,7 @@ void guage_instr :: draw (void)
} }
if( condition ) { if( condition ) {
marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/); marker_xs = scrn_rect.left + FloatToInt((i - vmin) * factor()/* +.5f*/);
// marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f); // marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5f);
if( div_min()){ if( div_min()){
if( !(i%(int)div_min()) ) { if( !(i%(int)div_min()) ) {
// draw in ticks only if they aren't too close to the edge. // draw in ticks only if they aren't too close to the edge.
@ -348,8 +351,10 @@ void guage_instr :: draw (void)
} else { } else {
disp_val = i; disp_val = i;
} }
lenstr = 4 * sprintf( TextScale, "%d", sprintf( TextScale, "%d",
FloatToInt(disp_val * data_scaling()/* +.5*/ )); FloatToInt(disp_val * data_scaling()/* +.5*/ ));
lenstr = getStringWidth( TextScale);
// Draw major ticks and text only if far enough from the edge. // Draw major ticks and text only if far enough from the edge.
if(( (marker_xs - 10)> scrn_rect.left ) && if(( (marker_xs - 10)> scrn_rect.left ) &&
( (marker_xs + 10) < width )){ ( (marker_xs + 10) < width )){

View file

@ -19,7 +19,9 @@
#include "hud.hxx" #include "hud.hxx"
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y ) #define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -123,27 +125,16 @@ draw( void ) // Required method in base class
int lenstr; int lenstr;
RECT scrn_rect = get_location(); RECT scrn_rect = get_location();
// if( pre_str != NULL) {
// if( post_str != NULL ) {
// sprintf( format_buffer, "%s%s%s", pre_str, pformat, post_str );
// }
// else {
// sprintf( format_buffer, "%s%s", pre_str, pformat );
// }
// }
// else {
// if( post_str != NULL ) {
// sprintf( format_buffer, "%s%s", pformat, post_str );
// }
// } // else do nothing if both pre and post strings are nulls. Interesting.
if( data_available() ) { if( data_available() ) {
lenstr = sprintf( label_buffer, format_buffer, get_value() ); sprintf( label_buffer, format_buffer, get_value() );
} }
else { else {
lenstr = sprintf( label_buffer, format_buffer ); sprintf( label_buffer, format_buffer );
} }
lenstr = getStringWidth( label_buffer );
#ifdef DEBUGHUD #ifdef DEBUGHUD
fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer ); fgPrintf( FG_COCKPIT, FG_DEBUG, format_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
@ -152,16 +143,15 @@ draw( void ) // Required method in base class
#endif #endif
// lenstr = strlen( label_buffer ); // lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8; if( justify == RIGHT_JUST ) {
posincr = scrn_rect.right - lenstr;
}else if( justify == CENTER_JUST ) {
posincr = get_span() - (lenstr/2); // -lenstr*4;
} else {
// justify == LEFT_JUST
posincr = 0; // 0;
}
if( justify == CENTER_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4;
}
else {
if( justify == LEFT_JUST ) {
posincr = - (lenstr << 8); // 0;
}
}
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -14,7 +14,7 @@
#include <Math/polar3d.hxx> #include <Math/polar3d.hxx>
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
#include <Time/fg_timer.hxx> #include <Time/fg_timer.hxx>
#include <GUI/gui.h>
#include "hud.hxx" #include "hud.hxx"
//====================== Top of HudLadder Class ======================= //====================== Top of HudLadder Class =======================
@ -84,250 +84,156 @@ HudLadder & HudLadder :: operator = ( const HudLadder & rhs )
// Draws a climb ladder in the center of the HUD // Draws a climb ladder in the center of the HUD
// //
inline static void _strokeString(float xx, float yy, char *msg, void *font)
{
int c;
if(*msg)
{
glTranslatef( xx, yy, 0);
glScalef(.075, .075, 0.0);
while ((c=*msg++)) {
glutStrokeCharacter( font, c);
}
}
}
void HudLadder :: draw( void ) void HudLadder :: draw( void )
{ {
float roll_value;
float pitch_value;
float marker_y;
float x_ini; float x_ini;
float x_end; float x_end;
float y_ini; float y;
float y_end;
int i;
POINT centroid = get_centroid(); POINT centroid = get_centroid();
RECT box = get_location(); RECT box = get_location();
int half_span = box.right >> 1; float half_span = box.right / 2.0;
char TextLadder[80]; float roll_value = current_ch2();
int label_length; float pitch_value = current_ch1() * RAD_TO_DEG;
roll_value = current_ch2();
float hole = (float)((scr_hole)/2);
GLfloat mat[16];
pitch_value = current_ch1() * RAD_TO_DEG;
vmin = pitch_value - (float)width_units/2.0; vmin = pitch_value - (float)width_units/2.0;
vmax = pitch_value + (float)width_units/2.0; vmax = pitch_value + (float)width_units/2.0;
// We will do everything with glLoadMatrix :-)
// to avoid multiple pushing and popping matrix stack
glPushMatrix(); glPushMatrix();
// glTranslatef( centroid.x, centroid.y, 0); glTranslatef( centroid.x, centroid.y, 0);
// glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0); glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
// glGetFloatv(GL_MODELVIEW_MATRIX, mat);
// this is the same as above
float sinx = sin(roll_value);
float cosx = cos(roll_value);
mat[0] = cosx;
mat[1] = sinx;
mat[2] = mat[3] = 0.0;
mat[4] = -sinx;
mat[5] = cosx;
mat[6] = mat[7] = mat[8] = mat[9];
mat[10] = 1.0;
mat[11] = 0.0;
mat[12] = centroid.x;
mat[13] = centroid.y;
mat[14] = 0;
mat[15] = 1.0;
glLoadMatrixf( mat );
// Draw the target spot. // Draw the target spot.
#define CENTER_DIAMOND_SIZE 5.0 #define CENTER_DIAMOND_SIZE 6.0
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glVertex2f( -CENTER_DIAMOND_SIZE, 0.0); glVertex2f( -CENTER_DIAMOND_SIZE, 0.0);
glVertex2f(0.0, CENTER_DIAMOND_SIZE); glVertex2f(0.0, CENTER_DIAMOND_SIZE);
glVertex2f( CENTER_DIAMOND_SIZE, 0.0); glVertex2f( CENTER_DIAMOND_SIZE, 0.0);
glVertex2f(0.0, -CENTER_DIAMOND_SIZE); glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
glEnd(); glEnd();
#if 0
glBegin(GL_LINES);
glVertex2f( -CENTER_DIAMOND_SIZE, 0);
glVertex2f( -(CENTER_DIAMOND_SIZE*2), 0);
glVertex2f(0, CENTER_DIAMOND_SIZE);
glVertex2f(0, (CENTER_DIAMOND_SIZE*2));
glVertex2f( CENTER_DIAMOND_SIZE, 0);
glVertex2f( (CENTER_DIAMOND_SIZE*2), 0);
glVertex2f(0, -CENTER_DIAMOND_SIZE);
glVertex2f(0, -(CENTER_DIAMOND_SIZE*2));
glEnd();
#endif // 0
#undef CENTER_DIAMOND_SIZE #undef CENTER_DIAMOND_SIZE
int last =FloatToInt(vmax)+1;
i = FloatToInt(vmin);
if( div_units ) { if( div_units ) {
if( !scr_hole ) { char TextLadder[8] ;
for( ; i <last ; i++ ) { float label_length ;
float label_height ;
float left ;
float right ;
float bot ;
float top ;
float text_offset = 4.0f ;
float zero_offset = 10.0f ;
marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5); fntFont *font = HUDtext->getFont();
float pointsize = HUDtext->getPointSize();
float italic = HUDtext->getSlant();
TextList.setFont( HUDtext );
TextList.erase();
LineList.erase();
StippleLineList.erase();
int last = FloatToInt(vmax)+1;
int i = FloatToInt(vmin);
if( !scr_hole ) {
for( ; i<last ; i++ ) {
y = (((float)(i - pitch_value) * factor) + .5f);
if( !(i % div_units )) { // At integral multiple of div if( !(i % div_units )) { // At integral multiple of div
label_length = sprintf( TextLadder, "%d", i ); sprintf( TextLadder, "%d", i );
font->getBBox ( TextLadder, pointsize, italic,
&left, &right, &bot, &top ) ;
label_length = right - left;
label_length += text_offset;
label_height = (top - bot)/2.0f;
if( i ) {
x_ini = -half_span; x_ini = -half_span;
} else { // Make zero point wider on left
x_ini = -half_span - 10;
}
x_end = half_span; x_end = half_span;
y_ini = marker_y; if( i >= 0 ) {
y_end = marker_y; // Make zero point wider on left
if( i == 0 )
// printf("(%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end); x_ini -= zero_offset;
// Zero or above draw solid lines
if( i >= 0 ) { // Above zero draw solid lines Line(x_ini, y, x_end, y);
glBegin(GL_LINES); } else {
glVertex2f( x_ini, y_ini); // Below zero draw dashed lines.
glVertex2f( x_end, y_end ); StippleLine(x_ini, y, x_end, y);
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
} }
// Calculate the position of the left text and write it. // Calculate the position of the left text and write it.
x_ini -= ( 8*label_length - 4); Text( x_ini-label_length, y-label_height, TextLadder );
y_ini -= 4; Text( x_end+text_offset, y-label_height, TextLadder );
_strokeString(x_ini, y_ini,
TextLadder, GLUT_STROKE_ROMAN );
glLoadMatrixf( mat );
// Calculate the position of the right text and write it.
x_end -= (24 - 8 * label_length);
y_end -= 4;
_strokeString(x_end, y_end,
TextLadder, GLUT_STROKE_ROMAN );
glLoadMatrixf( mat );
} }
} }
} }
else // if(scr_hole ) else // if(scr_hole )
{ // Draw ladder with space in the middle of the lines { // Draw ladder with space in the middle of the lines
last =FloatToInt(vmax)+1; float hole = (float)((scr_hole)/2.0f);
i = FloatToInt(vmin); for( ; i<last ; i++ ) {
for( ; i <last ; i++ ) {
marker_y = /*(int)*/(((float)(i - pitch_value) * factor) + .5); y = (((float)(i - pitch_value) * factor) + .5);
if( !(i % div_units )) { // At integral multiple of div if( !(i % div_units )) { // At integral multiple of div
label_length = sprintf( TextLadder, "%d", i ); sprintf( TextLadder, "%d", i );
font->getBBox ( TextLadder, pointsize, italic,
&left, &right, &bot, &top ) ;
label_length = right - left;
label_length += text_offset;
label_height = (top - bot)/2.0f;
// printf("l %f r %f b %f t %f\n",left, right, bot, top );
// Start by calculating the points and drawing the // Start by calculating the points and drawing the
// left side lines. // left side lines.
if( i != 0 ) {
x_ini = -half_span; x_ini = -half_span;
} else {
x_ini = -half_span - 10;
}
x_end = -half_span + hole; x_end = -half_span + hole;
y_ini = marker_y; if( i >= 0 ) {
y_end = marker_y; // Make zero point wider on left
if( i == 0 )
// printf("half_span(%d) scr_hole(%d)\n", half_span, scr_hole); x_ini -= zero_offset;
// printf("x_end(%f) %f\n",x_end,(float)(-half_span + scr_hole/2)); // Zero or above draw solid lines
// printf("L: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end); Line(x_ini, y, x_end, y);
} else {
if( i >= 0 ) { // Above zero draw solid lines // Below zero draw dashed lines.
glBegin(GL_LINES); StippleLine(x_ini, y, x_end, y);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
} }
// Now calculate the location of the left side label using // Now calculate the location of the left side label using
// the previously calculated start of the left side line. Text( x_ini-label_length, y-label_height, TextLadder );
x_ini -= (label_length + 32);
if( i < 0) {
x_ini -= 8;
} else {
if( i == 0 ) {
x_ini += 15; //20;
}
}
y_ini -= 4;
_strokeString(x_ini, y_ini,
TextLadder, GLUT_STROKE_MONO_ROMAN );
glLoadMatrixf( mat );
// Now calculate and draw the right side line location // Now calculate and draw the right side line location
x_ini = half_span - hole; x_ini = half_span - hole;
y_ini = marker_y;
if( i != 0 ) {
x_end = half_span; x_end = half_span;
if( i >= 0 ) {
if( i == 0 )
x_end += zero_offset;
// Zero or above draw solid lines
Line(x_ini, y, x_end, y);
} else { } else {
x_end = half_span + 10; // Below zero draw dashed lines.
} StippleLine(x_ini, y, x_end, y);
y_end = marker_y;
// printf("R: (%.1f %.1f) (%.1f %.1f)\n",x_ini,y_ini,x_end,y_end);
if( i >= 0 ) { // Above zero draw solid lines
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
} else { // Below zero draw dashed lines.
glEnable(GL_LINE_STIPPLE);
glLineStipple( 1, 0x00FF );
glBegin(GL_LINES);
glVertex2f( x_ini, y_ini);
glVertex2f( x_end, y_end );
glEnd();
glDisable(GL_LINE_STIPPLE);
} }
// Calculate the location and draw the right side label // Calculate the location and draw the right side label
// using the end of the line as previously calculated. Text( x_end+text_offset, y-label_height, TextLadder );
x_end -= (label_length - 24); }
}
}
TextList.draw();
if( i <= 0 ) { glLineWidth(0.2);
x_end -= 8;
} // else if( i==0)
// {
// x_end -=4;
// }
y_end = marker_y - 4; LineList.draw();
_strokeString(x_end, y_end,
TextLadder, GLUT_STROKE_MONO_ROMAN ); glEnable(GL_LINE_STIPPLE);
glLoadMatrixf( mat ); glLineStipple( 1, 0x00FF );
} StippleLineList.draw( );
} glDisable(GL_LINE_STIPPLE);
}
} }
glPopMatrix(); glPopMatrix();
} }

View file

@ -20,7 +20,9 @@
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y ) #define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -30,12 +32,10 @@ lat_label ::
UINT width, UINT width,
UINT height, UINT height,
FLTFNPTR data_source, FLTFNPTR data_source,
// DBLFNPTR data_source,
const char *label_format, const char *label_format,
const char *pre_label_string, const char *pre_label_string,
const char *post_label_string, const char *post_label_string,
float scale_data, float scale_data,
// double scale_data,
UINT options, UINT options,
fgLabelJust justification, fgLabelJust justification,
int font_size, int font_size,
@ -120,20 +120,17 @@ lat_label & lat_label ::operator = (const lat_label & rhs )
void lat_label :: void lat_label ::
draw( void ) // Required method in base class draw( void ) // Required method in base class
{ {
// char format_buffer[80];
char label_buffer[80]; char label_buffer[80];
int posincr; int posincr;
int lenstr; int lenstr;
RECT scrn_rect = get_location(); RECT scrn_rect = get_location();
float lat = get_value(); float lat = get_value();
// double lat = get_value();
if( data_available() ) { if( data_available() ) {
// char *latstring = coord_format_lat(lat); sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
lenstr = sprintf( label_buffer, format_buffer, coord_format_lat(lat) );
} }
else { else {
lenstr = sprintf( label_buffer, format_buffer ); sprintf( label_buffer, format_buffer );
} }
#ifdef DEBUGHUD #ifdef DEBUGHUD
@ -142,18 +139,18 @@ draw( void ) // Required method in base class
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer ); fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif #endif
// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8; lenstr = getStringWidth(label_buffer);
if( justify == CENTER_JUST ) { if( justify == RIGHT_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4; posincr = scrn_rect.right - lenstr;
} }else if( justify == CENTER_JUST ) {
else { posincr = get_span() - (lenstr/2); // -lenstr*4;
if( justify == LEFT_JUST ) { } else {
posincr = - (lenstr << 8); // 0; // justify == LEFT_JUST
} posincr = 0; // 0;
} }
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -20,7 +20,9 @@
#include "hud.hxx" #include "hud.hxx"
#ifdef USE_HUD_TextList #ifdef USE_HUD_TextList
#define textString( x , y, text, font ) TextString( font, text, x , y ) #define textString( x , y, text, font ) TextString( text, x , y )
#else
#define textString( x , y, text, font ) puDrawString ( guiFnt, text, x, y );
#endif #endif
//======================= Top of instr_label class ========================= //======================= Top of instr_label class =========================
@ -141,18 +143,18 @@ draw( void ) // Required method in base class
fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer ); fgPrintf( FG_COCKPIT, FG_DEBUG, label_buffer );
fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" ); fgPrintf( FG_COCKPIT, FG_DEBUG, "\n" );
#endif #endif
// lenstr = strlen( label_buffer );
posincr = 0; // default to RIGHT_JUST ... center located calc: -lenstr*8; lenstr = getStringWidth(label_buffer);
if( justify == CENTER_JUST ) { if( justify == RIGHT_JUST ) {
posincr = - (lenstr << 2); // -lenstr*4; posincr = scrn_rect.right - lenstr;
} }else if( justify == CENTER_JUST ) {
else { posincr = get_span() - (lenstr/2); // -lenstr*4;
if( justify == LEFT_JUST ) { } else {
posincr = - (lenstr << 8); // 0; // justify == LEFT_JUST
} posincr = 0; // 0;
} }
if( fontSize == SMALL ) { if( fontSize == SMALL ) {
textString( scrn_rect.left + posincr, scrn_rect.top, textString( scrn_rect.left + posincr, scrn_rect.top,
label_buffer, GLUT_BITMAP_8_BY_13); label_buffer, GLUT_BITMAP_8_BY_13);

View file

@ -61,7 +61,6 @@
#include "gui.h" #include "gui.h"
FG_USING_STD(cout);
FG_USING_STD(string); FG_USING_STD(string);
puFont guiFnt = 0; puFont guiFnt = 0;
@ -82,8 +81,22 @@ static puText *YNdialogBoxMessage = 0;
static puOneShot *YNdialogBoxOkButton = 0; static puOneShot *YNdialogBoxOkButton = 0;
static puOneShot *YNdialogBoxNoButton = 0; static puOneShot *YNdialogBoxNoButton = 0;
// extern void NewAltitude( puObject *cb ); static char msg_OK[] = "OK";
// extern void NewHeading( puObject *cb ); static char msg_NO[] = "NO";
static char msg_YES[] = "YES";
static char msg_CANCEL[] = "Cancel";
static char msg_RESET[] = "Reset";
char *gui_msg_OK; // "OK"
char *gui_msg_NO; // "NO"
char *gui_msg_YES; // "YES"
char *gui_msg_CANCEL; // "CANCEL"
char *gui_msg_RESET; // "RESET"
static char global_dialog_string[256];
extern void NewAltitude( puObject *cb );
extern void NewHeading( puObject *cb );
extern void fgAPAdjust( puObject * ); extern void fgAPAdjust( puObject * );
extern void fgLatLonFormatToggle( puObject *); extern void fgLatLonFormatToggle( puObject *);
@ -105,7 +118,6 @@ void guiMotionFunc ( int x, int y )
glutPostRedisplay () ; glutPostRedisplay () ;
} }
void guiMouseFunc(int button, int updown, int x, int y) void guiMouseFunc(int button, int updown, int x, int y)
{ {
_mX = x; _mX = x;
@ -114,7 +126,6 @@ void guiMouseFunc(int button, int updown, int x, int y)
last_buttons |= ( 1 << button ) ; last_buttons |= ( 1 << button ) ;
else else
last_buttons &= ~( 1 << button ) ; last_buttons &= ~( 1 << button ) ;
puMouse (button, updown, x,y); puMouse (button, updown, x,y);
glutPostRedisplay (); glutPostRedisplay ();
} }
@ -147,14 +158,15 @@ static inline void TurnCursorOff( void )
#if defined ( WIN32 ) || defined(__CYGWIN32__) #if defined ( WIN32 ) || defined(__CYGWIN32__)
glutSetCursor(GLUT_CURSOR_NONE); glutSetCursor(GLUT_CURSOR_NONE);
#else // I guess this is what we want to do ?? #else // I guess this is what we want to do ??
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9) #if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT)); glutWarpPointer( glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT));
#endif #endif
#endif #endif
} }
void maybeToggleMouse( void ) void maybeToggleMouse( void )
{ {
#ifdef WIN32
static int first_time = ~0; static int first_time = ~0;
static int mouse_changed = 0; static int mouse_changed = 0;
@ -172,6 +184,7 @@ void maybeToggleMouse( void )
} }
} }
first_time = ~first_time; first_time = ~first_time;
#endif // #ifdef WIN32
} }
// Call with FALSE to init and TRUE to restore // Call with FALSE to init and TRUE to restore
@ -182,7 +195,9 @@ void BusyCursor( int restore )
glutSetCursor(cursor); glutSetCursor(cursor);
} else { } else {
cursor = glutGet( GLUT_WINDOW_CURSOR ); cursor = glutGet( GLUT_WINDOW_CURSOR );
#ifdef WIN32
TurnCursorOn(); TurnCursorOn();
#endif
glutSetCursor( GLUT_CURSOR_WAIT ); glutSetCursor( GLUT_CURSOR_WAIT );
} }
} }
@ -191,20 +206,14 @@ void BusyCursor( int restore )
// Intercept the Escape Key // Intercept the Escape Key
void ConfirmExitDialog(void) void ConfirmExitDialog(void)
{ {
string Msg("Really Quit");
YNdialogBoxMessage -> setLabel(Msg.c_str());
YNdialogBoxNoButton-> makeReturnDefault (TRUE );
FG_PUSH_PUI_DIALOG( YNdialogBox ); FG_PUSH_PUI_DIALOG( YNdialogBox );
} }
// General Purpose Message Box // General Purpose Message Box
void mkDialog (char *txt) void mkDialog (const char *txt)
{ {
void goAwayCb(puObject *); strncpy(global_dialog_string, txt, 256);
dialogBoxMessage->setLabel(txt); dialogBoxMessage->setLabel(global_dialog_string);
dialogBoxOkButton -> setLegend ("OK");
dialogBoxOkButton -> makeReturnDefault (TRUE );
dialogBoxOkButton -> setCallback (goAwayCb);
FG_PUSH_PUI_DIALOG( dialogBox ); FG_PUSH_PUI_DIALOG( dialogBox );
} }
@ -214,7 +223,6 @@ void guiFixPanel( void )
int toggle_pause; int toggle_pause;
if ( current_options.get_panel_status() ) { if ( current_options.get_panel_status() ) {
FGView *v = &current_view; FGView *v = &current_view;
FGTime *t = FGTime::cur_time_params; FGTime *t = FGTime::cur_time_params;
@ -237,11 +245,15 @@ void guiToggleMenu(void)
if( menu_on ) { if( menu_on ) {
// printf("Hiding Menu\n"); // printf("Hiding Menu\n");
mainMenuBar->hide (); mainMenuBar->hide ();
#ifdef WIN32
TurnCursorOff(); TurnCursorOff();
#endif // #ifdef WIN32
} else { } else {
// printf("Showing Menu\n"); // printf("Showing Menu\n");
mainMenuBar->reveal(); mainMenuBar->reveal();
#ifdef WIN32
TurnCursorOn(); TurnCursorOn();
#endif // #ifdef WIN32
} }
menu_on = ~menu_on; menu_on = ~menu_on;
} }
@ -298,6 +310,9 @@ void mkDialogInit (void)
dialogBoxMessage = new puText (10, 70); dialogBoxMessage = new puText (10, 70);
dialogBoxMessage -> setLabel (""); dialogBoxMessage -> setLabel ("");
dialogBoxOkButton = new puOneShot (180, 10, 240, 50); dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
dialogBoxOkButton -> setLegend (gui_msg_OK);
dialogBoxOkButton -> makeReturnDefault (TRUE );
dialogBoxOkButton -> setCallback (goAwayCb);
} }
FG_FINALIZE_PUI_DIALOG( dialogBox ); FG_FINALIZE_PUI_DIALOG( dialogBox );
} }
@ -314,10 +329,11 @@ void goAwayYesNoCb(puObject *me)
void ConfirmExitDialogInit(void) void ConfirmExitDialogInit(void)
{ {
char msg[] = "Really Quit";
char *s;
// printf("ConfirmExitDialogInit\n"); // printf("ConfirmExitDialogInit\n");
string Msg("Really Quit"); int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), msg )/2;
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), Msg.c_str() )/2;
int x = (current_options.get_xsize()/2 - 400/2); int x = (current_options.get_xsize()/2 - 400/2);
int y = (current_options.get_ysize()/2 - 100/2); int y = (current_options.get_ysize()/2 - 100/2);
@ -328,14 +344,16 @@ void ConfirmExitDialogInit(void)
YNdialogFrame = new puFrame (0,0,400, 100); YNdialogFrame = new puFrame (0,0,400, 100);
YNdialogBoxMessage = new puText (len, 70); YNdialogBoxMessage = new puText (len, 70);
YNdialogBoxMessage -> setLabel (Msg.c_str()); YNdialogBoxMessage -> setDefaultValue (msg);
YNdialogBoxMessage -> getDefaultValue (&s);
YNdialogBoxMessage -> setLabel (s);
YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50); YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
YNdialogBoxOkButton -> setLegend ("OK"); YNdialogBoxOkButton -> setLegend (gui_msg_OK);
YNdialogBoxOkButton -> setCallback (goodBye); YNdialogBoxOkButton -> setCallback (goodBye);
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50); YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
YNdialogBoxNoButton -> setLegend ("NO"); YNdialogBoxNoButton -> setLegend (gui_msg_NO);
// YNdialogBoxNoButton -> makeReturnDefault (TRUE ); // YNdialogBoxNoButton -> makeReturnDefault (TRUE );
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb); YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
} }
@ -373,9 +391,10 @@ void helpCb (puObject *)
#endif #endif
system( command.c_str() ); system( command.c_str() );
string text = "Help started in netscape window."; //string text = "Help started in netscape window.";
mkDialog (text.c_str()); //mkDialog (text.c_str());
mkDialog ("Help started in netscape window.");
} }
/// The beginnings of teleportation :-) /// The beginnings of teleportation :-)
@ -386,14 +405,15 @@ static puFrame *AptDialogFrame = 0;
static puText *AptDialogMessage = 0; static puText *AptDialogMessage = 0;
static puInput *AptDialogInput = 0; static puInput *AptDialogInput = 0;
static char NewAirportId[16];
static char NewAirportLabel[] = "Enter New Airport ID";
static puOneShot *AptDialogOkButton = 0; static puOneShot *AptDialogOkButton = 0;
static puOneShot *AptDialogCancelButton = 0; static puOneShot *AptDialogCancelButton = 0;
static puOneShot *AptDialogResetButton = 0; static puOneShot *AptDialogResetButton = 0;
void AptDialog_Cancel(puObject *) void AptDialog_Cancel(puObject *)
{ {
AptDialogOkButton->makeReturnDefault(FALSE);
AptDialogInput->rejectInput();
FG_POP_PUI_DIALOG( AptDialog ); FG_POP_PUI_DIALOG( AptDialog );
} }
@ -414,7 +434,6 @@ void AptDialog_OK (puObject *)
if ( AptId.length() ) { if ( AptId.length() ) {
// set initial position from airport id // set initial position from airport id
fgAIRPORTS airports; fgAIRPORTS airports;
fgAIRPORT a; fgAIRPORT a;
@ -440,46 +459,48 @@ void AptDialog_OK (puObject *)
void AptDialog_Reset(puObject *) void AptDialog_Reset(puObject *)
{ {
AptDialogInput->setValue ( current_options.get_airport_id().c_str() ); // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
AptDialogInput->setValue ( NewAirportId );
AptDialogInput->setCursor( 0 ) ; AptDialogInput->setCursor( 0 ) ;
} }
void NewAirport(puObject *cb) void NewAirport(puObject *cb)
{ {
string AptLabel("Enter New Airport ID"); // strncpy( NewAirportId, current_options.get_airport_id().c_str(), 16 );
AptDialogMessage ->setLabel( AptLabel.c_str() ); sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
AptDialogInput ->setValue( current_options.get_airport_id().c_str() ); AptDialogInput->setValue( NewAirportId );
AptDialogInput ->acceptInput();
AptDialogOkButton->makeReturnDefault(TRUE);
FG_PUSH_PUI_DIALOG( AptDialog ); FG_PUSH_PUI_DIALOG( AptDialog );
} }
static void NewAirportInit(void) static void NewAirportInit(void)
{ {
cout << "NewAirportInit" << endl; sprintf( NewAirportId, "%s", current_options.get_airport_id().c_str() );
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
string AptLabel("Enter New Airport ID"); NewAirportLabel ) / 2;
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel.c_str() )/2;
AptDialog = new puDialogBox (150, 50); AptDialog = new puDialogBox (150, 50);
{ {
AptDialogFrame = new puFrame (0,0,350, 150); AptDialogFrame = new puFrame (0,0,350, 150);
AptDialogMessage = new puText (len, 110); AptDialogMessage = new puText (len, 110);
AptDialogMessage -> setLabel (NewAirportLabel);
AptDialogInput = new puInput ( 50, 70, 300, 100 ); AptDialogInput = new puInput (50, 70, 300, 100);
AptDialogInput -> setValue (NewAirportId);
AptDialogInput -> acceptInput();
AptDialogOkButton = new puOneShot (50, 10, 110, 50); AptDialogOkButton = new puOneShot (50, 10, 110, 50);
AptDialogOkButton -> setLegend ("OK"); AptDialogOkButton -> setLegend (gui_msg_OK);
AptDialogOkButton -> setCallback (AptDialog_OK); AptDialogOkButton -> setCallback (AptDialog_OK);
AptDialogOkButton -> makeReturnDefault(TRUE);
AptDialogCancelButton = new puOneShot (140, 10, 210, 50); AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
AptDialogCancelButton -> setLegend ("Cancel"); AptDialogCancelButton -> setLegend (gui_msg_CANCEL);
AptDialogCancelButton -> setCallback (AptDialog_Cancel); AptDialogCancelButton -> setCallback (AptDialog_Cancel);
AptDialogResetButton = new puOneShot (240, 10, 300, 50); AptDialogResetButton = new puOneShot (240, 10, 300, 50);
AptDialogResetButton -> setLegend ("Reset"); AptDialogResetButton -> setLegend (gui_msg_RESET);
AptDialogResetButton -> setCallback (AptDialog_Reset); AptDialogResetButton -> setCallback (AptDialog_Reset);
} }
FG_FINALIZE_PUI_DIALOG( AptDialog ); FG_FINALIZE_PUI_DIALOG( AptDialog );
@ -490,59 +511,87 @@ static void NewAirportInit(void)
The menu stuff The menu stuff
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
char *fileSubmenu [] = { char *fileSubmenu [] = {
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL }; "Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL
};
puCallback fileSubmenuCb [] = { puCallback fileSubmenuCb [] = {
MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL}; MayBeGoodBye, hideMenuCb, NULL, notCb, NULL, notCb, reInit, NULL
};
char *editSubmenu [] = { char *editSubmenu [] = {
"Edit text", NULL }; "Edit text", NULL
};
puCallback editSubmenuCb [] = { puCallback editSubmenuCb [] = {
notCb, NULL }; notCb, NULL
};
char *viewSubmenu [] = { char *viewSubmenu [] = {
"Cockpit View > ", "View >","------------", "Toggle Panel...", NULL }; "Cockpit View > ", "View >","------------", "Toggle Panel...", NULL
};
puCallback viewSubmenuCb [] = { puCallback viewSubmenuCb [] = {
notCb, notCb, NULL, guiTogglePanel, NULL }; notCb, notCb, NULL, guiTogglePanel, NULL
};
char *aircraftSubmenu [] = { char *aircraftSubmenu [] = {
"Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL}; "Autopilot", "Heading", "Altitude", "Navigation", "Communication", NULL
};
puCallback aircraftSubmenuCb [] = { puCallback aircraftSubmenuCb [] = {
fgAPAdjust, notCb, notCb, fgLatLonFormatToggle, notCb, NULL }; fgAPAdjust, NewHeading, NewAltitude, fgLatLonFormatToggle, notCb, NULL
};
char *environmentSubmenu [] = { char *environmentSubmenu [] = {
"Airport", "Terrain", "Weather", NULL}; "Airport", "Terrain", "Weather", NULL
};
puCallback environmentSubmenuCb [] = { puCallback environmentSubmenuCb [] = {
NewAirport, notCb, notCb, NULL }; NewAirport, notCb, notCb, NULL
};
char *optionsSubmenu [] = { char *optionsSubmenu [] = {
"Preferences", "Realism & Reliablity...", NULL}; "Preferences", "Realism & Reliablity...", NULL
};
puCallback optionsSubmenuCb [] = { puCallback optionsSubmenuCb [] = {
notCb, notCb, NULL}; notCb, notCb, NULL
};
char *helpSubmenu [] = { char *helpSubmenu [] = {
"About...", "Help", NULL }; "About...", "Help", NULL
};
puCallback helpSubmenuCb [] = { puCallback helpSubmenuCb [] = {
notCb, helpCb, NULL }; notCb, helpCb, NULL
};
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
init the gui init the gui
_____________________________________________________________________*/ _____________________________________________________________________*/
void guiInit() void guiInit()
{ {
char *mesa_win_state; char *mesa_win_state;
string fntpath;
// Initialize PUI // Initialize PUI
puInit(); puInit();
puSetDefaultStyle ( PUSTYLE_DEFAULT ); puSetDefaultStyle ( PUSTYLE_SMALL_BEVELLED ); //PUSTYLE_DEFAULT
puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4); puSetDefaultColourScheme (0.8, 0.8, 0.8, 0.4);
// Initialize our GLOBAL GUI STRINGS
gui_msg_OK = msg_OK; // "OK"
gui_msg_NO = msg_NO; // "NO"
gui_msg_YES = msg_YES; // "YES"
gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
gui_msg_RESET = msg_RESET; // "RESET"
// Next check home directory
char* envp = ::getenv( "FG_FONTS" );
if ( envp != NULL ) {
fntpath = envp;
} else {
fntpath = current_options.get_fg_root() + "/Fonts";
}
// Install our fast fonts // Install our fast fonts
string fntpath = current_options.get_fg_root() + "/Fonts/" + fntpath += "/typewriter.txf";
"typewriter" + ".txf";
guiFntHandle = new fntTexFont ; guiFntHandle = new fntTexFont ;
guiFntHandle -> load ( fntpath.c_str() ) ; guiFntHandle -> load ( fntpath.c_str() ) ;
puFont GuiFont ( guiFntHandle, 15 ) ; puFont GuiFont ( guiFntHandle, 15 ) ;

View file

@ -34,13 +34,19 @@ extern void maybeToggleMouse( void );
extern void BusyCursor( int restore ); extern void BusyCursor( int restore );
extern void guiToggleMenu(void); extern void guiToggleMenu(void);
extern void mkDialog(char *txt); extern void mkDialog(const char *txt);
extern void ConfirmExitDialog(void); extern void ConfirmExitDialog(void);
extern void guiFixPanel( void ); extern void guiFixPanel( void );
extern puFont guiFnt; extern puFont guiFnt;
extern fntTexFont *guiFntHandle; extern fntTexFont *guiFntHandle;
// GLOBAL COMMON DIALOG BOX TEXT STRINGS
extern char *gui_msg_OK; // "OK"
extern char *gui_msg_NO; // "NO"
extern char *gui_msg_YES; // "YES"
extern char *gui_msg_CANCEL; // "CANCEL"
extern char *gui_msg_RESET; // "RESET"
// MACROS TO HELP KEEP PUI LIVE INTERFACE STACK IN SYNC // MACROS TO HELP KEEP PUI LIVE INTERFACE STACK IN SYNC
// These insure that the mouse is active when dialog is shown // These insure that the mouse is active when dialog is shown

View file

@ -47,8 +47,10 @@
#include <Cockpit/hud.hxx> #include <Cockpit/hud.hxx>
#include <GUI/gui.h> #include <GUI/gui.h>
#include <Include/fg_constants.h> #include <Include/fg_constants.h>
#include <Scenery/tilemgr.hxx>
#include <Objects/materialmgr.hxx> #include <Objects/materialmgr.hxx>
#include <plib/pu.h> #include <plib/pu.h>
#include <Time/fg_time.hxx>
#include <Time/light.hxx> #include <Time/light.hxx>
#include <Weather/weather.hxx> #include <Weather/weather.hxx>
@ -56,8 +58,8 @@
#include "options.hxx" #include "options.hxx"
#include "views.hxx" #include "views.hxx"
// extern void NewAltitude( puObject *cb ); extern void NewAltitude( puObject *cb );
// extern void NewHeading( puObject *cb ); extern void NewHeading( puObject *cb );
// Force an update of the sky and lighting parameters // Force an update of the sky and lighting parameters
static void local_update_sky_and_lighting_params( void ) { static void local_update_sky_and_lighting_params( void ) {
@ -344,6 +346,21 @@ void GLUTspecialkey(int k, int x, int y) {
} else { } else {
FG_LOG( FG_INPUT, FG_DEBUG, "" ); FG_LOG( FG_INPUT, FG_DEBUG, "" );
switch (k) { switch (k) {
case GLUT_KEY_F2: // F2 Reload Tile Cache...
{
int toggle_pause;
FG_LOG(FG_INPUT, FG_INFO, "ReIniting TileCache");
FGTime *t = FGTime::cur_time_params;
if( (toggle_pause = !t->getPause()) )
t->togglePauseMode();
BusyCursor(0);
fgTileMgrInit();
fgTileMgrUpdate();
BusyCursor(1);
if(toggle_pause)
t->togglePauseMode();
return;
}
case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest... case GLUT_KEY_F8: // F8 toggles fog ... off fastest nicest...
current_options.cycle_fog(); current_options.cycle_fog();
@ -379,12 +396,11 @@ void GLUTspecialkey(int k, int x, int y) {
return; return;
case GLUT_KEY_F11: // F11 Altitude Dialog. case GLUT_KEY_F11: // F11 Altitude Dialog.
FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function"); FG_LOG(FG_INPUT, FG_INFO, "Invoking Altitude call back function");
// NewAltitude( NULL ); NewAltitude( NULL );
//exit(1);
return; return;
case GLUT_KEY_F12: // F12 Heading Dialog... case GLUT_KEY_F12: // F12 Heading Dialog...
FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function"); FG_LOG(FG_INPUT, FG_INFO, "Invoking Heading call back function");
// NewHeading( NULL ); NewHeading( NULL );
return; return;
case GLUT_KEY_UP: case GLUT_KEY_UP:
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) { if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {