Bug fix from Norman Vine.
This commit is contained in:
parent
4f7ac699e3
commit
96fbc75b7c
1 changed files with 84 additions and 71 deletions
|
@ -24,7 +24,7 @@
|
||||||
#include <Main/fg_init.hxx>
|
#include <Main/fg_init.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
//#include <Time/fg_time.hxx>
|
#include <Scenery/tilemgr.hxx>
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "gui_local.hxx"
|
#include "gui_local.hxx"
|
||||||
|
@ -46,103 +46,116 @@ static puOneShot *AptDialogResetButton = 0;
|
||||||
|
|
||||||
void AptDialog_Cancel(puObject *)
|
void AptDialog_Cancel(puObject *)
|
||||||
{
|
{
|
||||||
FG_POP_PUI_DIALOG( AptDialog );
|
FG_POP_PUI_DIALOG( AptDialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
void AptDialog_OK (puObject *)
|
void AptDialog_OK (puObject *)
|
||||||
{
|
{
|
||||||
SGPath path( globals->get_fg_root() );
|
SGPath path( globals->get_fg_root() );
|
||||||
path.append( "Airports" );
|
path.append( "Airports" );
|
||||||
path.append( "simple.mk4" );
|
path.append( "simple.mk4" );
|
||||||
FGAirports airports( path.c_str() );
|
FGAirports airports( path.c_str() );
|
||||||
|
|
||||||
FGAirport a;
|
FGAirport a;
|
||||||
|
|
||||||
int freeze = globals->get_freeze();
|
int freeze = globals->get_freeze();
|
||||||
if(!freeze)
|
if(!freeze)
|
||||||
globals->set_freeze( true );
|
globals->set_freeze( true );
|
||||||
|
|
||||||
char *s;
|
char *s;
|
||||||
AptDialogInput->getValue(&s);
|
AptDialogInput->getValue(&s);
|
||||||
string AptId(s);
|
string AptId(s);
|
||||||
|
|
||||||
cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
|
cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
|
||||||
|
|
||||||
AptDialog_Cancel( NULL );
|
AptDialog_Cancel( NULL );
|
||||||
|
|
||||||
if ( AptId.length() ) {
|
if ( AptId.length() ) {
|
||||||
// set initial position from airport id
|
// set initial position from airport id
|
||||||
SG_LOG( SG_GENERAL, SG_INFO,
|
SG_LOG( SG_GENERAL, SG_INFO,
|
||||||
"Attempting to set starting position from airport code "
|
"Attempting to set starting position from airport code "
|
||||||
<< AptId );
|
<< AptId );
|
||||||
|
|
||||||
if ( airports.search( AptId, &a ) )
|
if ( airports.search( AptId, &a ) )
|
||||||
{
|
{
|
||||||
fgSetString("/sim/startup/airport-id", AptId.c_str() );
|
fgSetString("/sim/startup/airport-id", AptId.c_str() );
|
||||||
// fgSetDouble("/position/altitude", -9999.0 );
|
// fgSetDouble("/position/altitude", -9999.0 );
|
||||||
// fgSetPosFromAirportID( AptId );
|
// fgSetPosFromAirportID( AptId );
|
||||||
fgSetPosFromAirportIDandHdg( AptId,
|
fgSetPosFromAirportIDandHdg( AptId,
|
||||||
cur_fdm_state->get_Psi() *
|
cur_fdm_state->get_Psi() *
|
||||||
SGD_RADIANS_TO_DEGREES);
|
SGD_RADIANS_TO_DEGREES);
|
||||||
BusyCursor(0);
|
BusyCursor(0);
|
||||||
fgReInitSubsystems();
|
fgReInitSubsystems();
|
||||||
BusyCursor(1);
|
if ( global_tile_mgr.init() ) {
|
||||||
} else {
|
// Load the local scenery data
|
||||||
AptId += " not in database.";
|
global_tile_mgr.update(
|
||||||
mkDialog(AptId.c_str());
|
cur_fdm_state->get_Longitude()
|
||||||
}
|
* SGD_RADIANS_TO_DEGREES,
|
||||||
}
|
cur_fdm_state->get_Latitude()
|
||||||
if(!freeze)
|
* SGD_RADIANS_TO_DEGREES );
|
||||||
globals->set_freeze( false );
|
} else {
|
||||||
|
SG_LOG( SG_GENERAL, SG_ALERT,
|
||||||
|
"Error in Tile Manager initialization!" );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
BusyCursor(1);
|
||||||
|
} else {
|
||||||
|
AptId += " not in database.";
|
||||||
|
mkDialog(AptId.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!freeze)
|
||||||
|
globals->set_freeze( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AptDialog_Reset(puObject *)
|
void AptDialog_Reset(puObject *)
|
||||||
{
|
{
|
||||||
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
||||||
AptDialogInput->setValue ( NewAirportId );
|
AptDialogInput->setValue ( NewAirportId );
|
||||||
AptDialogInput->setCursor( 0 ) ;
|
AptDialogInput->setCursor( 0 ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewAirport(puObject *cb)
|
void NewAirport(puObject *cb)
|
||||||
{
|
{
|
||||||
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
||||||
// cout << "NewAirport " << NewAirportId << endl;
|
// cout << "NewAirport " << NewAirportId << endl;
|
||||||
AptDialogInput->setValue( NewAirportId );
|
AptDialogInput->setValue( NewAirportId );
|
||||||
|
|
||||||
FG_PUSH_PUI_DIALOG( AptDialog );
|
FG_PUSH_PUI_DIALOG( AptDialog );
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewAirportInit(void)
|
void NewAirportInit(void)
|
||||||
{
|
{
|
||||||
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
||||||
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
|
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(),
|
||||||
NewAirportLabel ) / 2;
|
NewAirportLabel ) / 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);
|
AptDialogMessage -> setLabel (NewAirportLabel);
|
||||||
|
|
||||||
AptDialogInput = new puInput (50, 70, 300, 100);
|
AptDialogInput = new puInput (50, 70, 300, 100);
|
||||||
AptDialogInput -> setValue (NewAirportId);
|
AptDialogInput -> setValue (NewAirportId);
|
||||||
AptDialogInput -> acceptInput();
|
AptDialogInput -> acceptInput();
|
||||||
|
|
||||||
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
||||||
AptDialogOkButton -> setLegend (gui_msg_OK);
|
AptDialogOkButton -> setLegend (gui_msg_OK);
|
||||||
AptDialogOkButton -> setCallback (AptDialog_OK);
|
AptDialogOkButton -> setCallback (AptDialog_OK);
|
||||||
AptDialogOkButton -> makeReturnDefault(TRUE);
|
AptDialogOkButton -> makeReturnDefault(TRUE);
|
||||||
|
|
||||||
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
||||||
AptDialogCancelButton -> setLegend (gui_msg_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 (gui_msg_RESET);
|
AptDialogResetButton -> setLegend (gui_msg_RESET);
|
||||||
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
||||||
}
|
}
|
||||||
cout << "NewAirportInit " << NewAirportId << endl;
|
cout << "NewAirportInit " << NewAirportId << endl;
|
||||||
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue