1
0
Fork 0

Rationalisation of the ATC popup dialog code - moved it all over to AK's dynamic list system and removed the hardcoded list code, extended the dynamic list system a bit, started adding support for callbacks from the user interaction

This commit is contained in:
daveluff 2003-11-04 11:54:42 +00:00
parent 69f2597a0c
commit ed2e58d230
10 changed files with 203 additions and 332 deletions

View file

@ -55,6 +55,10 @@ void FGATC::Update(double dt) {
}
}
void FGATC::ReceiveUserCallback(int code) {
SG_LOG(SG_ATC, SG_WARN, "WARNING - whichever ATC class was intended to receive callback code " << code << " didn't get it!!!");
}
void FGATC::SetResponseReqd(string rid) {
receiving = false;
responseReqd = true;

View file

@ -111,6 +111,9 @@ public:
// wish to use the response timer functionality.
virtual void Update(double dt);
// Recieve a coded callback from the ATC menu system based on the user's selection
virtual void ReceiveUserCallback(int code);
// Add plane to a stack
virtual void AddPlane(string pid);

View file

@ -36,17 +36,11 @@
SG_USING_STD(ostringstream);
static void atcUppercase(string &s) {
for(unsigned int i=0; i<s.size(); ++i) {
s[i] = toupper(s[i]);
}
}
FGATCDialog *current_atcdialog;
// For the command manager - maybe eventually this should go in the built in command list
static bool do_ATC_dialog(const SGPropertyNode* arg) {
globals->get_ATC_mgr()->doPopupDialog();
current_atcdialog->PopupDialog();
return(true);
}
@ -57,36 +51,31 @@ static bool do_ATC_freq_search(const SGPropertyNode* arg) {
ATCMenuEntry::ATCMenuEntry() {
stationid = "";
stationfr = 0;
//stationfr = 0;
transmission = "";
menuentry = "";
callback_code = 0;
}
ATCMenuEntry::~ATCMenuEntry() {
}
static char* t0 = "No communication currently available";
//static char* t1 = "Request departure clearance";
//static char* t2 = "Report Runway vacated";
static char** towerOptions = new char*[2];
static void atcUppercase(string &s) {
for(unsigned int i=0; i<s.size(); ++i) {
s[i] = toupper(s[i]);
}
}
// ----------------------- DCL ------------------------------------------
// For the ATC dialog - copied from the Autopilot new heading dialog code!
// ----------------------- Popup Dialog Statics------------------
static puDialogBox* atcDialog;
static puFrame* atcDialogFrame;
static puText* atcDialogMessage;
//static puInput* atcDialogInput;
static puOneShot* atcDialogOkButton;
static puOneShot* atcDialogCancelButton;
static puButtonBox* atcDialogCommunicationOptions;
// ----------------------------------------------------------------------
//////////////////////////////////////////////////////
//
// STUFF FOR THE FREQUENCY SEARCH DIALOG
//
//////////////////////////////////////////////////////
// --------------------------------------------------------------
// ----------------------- Freq Dialog Statics-------------------
static const int ATC_MAX_FREQ_DISPLAY = 20; // Maximum number of frequencies that can be displayed for any one airport
static puDialogBox* atcFreqDialog;
@ -101,34 +90,12 @@ static puFrame* atcFreqDisplayFrame;
static puText* atcFreqDisplayMessage;
static puOneShot* atcFreqDisplayOkButton;
static puText* atcFreqDisplayText[ATC_MAX_FREQ_DISPLAY];
// --------------------------------------------------------------
static void FreqDialogCancel(puObject*) {
FG_POP_PUI_DIALOG(atcFreqDialog);
}
static void FreqDialogOK(puObject*) {
string tmp = atcFreqDialogInput->getStringValue();
FG_POP_PUI_DIALOG(atcFreqDialog);
current_atcdialog->FreqDisplay(tmp);
}
static void FreqDisplayOK(puObject*) {
FG_POP_PUI_DIALOG(atcFreqDisplay);
}
////////////// end freq search statics ///////////////
// ------------------------ AK ------------------------------------------
static puDialogBox *ATCMenuBox = 0;
static puFrame *ATCMenuFrame = 0;
static puText *ATCMenuBoxMessage = 0;
static puButtonBox *ATCOptionsList = 0;
// ----------------------------------------------------------------------
// AK
static void AKATCDialogOK(puObject *)
//////////////// Popup callbacks ///////////////////
static void ATCDialogOK(puObject *)
{
switch(ATCOptionsList->getValue()) {
switch(atcDialogCommunicationOptions->getValue()) {
case 0:
//cout << "Option 0 chosen\n";
fgSetBool("/sim/atc/opt0",true);
@ -148,165 +115,45 @@ static void AKATCDialogOK(puObject *)
default:
break;
}
FG_POP_PUI_DIALOG( ATCMenuBox );
}
// AK
static void AKATCDialogCancel(puObject *)
{
FG_POP_PUI_DIALOG( ATCMenuBox );
}
// DCL
static void ATCDialogCancel(puObject *)
{
//ATCDialogInput->rejectInput();
FG_POP_PUI_DIALOG( atcDialog );
}
// DCL
static void ATCDialogOK (puObject *me)
static void ATCDialogCancel(puObject *)
{
// Note that currently the dialog is hardwired to comm1 only here.
switch(globals->get_ATC_mgr()->GetComm1ATCType()) {
case INVALID:
break;
case ATIS:
break;
case TOWER: {
/*
FGTower* twr = (FGTower*)globals->get_ATC_mgr()->GetComm1ATCPointer();
switch(atcDialogCommunicationOptions->getValue()) {
case 0:
//cout << "Option 0 chosen\n";
twr->RequestLandingClearance("charlie foxtrot sierra");
break;
case 1:
//cout << "Option 1 chosen\n";
twr->RequestDepartureClearance("charlie foxtrot sierra");
break;
case 2:
//cout << "Option 2 chosen\n";
twr->ReportRunwayVacated("charlie foxtrot sierra");
break;
default:
break;
FG_POP_PUI_DIALOG( atcDialog );
}
*/
break;
}
case GROUND:
break;
case APPROACH:
break;
default:
break;
//////////////////////////////////////////////////
///////////////// Freq search callbacks ///////////
static void FreqDialogCancel(puObject*) {
FG_POP_PUI_DIALOG(atcFreqDialog);
}
ATCDialogCancel(me);
//if(error) mkDialog(s.c_str());
static void FreqDialogOK(puObject*) {
string tmp = atcFreqDialogInput->getStringValue();
FG_POP_PUI_DIALOG(atcFreqDialog);
current_atcdialog->FreqDisplay(tmp);
}
// DCL
static void ATCDialog(puObject *cb)
{
FG_PUSH_PUI_DIALOG(atcDialog);
static void FreqDisplayOK(puObject*) {
FG_POP_PUI_DIALOG(atcFreqDisplay);
}
//////////////////////////////////////////////////
// DCL
void ATCDialogInit()
{
char defaultATCLabel[] = "Enter desired option to communicate with ATC:";
char *s;
// Option lists hardwired per ATC type
towerOptions[0] = new char[strlen(t0)+1];
strcpy(towerOptions[0], t0);
//towerOptions[1] = new char[strlen(t1)+1];
//strcpy(towerOptions[1], t1);
//towerOptions[2] = new char[strlen(t2)+1];
//strcpy(towerOptions[2], t2);
towerOptions[1] = NULL;
atcDialog = new puDialogBox (150, 50);
{
atcDialogFrame = new puFrame (0, 0, 500, 250);
atcDialogMessage = new puText (250, 220);
atcDialogMessage -> setDefaultValue (defaultATCLabel);
atcDialogMessage -> getDefaultValue (&s);
atcDialogMessage -> setLabel (s);
atcDialogMessage -> setLabelPlace (PUPLACE_TOP_CENTERED);
atcDialogCommunicationOptions = new puButtonBox (50, 50, 450, 210, NULL, true);
atcDialogOkButton = new puOneShot (50, 10, 110, 50);
atcDialogOkButton -> setLegend (gui_msg_OK);
atcDialogOkButton -> makeReturnDefault (TRUE);
atcDialogOkButton -> setCallback (ATCDialogOK);
atcDialogCancelButton = new puOneShot (140, 10, 210, 50);
atcDialogCancelButton -> setLegend (gui_msg_CANCEL);
atcDialogCancelButton -> setCallback (ATCDialogCancel);
}
FG_FINALIZE_PUI_DIALOG(atcDialog);
// Add ATC-dialog to the command list
globals->get_commands()->addCommand("ATC-dialog", do_ATC_dialog);
}
///////////////////////////////////////////////////////////////////////
//
// ATCDoDialog is in a state of flux at the moment
// Stations other than approach are handled by DCL's simple code
// Approach is handled by AK's fancy dynamic-list code
// Hopefully all interactive stations should go to AK's code eventually
//
///////////////////////////////////////////////////////////////////////
void ATCDoDialog(atc_type type) {
switch(type) {
case INVALID:
atcDialogCommunicationOptions->newList(NULL);
atcDialogMessage->setLabel("Not tuned in to any ATC service.");
break;
case ATIS:
atcDialogCommunicationOptions->newList(NULL);
atcDialogMessage->setLabel("Tuned in to ATIS: no communication possible.");
break;
case TOWER:
atcDialogCommunicationOptions->newList(towerOptions);
atcDialogMessage->setLabel("Tuned in to Tower - select communication to transmit:");
break;
case GROUND:
atcDialogCommunicationOptions->newList(NULL);
atcDialogMessage->setLabel("Tuned in to Ground - select communication to transmit:");
break;
case APPROACH:
current_atcdialog->DoDialog();
break;
default:
atcDialogCommunicationOptions->newList(NULL);
atcDialogMessage->setLabel("Tuned in to unknown ATC service - enter transmission:");
break;
}
// Third - display the dialog without pausing sim.
if(type != APPROACH) {
ATCDialog(NULL);
}
}
FGATCDialog::FGATCDialog() {
}
FGATCDialog::~FGATCDialog() {
if(atcDialog) puDeleteObject(atcDialog);
if(atcFreqDialog) puDeleteObject(atcFreqDialog);
if(atcFreqDisplay) puDeleteObject(atcFreqDisplay);
if(ATCMenuBox) puDeleteObject(ATCMenuBox);
}
void FGATCDialog::Init() {
// Add ATC-dialog to the command list
globals->get_commands()->addCommand("ATC-dialog", do_ATC_dialog);
// Add ATC-freq-search to the command list
globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search);
@ -380,47 +227,69 @@ void FGATCDialog::Init() {
x = (fgGetInt("/sim/startup/xsize") / 2) - (w / 2);
//y = (fgGetInt("/sim/startup/ysize") / 2) - (h / 2);
y = 50;
ATCMenuBox = new puDialogBox (x, y);
atcDialog = new puDialogBox (x, y);
{
ATCMenuFrame = new puFrame (0,0,w,h);
ATCMenuBoxMessage = new puText (w / 2, h - 30);
ATCMenuBoxMessage -> setLabel( "No transmission available" );
ATCMenuBoxMessage -> setLabelPlace(PUPLACE_TOP_CENTERED);
ATCOptionsList = new puButtonBox (50, 60, 450, 50, NULL, true);
ATCOptionsList -> hide();
atcDialogFrame = new puFrame (0,0,w,h);
atcDialogMessage = new puText (w / 2, h - 30);
atcDialogMessage -> setLabel( "No transmission available" );
atcDialogMessage -> setLabelPlace(PUPLACE_TOP_CENTERED);
atcDialogCommunicationOptions = new puButtonBox (50, 60, 450, 50, NULL, true);
atcDialogCommunicationOptions -> hide();
atcDialogOkButton = new puOneShot ((w/2)-85, 10, (w/2)-25, 50);
atcDialogOkButton -> setLegend (gui_msg_OK);
atcDialogOkButton -> makeReturnDefault (TRUE);
atcDialogOkButton -> setCallback (AKATCDialogOK);
atcDialogOkButton -> setCallback (ATCDialogOK);
atcDialogCancelButton = new puOneShot ((w/2)+25, 10, (w/2)+85, 50);
atcDialogCancelButton -> setLegend (gui_msg_CANCEL);
atcDialogCancelButton -> setCallback (AKATCDialogCancel);
atcDialogCancelButton -> setCallback (ATCDialogCancel);
}
FG_FINALIZE_PUI_DIALOG(ATCMenuBox);
FG_FINALIZE_PUI_DIALOG(atcDialog);
}
// AK
// Add an entry
void FGATCDialog::add_entry(string station, string transmission, string menutext ) {
void FGATCDialog::add_entry(string station, string transmission, string menutext, atc_type type, int code) {
ATCMenuEntry a;
a.stationid = station;
a.transmission = transmission;
a.menuentry = menutext;
a.callback_code = code;
atcmentrylist_station[station.c_str()].push_back(a);
//atcmentrylist_station[station.c_str()].push_back(a);
(available_dialog[type])[station.c_str()].push_back(a);
}
// AK
// query the database whether the transmission is already registered;
bool FGATCDialog::trans_reg( const string &station, const string &trans ) {
void FGATCDialog::remove_entry( const string &station, const string &trans, atc_type type ) {
atcmentry_vec_type atcmlist = (available_dialog[type])[station];
atcmentry_vec_iterator current = atcmlist.begin();
atcmentry_vec_iterator last = atcmlist.end();
atcmentry_list_type atcmlist = atcmentrylist_station[station];
atcmentry_list_iterator current = atcmlist.begin();
atcmentry_list_iterator last = atcmlist.end();
while(current != last) {
if(current->transmission == trans) current = atcmlist.erase(current);
else ++current;
}
}
void FGATCDialog::remove_entry( const string &station, int code, atc_type type ) {
atcmentry_vec_type atcmlist = (available_dialog[type])[station];
atcmentry_vec_iterator current = atcmlist.begin();
atcmentry_vec_iterator last = atcmlist.end();
while(current != last) {
if(current->callback_code == code) current = atcmlist.erase(current);
else ++current;
}
}
// query the database whether the transmission is already registered;
bool FGATCDialog::trans_reg( const string &station, const string &trans, atc_type type ) {
//atcmentry_list_type atcmlist = atcmentrylist_station[station];
atcmentry_vec_type atcmlist = (available_dialog[type])[station];
atcmentry_vec_iterator current = atcmlist.begin();
atcmentry_vec_iterator last = atcmlist.end();
for ( ; current != last ; ++current ) {
if ( current->transmission == trans ) return true;
@ -428,11 +297,21 @@ bool FGATCDialog::trans_reg( const string &station, const string &trans ) {
return false;
}
// AK
// ===================================================
// === Update ATC menue and look for keys pressed ===
// ===================================================
void FGATCDialog::DoDialog() {
// query the database whether the transmission is already registered;
bool FGATCDialog::trans_reg( const string &station, int code, atc_type type ) {
//atcmentry_list_type atcmlist = atcmentrylist_station[station];
atcmentry_vec_type atcmlist = (available_dialog[type])[station];
atcmentry_vec_iterator current = atcmlist.begin();
atcmentry_vec_iterator last = atcmlist.end();
for ( ; current != last ; ++current ) {
if ( current->callback_code == code ) return true;
}
return false;
}
// Display the ATC popup dialog box with options relevant to the users current situation.
void FGATCDialog::PopupDialog() {
static string mentry[10];
static string mtrans[10];
@ -440,12 +319,19 @@ void FGATCDialog::DoDialog() {
TransPar TPar;
FGATC* atcptr = globals->get_ATC_mgr()->GetComm1ATCPointer(); // Hardwired to comm1 at the moment
if(atcptr != NULL) {
int w = 500;
int h = 100;
if(atcptr) {
if(atcptr->GetType() == ATIS) {
atcDialogCommunicationOptions->hide();
atcDialogMessage -> setLabel( "Tuned to ATIS - no communication possible" );
atcDialogFrame->setSize(w, h);
atcDialogMessage -> setPosition(w / 2, h - 30);
} else {
atcmentry_list_type atcmlist = atcmentrylist_station[atcptr->get_ident()];
//atcmentry_list_type atcmlist = atcmentrylist_station["EGNX"];
atcmentry_list_iterator current = atcmlist.begin();
atcmentry_list_iterator last = atcmlist.end();
atcmentry_vec_type atcmlist = (available_dialog[atcptr->GetType()])[atcptr->get_ident()];
atcmentry_vec_iterator current = atcmlist.begin();
atcmentry_vec_iterator last = atcmlist.end();
// Set all opt flags to false before displaying box
fgSetBool("/sim/atc/opt0",false);
@ -459,12 +345,11 @@ void FGATCDialog::DoDialog() {
fgSetBool("/sim/atc/opt8",false);
fgSetBool("/sim/atc/opt9",false);
int w = 500;
int k = atcmlist.size();
int h = 110 + k * 25;
h += k * 25;
//cout << "k = " << k << '\n';
ATCMenuFrame->setSize(w, h);
atcDialogFrame->setSize(w, h);
if(k) {
// loop over all entries in atcmentrylist
@ -483,49 +368,25 @@ void FGATCDialog::DoDialog() {
++kk;
}
optList[k] = NULL;
ATCOptionsList->newList(optList);
ATCOptionsList->setSize(w-100, h-100);
ATCOptionsList->reveal();
ATCMenuBoxMessage -> setLabel( "ATC Menu" );
ATCMenuBoxMessage -> setPosition(w / 2, h - 30);
atcDialogCommunicationOptions->newList(optList);
atcDialogCommunicationOptions->setSize(w-100, h-100);
atcDialogCommunicationOptions->reveal();
atcDialogMessage -> setLabel( "ATC Menu" );
atcDialogMessage -> setPosition(w / 2, h - 30);
} else {
ATCOptionsList->hide();
ATCMenuBoxMessage -> setLabel( "No transmission available" );
ATCMenuBoxMessage -> setPosition(w / 2, h - 20);
atcDialogCommunicationOptions->hide();
atcDialogMessage -> setLabel( "No transmission available" );
atcDialogMessage -> setPosition(w / 2, h - 30);
}
}
} else {
atcDialogCommunicationOptions->hide();
atcDialogMessage -> setLabel( "Not currently tuned to any ATC service" );
atcDialogFrame->setSize(w, h);
atcDialogMessage -> setPosition(w / 2, h - 30);
}
FG_PUSH_PUI_DIALOG( ATCMenuBox );
/*
if ( atckey != -1 && TransDisplayed && mtrans[atckey-1].c_str() != "" ) {
cout << mtrans[atckey-1].c_str() << endl;
TPar = current_transmissionlist->extract_transpar( mtrans[atckey-1].c_str() );
current_atcmentrylist->reset = true;
current_transparlist->add_entry( TPar );
// transpar_list_type test = current_transparlist;
// transpar_list_iterator current = test.begin();
//for ( ; current != test.end(); ++current ) {
// current->tpar.intention;
//}
}
if ( current_atcmentrylist->freq != (int)(comm1_freq*100.0 + 0.5) ) {
current_atcmentrylist->reset = true;
}
// reset (delete) ATCmenue list if reset is true
if ( current_atcmentrylist->reset == true ) {
delete ( current_atcmentrylist );
current_atcmentrylist = new FGatcmentryList;
current_atcmentrylist->init( (int)(comm1_freq*100.0 + 0.5) );
if ( TransDisplayed ) {
FG_POP_PUI_DIALOG( ATCMenuBox );
TransDisplayed = false;
}
}
*/
}
FG_PUSH_PUI_DIALOG(atcDialog);
}

View file

@ -29,27 +29,27 @@
struct ATCMenuEntry {
string stationid; // ID of transmitting station
int stationfr; // ?
//int stationfr; // ?
string transmission; // Actual speech of transmission
string menuentry; // Shortened version for display in the dialog
int callback_code; // This code is supplied by the registering station, and then
// returned to the registering station if that option is chosen.
// The actual value is only understood by the registering station -
// FGATCDialog only stores it and returns it if appropriate.
ATCMenuEntry();
~ATCMenuEntry();
};
// convenience types
typedef vector < ATCMenuEntry > atcmentry_list_type;
typedef atcmentry_list_type::iterator atcmentry_list_iterator;
typedef atcmentry_list_type::const_iterator atcmentry_list_const_iterator;
typedef vector < ATCMenuEntry > atcmentry_vec_type;
typedef atcmentry_vec_type::iterator atcmentry_vec_iterator;
// typedef map < string, atcmentry_list_type, less<string> > atcmentry_map_type;
typedef map < string, atcmentry_list_type > atcmentry_map_type;
typedef map < string, atcmentry_vec_type > atcmentry_map_type;
typedef atcmentry_map_type::iterator atcmentry_map_iterator;
typedef atcmentry_map_type::const_iterator atcmentry_map_const_iterator;
void ATCDialogInit();
//void ATCDialogInit();
void ATCDoDialog(atc_type type);
//void ATCDoDialog(atc_type type);
class FGATCDialog {
@ -60,11 +60,17 @@ public:
void Init();
void DoDialog();
void PopupDialog();
void add_entry( string station, string transmission, string menutext );
void add_entry( string station, string transmission, string menutext, atc_type type, int code);
bool trans_reg( const string &station, const string &trans );
void remove_entry( const string &station, const string &trans, atc_type type );
void remove_entry( const string &station, int code, atc_type type );
bool trans_reg( const string &station, const string &trans, atc_type type );
bool trans_reg( const string &station, int code, atc_type type );
// Display a frequency search dialog for nearby stations
void FreqDialog();
@ -75,7 +81,7 @@ public:
private:
atcmentry_map_type atcmentrylist_station;
atcmentry_map_type available_dialog[ATC_NUM_TYPES];
int freq;
bool reset;

View file

@ -131,12 +131,6 @@ void FGATCMgr::init() {
current_atcdialog = new FGATCDialog;
current_atcdialog->Init();
ATCDialogInit();
// DCL - testing
//current_atcdialog->add_entry( "EGNX", "Request vectoring for approach", "Request Vectors" );
//current_atcdialog->add_entry( "EGNX", "Mayday, Mayday", "Declare Emergency" );
initDone = true;
}
@ -476,11 +470,6 @@ FGATCVoice* FGATCMgr::GetVoicePointer(atc_type type) {
}
}
// Display a dialog box with options relevant to the currently tuned ATC service.
void FGATCMgr::doPopupDialog() {
ATCDoDialog(comm_type[0]); // FIXME - currently hardwired to comm1
}
// Search for ATC stations by frequency
void FGATCMgr::FreqSearch(int channel) {
int chan = channel - 1; // Convert to zero-based for the arrays

View file

@ -167,9 +167,6 @@ public:
// Returns NULL if service doesn't exist - calling function should check for this.
FGATC* GetATCPointer(string icao, atc_type type);
// Display a dialog box with options relevant to the currently tuned ATC service.
void doPopupDialog();
// Return a pointer to an appropriate voice for a given type of ATC
// creating the voice if necessary - ie. make sure exactly one copy
// of every voice in use exists in memory.

View file

@ -87,7 +87,7 @@ void FGApproach::Update(double dt) {
const int max_trans = 20;
FGTransmission tmissions[max_trans];
int wpn;
int station = 1;
atc_type station = APPROACH;
TransCode code;
TransPar TPar;
int i,j;
@ -111,7 +111,7 @@ void FGApproach::Update(double dt) {
for (i=0; i<num_planes; i++) {
if ( planes[i].ident == "Player") {
station = 1;
station = APPROACH;
tpars.station = name;
tpars.callsign = "Player";
tpars.airport = ident;
@ -133,8 +133,8 @@ void FGApproach::Update(double dt) {
mentry = current_transmissionlist->gen_text(station, code, tpars, false);
transm = current_transmissionlist->gen_text(station, code, tpars, true);
// is the transmission already registered?
if (!current_atcdialog->trans_reg( ident, transm )) {
current_atcdialog->add_entry( ident, transm, mentry );
if (!current_atcdialog->trans_reg( ident, transm, APPROACH )) {
current_atcdialog->add_entry( ident, transm, mentry, APPROACH, 0 );
}
}
}
@ -233,7 +233,7 @@ void FGApproach::Update(double dt) {
tpars.alt = planes[i].aalt;
message = current_transmissionlist->gen_text(station, code, tpars, true );
//cout << "Approach transmitting...\n";
//cout << message << '\n';
//cout << message << endl;
globals->get_ATC_display()->RegisterSingleMessage( message, 0 );
}
@ -244,7 +244,7 @@ void FGApproach::Update(double dt) {
tpars.runway = active_runway;
message = current_transmissionlist->gen_text(station, code, tpars, true);
//cout << "Approach transmitting 2 ...\n";
//cout << message << '\n';
//cout << message << endl;
globals->get_ATC_display()->RegisterSingleMessage( message, 0 );
}
planes[i].lmc = code;

View file

@ -46,6 +46,8 @@
#include <iomanip.h>
#endif
#include "ATC.hxx"
#if ! defined( SG_HAVE_NATIVE_SGI_COMPILERS )
SG_USING_STD(istream);
#endif
@ -79,7 +81,8 @@ struct TransPar {
// FGTransmission - a class to encapsulate a speech transmission
class FGTransmission {
int StationType; // Type of ATC station: 1 Approach
//int StationType; // Type of ATC station: 1 Approach
atc_type StationType;
TransCode Code; // DCL - no idea what this is.
string TransText; // The text of the spoken transmission
string MenuText; // An abbreviated version of the text for the menu entry
@ -91,7 +94,7 @@ public:
void Init();
inline int get_station() const { return StationType; }
inline atc_type get_station() const { return StationType; }
inline TransCode get_code() { return Code; }
inline string get_transtext() { return TransText; }
inline string get_menutext() { return MenuText; }
@ -109,6 +112,7 @@ private:
inline istream&
operator >> ( istream& in, FGTransmission& a ) {
char ch;
int tmp;
static bool first_time = true;
static double julian_date = 0;
@ -117,7 +121,13 @@ operator >> ( istream& in, FGTransmission& a ) {
julian_date = sgTimeCurrentMJD(0, 0) + MJD0;
first_time = false;
}
in >> a.StationType;
// Ugly hack alert - eventually we'll use xml format for the transmissions file
in >> tmp;
if(tmp == 1) {
a.StationType = APPROACH;
} else {
a.StationType = INVALID;
}
in >> a.Code.c1;
in >> a.Code.c2;
in >> a.Code.c3;

View file

@ -117,7 +117,7 @@ bool FGTransmissionList::init( SGPath path ) {
// query the database for the specified station type;
// for station see FlightGear/ATC/default.transmissions
bool FGTransmissionList::query_station( const int &station, FGTransmission *t,
bool FGTransmissionList::query_station( const atc_type &station, FGTransmission *t,
int max_trans, int &num_trans )
{
transmission_list_type tmissions = transmissionlist_station[station];
@ -142,7 +142,7 @@ bool FGTransmissionList::query_station( const int &station, FGTransmission *t,
}
}
string FGTransmissionList::gen_text(const int &station, const TransCode code,
string FGTransmissionList::gen_text(const atc_type &station, const TransCode code,
const TransPar &tpars, const bool ttext )
{
const int cmax = 300;

View file

@ -33,6 +33,7 @@
#include <plib/pu.h>
#include "ATC.hxx"
#include "transmission.hxx"
SG_USING_STD(map);
@ -47,7 +48,7 @@ class FGTransmissionList {
// Map of transmission lists by station type
// typedef map < int, transmission_list_type, less<int> > transmission_map_type;
typedef map < int, transmission_list_type > transmission_map_type;
typedef map < atc_type, transmission_list_type > transmission_map_type;
typedef transmission_map_type::iterator transmission_map_iterator;
typedef transmission_map_type::const_iterator transmission_map_const_iterator;
@ -62,13 +63,13 @@ public:
bool init( SGPath path );
// query the database for the specified code,
bool query_station( const int &station, FGTransmission *a, int max_trans, int &num_trans );
bool query_station( const atc_type &station, FGTransmission *a, int max_trans, int &num_trans );
// generate the transmission text given the code of the message
// and the parameters
// Set ttext = true to generate the spoken transmission text,
// or false to generate the abridged menu entry text.
string gen_text(const int &station, const TransCode code,
string gen_text(const atc_type &station, const TransCode code,
const TransPar &tpars, const bool ttext);
};