]> git.mxchange.org Git - flightgear.git/commitdiff
Start of adding interaction between the user controlled aircraft and AI traffic,...
authorDurk Talsma <durk@localhost.(none)>
Sun, 3 Apr 2011 15:39:35 +0000 (17:39 +0200)
committerDurk Talsma <durk@localhost.(none)>
Sun, 3 Apr 2011 15:39:35 +0000 (17:39 +0200)
* 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 [new file with mode: 0644]
src/ATC/atc_mgr.hxx [new file with mode: 0644]
src/ATC/atcdialog.cxx [new file with mode: 0644]
src/ATC/atcdialog.hxx [new file with mode: 0644]

diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx
new file mode 100644 (file)
index 0000000..111816c
--- /dev/null
@@ -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 <iostream>
+
+#include <simgear/math/SGMath.hxx>
+#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 (file)
index 0000000..bef7269
--- /dev/null
@@ -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 <simgear/structure/SGReferenced.hxx>
+//#include <simgear/structure/SGSharedPtr.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
+
+
+#include <ATC/trafficcontrol.hxx>
+#include <ATC/atcdialog.hxx>
+//class FGATCController;
+
+
+typedef vector<FGATCController*> AtcVec;
+typedef vector<FGATCController*>::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 (file)
index 0000000..43bdd40
--- /dev/null
@@ -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 <Main/fg_commands.hxx>
+#include <Main/globals.hxx>
+
+#include <simgear/constants.h>
+#include <simgear/structure/commands.hxx>
+#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
+#include <simgear/misc/sgstream.hxx>
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
+
+#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 (file)
index 0000000..1a54deb
--- /dev/null
@@ -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 <simgear/constants.h>
+#include <simgear/structure/commands.hxx>
+#include <simgear/compiler.h>
+#include <simgear/props/props.hxx>
+#include <simgear/misc/sgstream.hxx>
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/structure/SGSharedPtr.hxx>
+
+
+#include <GUI/gui.h>           // mkDialog
+#include <GUI/new_gui.hxx>
+
+
+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