]> git.mxchange.org Git - flightgear.git/blob - src/ATC/atcdialog.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / src / ATC / atcdialog.cxx
1 // atcdialog.cxx - classes to manage user interactions with AI traffic
2 // Written by Durk Talsma, started April 3, 2011
3 // Based on earlier code written by Alexander Kappes and David Luff
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 //
19 // $Id$
20
21 #include <Main/fg_commands.hxx>
22 #include <Main/globals.hxx>
23
24 #include <simgear/constants.h>
25 #include <simgear/structure/commands.hxx>
26 #include <simgear/compiler.h>
27 #include <simgear/props/props.hxx>
28 #include <simgear/misc/sgstream.hxx>
29 #include <simgear/math/sg_geodesy.hxx>
30 #include <simgear/debug/logstream.hxx>
31 #include <simgear/structure/SGSharedPtr.hxx>
32
33 #include "atcdialog.hxx"
34
35
36
37 static bool doATCDialog(const SGPropertyNode* arg) {
38         cerr << "Running doATCDialog" << endl;
39         current_atcdialog->PopupDialog();
40         return(true);
41 }
42
43 FGATCDialogNew::FGATCDialogNew()
44 {
45   dialogVisible = false;
46 }
47
48 FGATCDialogNew::~FGATCDialogNew()
49 {
50 }
51
52
53
54 void FGATCDialogNew::init() {
55         // Add ATC-dialog to the command list
56         globals->get_commands()->addCommand("ATC-dialog", doATCDialog);
57         // Add ATC-freq-search to the command list
58         //globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search);
59
60         // initialize properties polled in Update()
61         //globals->get_props()->setStringValue("/sim/atc/freq-airport", "");
62         //globals->get_props()->setIntValue("/sim/atc/transmission-num", -1);
63 }
64
65 // Display the ATC popup dialog box with options relevant to the users current situation.
66 void FGATCDialogNew::PopupDialog() {
67         const char *dialog_name = "atc-dialog";
68         _gui = (NewGUI *)globals->get_subsystem("gui");
69         SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
70         if (!dlg)
71                 return;
72         if (dialogVisible) {
73              _gui->closeDialog(dialog_name);
74         } else {
75              _gui->showDialog(dialog_name);
76         }
77         dialogVisible = !dialogVisible;
78         return;
79 }