From ff4004b261677104d958591635b084131b678d59 Mon Sep 17 00:00:00 2001 From: Durk Talsma <durk@localhost.(none)> Date: Tue, 5 Apr 2011 18:13:11 +0200 Subject: [PATCH] Some further testing of the ATC Dialog infrastructure. --- src/ATC/atc_mgr.cxx | 5 ++++- src/ATC/atc_mgr.hxx | 2 +- src/ATC/atcdialog.cxx | 40 ++++++++++++++++++++++++++-------------- src/ATC/atcdialog.hxx | 2 +- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx index 111816cab..ba71c6087 100644 --- a/src/ATC/atc_mgr.cxx +++ b/src/ATC/atc_mgr.cxx @@ -40,7 +40,10 @@ FGATCManager::~FGATCManager() { void FGATCManager::init() { SGSubsystem::init(); - dialog.init(); + currentATCDialog = new FGATCDialogNew; + currentATCDialog->init(); + + //dialog.init(); } void FGATCManager::addController(FGATCController *controller) { diff --git a/src/ATC/atc_mgr.hxx b/src/ATC/atc_mgr.hxx index bef72695d..c34c82446 100644 --- a/src/ATC/atc_mgr.hxx +++ b/src/ATC/atc_mgr.hxx @@ -46,7 +46,7 @@ class FGATCManager : public SGSubsystem { private: AtcVec activeStations; - FGATCDialogNew dialog; + //FGATCDialogNew dialog; // note that this variable should really replace the ugly global "currentATCDialog(); public: FGATCManager(); diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index 43bdd4049..d77a20187 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -32,11 +32,11 @@ #include "atcdialog.hxx" - +FGATCDialogNew *currentATCDialog; static bool doATCDialog(const SGPropertyNode* arg) { cerr << "Running doATCDialog" << endl; - current_atcdialog->PopupDialog(); + currentATCDialog->PopupDialog(); return(true); } @@ -62,18 +62,30 @@ void FGATCDialogNew::init() { //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); } + + // Display the ATC popup dialog box with options relevant to the users current situation. +// +// So, the first thing we need to do is check the frequency that our pilot's nav radio +// is currently tuned to. The dialog should always contain an option to to tune the +// to a particular frequency, void FGATCDialogNew::PopupDialog() { - const char *dialog_name = "atc-dialog"; - _gui = (NewGUI *)globals->get_subsystem("gui"); - SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name); - if (!dlg) - return; - if (dialogVisible) { - _gui->closeDialog(dialog_name); - } else { - _gui->showDialog(dialog_name); - } - dialogVisible = !dialogVisible; - return; + double onBoardRadioFreq0 = + fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz"); + double onBoardRadioFreq1 = + fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz"); + + const char *dialog_name = "atc-dialog"; + _gui = (NewGUI *)globals->get_subsystem("gui"); + SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name); + if (!dlg) + return; + + if (dialogVisible) { + _gui->closeDialog(dialog_name); + } else { + _gui->showDialog(dialog_name); + } + dialogVisible = !dialogVisible; + return; } diff --git a/src/ATC/atcdialog.hxx b/src/ATC/atcdialog.hxx index 1a54debfb..2e0aa2f74 100644 --- a/src/ATC/atcdialog.hxx +++ b/src/ATC/atcdialog.hxx @@ -58,6 +58,6 @@ public: void PopupDialog(); }; -extern FGATCDialogNew *current_atcdialog; +extern FGATCDialogNew *currentATCDialog; #endif // _ATC_DIALOG_HXX_ \ No newline at end of file