]> git.mxchange.org Git - flightgear.git/blob - src/ATC/atcdialog.cxx
d77a20187395b5d239f2a2774a287681ef5432e9
[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 FGATCDialogNew *currentATCDialog;
36
37 static bool doATCDialog(const SGPropertyNode* arg) {
38         cerr << "Running doATCDialog" << endl;
39         currentATCDialog->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
66
67 // Display the ATC popup dialog box with options relevant to the users current situation.
68 // 
69 // So, the first thing we need to do is check the frequency that our pilot's nav radio
70 // is currently tuned to. The dialog should always contain an option to to tune the 
71 // to a particular frequency,
72 void FGATCDialogNew::PopupDialog() {
73     double onBoardRadioFreq0 =
74         fgGetDouble("/instrumentation/comm[0]/frequencies/selected-mhz");
75     double onBoardRadioFreq1 =
76         fgGetDouble("/instrumentation/comm[1]/frequencies/selected-mhz");
77
78     const char *dialog_name = "atc-dialog";
79     _gui = (NewGUI *)globals->get_subsystem("gui");
80     SGPropertyNode_ptr dlg = _gui->getDialogProperties(dialog_name);
81     if (!dlg)
82         return;
83     
84     if (dialogVisible) {
85         _gui->closeDialog(dialog_name);
86     } else {
87         _gui->showDialog(dialog_name);
88     }
89     dialogVisible = !dialogVisible;
90     return;
91 }