2001-01-08 20:55:16 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <simgear/constants.h>
|
|
|
|
#include <simgear/debug/logstream.hxx>
|
2001-03-25 14:20:12 +00:00
|
|
|
#include <simgear/misc/sg_path.hxx>
|
2001-01-08 20:55:16 +00:00
|
|
|
|
|
|
|
#include <Include/general.hxx>
|
|
|
|
|
|
|
|
#include <GL/glut.h>
|
2001-05-15 22:30:39 +00:00
|
|
|
#include <GL/gl.h>
|
2001-01-08 20:55:16 +00:00
|
|
|
|
|
|
|
#include <Airports/simple.hxx>
|
|
|
|
#include <FDM/flight.hxx>
|
|
|
|
#include <Main/fg_init.hxx>
|
2001-01-13 22:06:39 +00:00
|
|
|
#include <Main/fg_props.hxx>
|
2001-01-08 20:55:16 +00:00
|
|
|
#include <Main/globals.hxx>
|
2001-04-02 21:28:35 +00:00
|
|
|
#include <Scenery/tilemgr.hxx>
|
2001-01-08 20:55:16 +00:00
|
|
|
|
|
|
|
#include "gui.h"
|
|
|
|
#include "gui_local.hxx"
|
|
|
|
|
|
|
|
/// The beginnings of teleportation :-)
|
|
|
|
// Needs cleaning up but works
|
|
|
|
// These statics should disapear when this is a class
|
|
|
|
static puDialogBox *AptDialog = 0;
|
|
|
|
static puFrame *AptDialogFrame = 0;
|
|
|
|
static puText *AptDialogMessage = 0;
|
|
|
|
static puInput *AptDialogInput = 0;
|
|
|
|
|
|
|
|
static char NewAirportId[16];
|
|
|
|
static char NewAirportLabel[] = "Enter New Airport ID";
|
|
|
|
|
|
|
|
static puOneShot *AptDialogOkButton = 0;
|
|
|
|
static puOneShot *AptDialogCancelButton = 0;
|
|
|
|
static puOneShot *AptDialogResetButton = 0;
|
|
|
|
|
|
|
|
void AptDialog_Cancel(puObject *)
|
|
|
|
{
|
2001-04-02 21:28:35 +00:00
|
|
|
FG_POP_PUI_DIALOG( AptDialog );
|
2001-01-08 20:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AptDialog_OK (puObject *)
|
|
|
|
{
|
2001-10-28 16:16:30 +00:00
|
|
|
static const SGPropertyNode *longitude
|
|
|
|
= fgGetNode("/position/longitude-deg");
|
|
|
|
static const SGPropertyNode *latitude
|
|
|
|
= fgGetNode("/position/latitude-deg");
|
|
|
|
|
2001-04-02 21:28:35 +00:00
|
|
|
SGPath path( globals->get_fg_root() );
|
|
|
|
path.append( "Airports" );
|
|
|
|
path.append( "simple.mk4" );
|
|
|
|
FGAirports airports( path.c_str() );
|
|
|
|
|
|
|
|
FGAirport a;
|
|
|
|
|
|
|
|
int freeze = globals->get_freeze();
|
|
|
|
if(!freeze)
|
|
|
|
globals->set_freeze( true );
|
|
|
|
|
|
|
|
char *s;
|
|
|
|
AptDialogInput->getValue(&s);
|
|
|
|
string AptId(s);
|
|
|
|
|
|
|
|
cout << "AptDialog_OK " << AptId << " " << AptId.length() << endl;
|
|
|
|
|
|
|
|
AptDialog_Cancel( NULL );
|
|
|
|
|
|
|
|
if ( AptId.length() ) {
|
|
|
|
// set initial position from airport id
|
|
|
|
SG_LOG( SG_GENERAL, SG_INFO,
|
|
|
|
"Attempting to set starting position from airport code "
|
|
|
|
<< AptId );
|
|
|
|
|
|
|
|
if ( airports.search( AptId, &a ) )
|
|
|
|
{
|
2001-10-28 16:16:30 +00:00
|
|
|
// 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();
|
|
|
|
|
2001-10-10 18:15:07 +00:00
|
|
|
AptId = a.id.c_str(); /// NHV fix wrong case crash
|
2001-04-02 21:28:35 +00:00
|
|
|
fgSetString("/sim/startup/airport-id", AptId.c_str() );
|
2001-07-02 22:27:24 +00:00
|
|
|
// fgSetDouble("/position/altitude-ft", -9999.0 );
|
2001-04-02 21:28:35 +00:00
|
|
|
// fgSetPosFromAirportID( AptId );
|
|
|
|
fgSetPosFromAirportIDandHdg( AptId,
|
|
|
|
cur_fdm_state->get_Psi() *
|
|
|
|
SGD_RADIANS_TO_DEGREES);
|
|
|
|
BusyCursor(0);
|
|
|
|
fgReInitSubsystems();
|
2001-10-28 16:16:30 +00:00
|
|
|
// if ( global_tile_mgr.init() ) {
|
2001-04-02 21:28:35 +00:00
|
|
|
// Load the local scenery data
|
2001-10-28 16:16:30 +00:00
|
|
|
global_tile_mgr.update( longitude->getDoubleValue(),
|
2001-11-12 22:05:47 +00:00
|
|
|
latitude->getDoubleValue() );
|
2001-10-28 16:16:30 +00:00
|
|
|
// } else {
|
|
|
|
// SG_LOG( SG_GENERAL, SG_ALERT,
|
|
|
|
// "Error in Tile Manager initialization!" );
|
|
|
|
// exit(-1);
|
|
|
|
// }
|
2001-04-02 21:28:35 +00:00
|
|
|
BusyCursor(1);
|
|
|
|
} else {
|
|
|
|
AptId += " not in database.";
|
|
|
|
mkDialog(AptId.c_str());
|
|
|
|
}
|
|
|
|
}
|
2001-10-28 16:16:30 +00:00
|
|
|
if ( !freeze ) {
|
2001-04-02 21:28:35 +00:00
|
|
|
globals->set_freeze( false );
|
2001-10-28 16:16:30 +00:00
|
|
|
}
|
2001-01-08 20:55:16 +00:00
|
|
|
}
|
|
|
|
|
2001-04-02 21:28:35 +00:00
|
|
|
|
2001-01-08 20:55:16 +00:00
|
|
|
void AptDialog_Reset(puObject *)
|
|
|
|
{
|
2001-04-02 21:28:35 +00:00
|
|
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
|
|
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
|
|
|
AptDialogInput->setValue ( NewAirportId );
|
|
|
|
AptDialogInput->setCursor( 0 ) ;
|
2001-01-08 20:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewAirport(puObject *cb)
|
|
|
|
{
|
2001-04-02 21:28:35 +00:00
|
|
|
// strncpy( NewAirportId, fgGetString("/sim/startup/airport-id").c_str(), 16 );
|
|
|
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
|
|
|
// cout << "NewAirport " << NewAirportId << endl;
|
|
|
|
AptDialogInput->setValue( NewAirportId );
|
2001-01-08 20:55:16 +00:00
|
|
|
|
2001-04-02 21:28:35 +00:00
|
|
|
FG_PUSH_PUI_DIALOG( AptDialog );
|
2001-01-08 20:55:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewAirportInit(void)
|
|
|
|
{
|
2001-04-02 21:28:35 +00:00
|
|
|
sprintf( NewAirportId, "%s", fgGetString("/sim/startup/airport-id").c_str() );
|
2001-10-24 21:24:53 +00:00
|
|
|
int len = 150
|
|
|
|
- puGetDefaultLabelFont().getStringWidth( NewAirportLabel ) / 2;
|
2001-04-02 21:28:35 +00:00
|
|
|
|
|
|
|
AptDialog = new puDialogBox (150, 50);
|
|
|
|
{
|
|
|
|
AptDialogFrame = new puFrame (0,0,350, 150);
|
|
|
|
AptDialogMessage = new puText (len, 110);
|
|
|
|
AptDialogMessage -> setLabel (NewAirportLabel);
|
|
|
|
|
|
|
|
AptDialogInput = new puInput (50, 70, 300, 100);
|
|
|
|
AptDialogInput -> setValue (NewAirportId);
|
|
|
|
AptDialogInput -> acceptInput();
|
|
|
|
|
|
|
|
AptDialogOkButton = new puOneShot (50, 10, 110, 50);
|
|
|
|
AptDialogOkButton -> setLegend (gui_msg_OK);
|
|
|
|
AptDialogOkButton -> setCallback (AptDialog_OK);
|
|
|
|
AptDialogOkButton -> makeReturnDefault(TRUE);
|
|
|
|
|
|
|
|
AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
|
|
|
|
AptDialogCancelButton -> setLegend (gui_msg_CANCEL);
|
|
|
|
AptDialogCancelButton -> setCallback (AptDialog_Cancel);
|
|
|
|
|
|
|
|
AptDialogResetButton = new puOneShot (240, 10, 300, 50);
|
|
|
|
AptDialogResetButton -> setLegend (gui_msg_RESET);
|
|
|
|
AptDialogResetButton -> setCallback (AptDialog_Reset);
|
|
|
|
}
|
|
|
|
cout << "NewAirportInit " << NewAirportId << endl;
|
|
|
|
FG_FINALIZE_PUI_DIALOG( AptDialog );
|
2001-01-08 20:55:16 +00:00
|
|
|
}
|