]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCdisplay.cxx
If it's a struct, it's not a class
[flightgear.git] / src / ATC / ATCdisplay.cxx
index e0c56f3ba469598c8bc7bb103fb3f1427b64bc6c..89588e0006f0967708853a3f4600016f2a9792c2 100644 (file)
 //
 // 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
 
-#include <simgear/misc/props.hxx>
+#ifdef HAVE_WINDOWS_H
+#   include <windows.h>
+#endif
+
+#include <simgear/compiler.h>
+
+#include SG_GLU_H
+
+#include <simgear/props/props.hxx>
 
 #include <Include/general.hxx>
 #include <Main/fg_props.hxx>
@@ -35,8 +43,8 @@
 FGATCDisplay::FGATCDisplay() {
        rep_msg = false;
        change_msg_flag = false;
-       dsp_offset1 = 0;
-       dsp_offset2 = 0;
+       dsp_offset1 = 0.0;
+       dsp_offset2 = 0.0;
 }
 
 
@@ -82,6 +90,8 @@ void FGATCDisplay::update(double dt) {
                
                glColor3f( 0.9, 0.4, 0.2 );
                
+               float fps = general.get_frame_rate();
+               
                if(rep_msg) {
                        //cout << "dsp_offset1 = " << dsp_offset1 << " dsp_offset2 = " << dsp_offset2 << endl;
                        if(dsp_offset1 == 0) {
@@ -100,8 +110,6 @@ void FGATCDisplay::update(double dt) {
                                change_msg_flag = false;
                        }
                        
-                       float fps = general.get_frame_rate();
-                       
                        //      guiFnt.drawString( rep_msg_str.c_str(),
                        //          int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset),
                        //          (iheight - 20) );
@@ -131,27 +139,57 @@ void FGATCDisplay::update(double dt) {
                if(msgList.size()) {
                        //cout << "Attempting to render single message\n";
                        // We have at least one non-repeating message to process
-                       msgList_itr = msgList.begin();
-                       int i = 0;
-                       while(msgList_itr != msgList.end()) {
-                               atcMessage m = *msgList_itr;
-                               //cout << "m.counter = " << m.counter << '\n';
-                               if(m.counter > m.stop_count) {
-                                       //cout << "Stopping single message\n";
-                                       msgList_itr = msgList.erase(msgList_itr);
-                               } else if(m.counter > m.start_count) {
-                                       guiFnt.drawString( m.msg.c_str(),
-                                       100,
-                                       (iheight - 40) );       // TODO - relate the distance in that the string is rendered to the string length.
-                                       ++m.counter;
-                                       msgList[i] = m;
-                                       ++msgList_itr;
-                                       ++i;
-                               } else {
-                                       ++m.counter;
-                                       msgList[i] = m;
-                                       ++msgList_itr;
-                                       ++i;
+                       if(fgGetBool("/ATC/display/scroll-single-messages")) {  // Scroll single messages across the screen.
+                               msgList_itr = msgList.begin();
+                               int i = 0;
+                               while(msgList_itr != msgList.end()) {
+                                       atcMessage m = *msgList_itr;
+                                       //cout << "m.counter = " << m.counter << '\n';
+                                       if(m.dsp_offset > (iwidth + (m.msg.size() * 10))) {
+                                               //cout << "Stopping single message\n";
+                                               msgList_itr = msgList.erase(msgList_itr);
+                                       } else if(m.counter > m.start_count) {
+                                               //cout << "Drawing single message\n";
+                                               guiFnt.drawString( m.msg.c_str(),
+                                               int(iwidth - 10 - m.dsp_offset),
+                                               (iheight - 40) );
+                                               m.counter += dt;
+                                               m.dsp_offset += (80.0/fps);
+                                               msgList[i] = m;
+                                               ++msgList_itr;
+                                               ++i;
+                                       } else {
+                                               //cout << "Not yet started single message\n";
+                                               m.counter += dt;
+                                               msgList[i] = m;
+                                               ++msgList_itr;
+                                               ++i;
+                                       }
+                               }
+                       } else {        // Display single messages for a short period of time.
+                               msgList_itr = msgList.begin();
+                               int i = 0;
+                               while(msgList_itr != msgList.end()) {
+                                       atcMessage m = *msgList_itr;
+                                       //cout << "m.counter = " << m.counter << '\n';
+                                       if(m.counter > m.stop_count) {
+                                               //cout << "Stopping single message\n";
+                                               msgList_itr = msgList.erase(msgList_itr);
+                                       } else if(m.counter > m.start_count) {
+                                               int pin = (((int)m.msg.size() * 8) >= iwidth ? 5 : (iwidth - (m.msg.size() * 8))/2);
+                                               //cout << m.msg << '\n';
+                                               //cout << "pin = " << pin << ", iwidth = " << iwidth << ", msg.size = " << m.msg.size() << '\n';
+                                               guiFnt.drawString( m.msg.c_str(), pin, (iheight - 40) );
+                                               m.counter += dt;
+                                               msgList[i] = m;
+                                               ++msgList_itr;
+                                               ++i;
+                                       } else {
+                                               m.counter += dt;
+                                               msgList[i] = m;
+                                               ++msgList_itr;
+                                               ++i;
+                                       }
                                }
                        }
                }
@@ -164,33 +202,39 @@ void FGATCDisplay::update(double dt) {
        }
 }
 
-void FGATCDisplay::RegisterSingleMessage(string msg, int delay) {
+void FGATCDisplay::RegisterSingleMessage(const string& msg, double delay) {
+/**/   return;
+       //cout << msg << '\n';
        atcMessage m;
        m.msg = msg;
        m.repeating = false;
-       m.counter = 0;
-       m.start_count = delay * 30;             // Fixme - need to use actual FPS
-       m.stop_count = m.start_count + 100;             // Display for 3 - 5 seconds for now - this might have to change eg. be related to length of message in future
+       m.counter = 0.0;
+       m.start_count = delay;
+       m.stop_count = m.start_count + 5.0;             // Display for 5ish seconds for now - this might have to change eg. be related to length of message in future
        //cout << "m.stop_count = " << m.stop_count << '\n';
        m.id = 0;
+       m.dsp_offset = 0.0;
        
        msgList.push_back(m);
        //cout << "Single message registered\n";
 }
 
-void FGATCDisplay::RegisterRepeatingMessage(string msg) {
+void FGATCDisplay::RegisterRepeatingMessage(const string& msg) {
+/**/   return;
        rep_msg = true;
        rep_msg_str = msg;
        return;
 }
 
-void FGATCDisplay::ChangeRepeatingMessage(string newmsg) {
+void FGATCDisplay::ChangeRepeatingMessage(const string& newmsg) {
+/**/   return;
        rep_msg_str = newmsg;
        change_msg_flag = true;
        return;
 }
 
 void FGATCDisplay::CancelRepeatingMessage() {
+/**/   return;
        rep_msg = false;
        rep_msg_str = "";
        dsp_offset1 = 0;