From 48bb176e87b9567788882ab2e20b6fb4b6373543 Mon Sep 17 00:00:00 2001 From: Durk Talsma Date: Sun, 3 Apr 2011 17:39:35 +0200 Subject: [PATCH] Start of adding interaction between the user controlled aircraft and AI traffic, by means of ATC. * Started transfering the ATC infrastructure to be driven by it's own subsystem * Changed the bahavior of the "'" key so that it is no longer driven by ATCDCL, but it now triggered by the new subsystem based ATC module. --- src/ATC/atc_mgr.cxx | 52 ++++++++++++++++++++++++++++ src/ATC/atc_mgr.hxx | 59 ++++++++++++++++++++++++++++++++ src/ATC/atcdialog.cxx | 79 +++++++++++++++++++++++++++++++++++++++++++ src/ATC/atcdialog.hxx | 63 ++++++++++++++++++++++++++++++++++ 4 files changed, 253 insertions(+) create mode 100644 src/ATC/atc_mgr.cxx create mode 100644 src/ATC/atc_mgr.hxx create mode 100644 src/ATC/atcdialog.cxx create mode 100644 src/ATC/atcdialog.hxx diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx new file mode 100644 index 000000000..111816cab --- /dev/null +++ b/src/ATC/atc_mgr.cxx @@ -0,0 +1,52 @@ +/****************************************************************************** + * atc_mgr.cxx + * Written by Durk Talsma, started August 1, 2010. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + **************************************************************************/ + + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include +#include "atc_mgr.hxx" + + +FGATCManager::FGATCManager() { + +} + +FGATCManager::~FGATCManager() { + +} + +void FGATCManager::init() { + SGSubsystem::init(); + dialog.init(); +} + +void FGATCManager::addController(FGATCController *controller) { + activeStations.push_back(controller); +} + +void FGATCManager::update ( double time ) { + //cerr << "ATC update code is running at time: " << time << endl; +} diff --git a/src/ATC/atc_mgr.hxx b/src/ATC/atc_mgr.hxx new file mode 100644 index 000000000..bef72695d --- /dev/null +++ b/src/ATC/atc_mgr.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++ -*- ***************************************************** + * atic.hxx + * Written by Durk Talsma. Started August 1, 2010; based on earlier work + * by David C. Luff + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * + **************************************************************************/ + +/************************************************************************** + * The ATC Manager interfaces the users aircraft with the AI traffic system + * and also monitors the ongoing AI traffic patterns for potential conflicts + * and interferes where necessary. + *************************************************************************/ + +#ifndef _ATC_MGR_HXX_ +#define _ATC_MGR_HXX_ + +//#include +//#include +#include + + +#include +#include +//class FGATCController; + + +typedef vector AtcVec; +typedef vector::iterator AtcVecIterator; + +class FGATCManager : public SGSubsystem +{ +private: + AtcVec activeStations; + FGATCDialogNew dialog; + +public: + FGATCManager(); + ~FGATCManager(); + void init(); + void addController(FGATCController *controller); + void update(double time); +}; + +#endif // _ATC_MRG_HXX_ \ No newline at end of file diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx new file mode 100644 index 000000000..43bdd4049 --- /dev/null +++ b/src/ATC/atcdialog.cxx @@ -0,0 +1,79 @@ +// atcdialog.cxx - classes to manage user interactions with AI traffic +// Written by Durk Talsma, started April 3, 2011 +// Based on earlier code written by Alexander Kappes and David Luff +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// $Id$ + +#include
+#include
+ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "atcdialog.hxx" + + + +static bool doATCDialog(const SGPropertyNode* arg) { + cerr << "Running doATCDialog" << endl; + current_atcdialog->PopupDialog(); + return(true); +} + +FGATCDialogNew::FGATCDialogNew() +{ + dialogVisible = false; +} + +FGATCDialogNew::~FGATCDialogNew() +{ +} + + + +void FGATCDialogNew::init() { + // Add ATC-dialog to the command list + globals->get_commands()->addCommand("ATC-dialog", doATCDialog); + // Add ATC-freq-search to the command list + //globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search); + + // initialize properties polled in Update() + //globals->get_props()->setStringValue("/sim/atc/freq-airport", ""); + //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1); +} + +// Display the ATC popup dialog box with options relevant to the users current situation. +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; +} diff --git a/src/ATC/atcdialog.hxx b/src/ATC/atcdialog.hxx new file mode 100644 index 000000000..1a54debfb --- /dev/null +++ b/src/ATC/atcdialog.hxx @@ -0,0 +1,63 @@ +// atcdialog.hxx - classes to manage user interactions with AI traffic +// Written by Durk Talsma, started April 3, 2011 +// Based on earlier code written by Alexander Kappes and David Luff +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +// $Id$ + + +#ifndef _ATC_DIALOG_HXX_ +#define _ATC_DIALOG_HXX_ + + +#ifndef __cplusplus +# error This library requires C++ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include // mkDialog +#include + + +static bool doATCDialog(const SGPropertyNode* arg); + +class FGATCDialogNew { +private: + NewGUI *_gui; + bool dialogVisible; +public: + + FGATCDialogNew(); + ~FGATCDialogNew(); + + void init(); + + void update(double dt); + void PopupDialog(); +}; + +extern FGATCDialogNew *current_atcdialog; + +#endif // _ATC_DIALOG_HXX_ \ No newline at end of file