X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FGUI%2Fapt_dlg.cxx;h=d7c0b6334088acca8b96c5ab04f6fb4831ad5468;hb=f0e6716953604730579a5e45f785fd063737dce4;hp=49e3336d2fc1dd10adb9f6a01528ecca5bcfd08a;hpb=96fbc75b7c1a28c378d7e5473eac14f377a1e81f;p=flightgear.git diff --git a/src/GUI/apt_dlg.cxx b/src/GUI/apt_dlg.cxx index 49e3336d2..d7c0b6334 100644 --- a/src/GUI/apt_dlg.cxx +++ b/src/GUI/apt_dlg.cxx @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include @@ -51,6 +51,11 @@ void AptDialog_Cancel(puObject *) void AptDialog_OK (puObject *) { + static const SGPropertyNode *longitude + = fgGetNode("/position/longitude-deg"); + static const SGPropertyNode *latitude + = fgGetNode("/position/latitude-deg"); + SGPath path( globals->get_fg_root() ); path.append( "Airports" ); path.append( "simple.mk4" ); @@ -77,35 +82,39 @@ void AptDialog_OK (puObject *) << AptId ); if ( airports.search( AptId, &a ) ) - { - fgSetString("/sim/startup/airport-id", AptId.c_str() ); - // fgSetDouble("/position/altitude", -9999.0 ); - // fgSetPosFromAirportID( AptId ); - fgSetPosFromAirportIDandHdg( AptId, - cur_fdm_state->get_Psi() * - SGD_RADIANS_TO_DEGREES); - BusyCursor(0); - fgReInitSubsystems(); - if ( global_tile_mgr.init() ) { - // Load the local scenery data - global_tile_mgr.update( - cur_fdm_state->get_Longitude() - * SGD_RADIANS_TO_DEGREES, - cur_fdm_state->get_Latitude() - * SGD_RADIANS_TO_DEGREES ); - } 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()); - } + { + // unbind the current fdm state so property changes + // don't get lost when we subsequently delete this fdm + // and create a new one. + cur_fdm_state->unbind(); + + AptId = a.id.c_str(); /// NHV fix wrong case crash + fgSetString("/sim/startup/airport-id", AptId.c_str() ); + // fgSetDouble("/position/altitude-ft", -9999.0 ); + // fgSetPosFromAirportID( AptId ); + fgSetPosFromAirportIDandHdg( AptId, + cur_fdm_state->get_Psi() * + SGD_RADIANS_TO_DEGREES); + // BusyCursor(0); + fgReInitSubsystems(); + // if ( global_tile_mgr.init() ) { + // Load the local scenery data + global_tile_mgr.update( longitude->getDoubleValue(), + latitude->getDoubleValue() ); + // } 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) + if ( !freeze ) { globals->set_freeze( false ); + } } @@ -121,7 +130,7 @@ void NewAirport(puObject *cb) { // strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 ); sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() ); - // cout << "NewAirport " << NewAirportId << endl; + // cout << "NewAirport " << NewAirportId << endl; AptDialogInput->setValue( NewAirportId ); FG_PUSH_PUI_DIALOG( AptDialog ); @@ -130,8 +139,8 @@ void NewAirport(puObject *cb) void NewAirportInit(void) { sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() ); - int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), - NewAirportLabel ) / 2; + int len = 150 + - puGetDefaultLabelFont().getStringWidth( NewAirportLabel ) / 2; AptDialog = new puDialogBox (150, 50); {