]> git.mxchange.org Git - flightgear.git/blobdiff - src/ATC/ATCdisplay.cxx
Catch sound exceptions at the earliest, report problem has an alert, and continue...
[flightgear.git] / src / ATC / ATCdisplay.cxx
index de77e9b89681c53bce39a945d011ef5d480f95f1..cd05ca4d08f5de330a8f09a09168f2fb3c142bc8 100644 (file)
 #  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;
 }
 
 
@@ -145,14 +153,14 @@ void FGATCDisplay::update(double dt) {
                                                guiFnt.drawString( m.msg.c_str(),
                                                int(iwidth - 10 - m.dsp_offset),
                                                (iheight - 40) );
-                                               ++m.counter;
+                                               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;
+                                               m.counter += dt;
                                                msgList[i] = m;
                                                ++msgList_itr;
                                                ++i;
@@ -168,16 +176,16 @@ void FGATCDisplay::update(double dt) {
                                                //cout << "Stopping single message\n";
                                                msgList_itr = msgList.erase(msgList_itr);
                                        } else if(m.counter > m.start_count) {
-                                               guiFnt.drawString( m.msg.c_str(),
-                                               (iwidth - (m.msg.size() * 8))/2,
-                                               //iwidth/2,
-                                               (iheight - 40) );       // TODO - relate the distance in that the string is rendered to the string length.
-                                               ++m.counter;
+                                               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;
+                                               m.counter += dt;
                                                msgList[i] = m;
                                                ++msgList_itr;
                                                ++i;
@@ -194,13 +202,14 @@ void FGATCDisplay::update(double dt) {
        }
 }
 
-void FGATCDisplay::RegisterSingleMessage(string msg, int delay) {
+void FGATCDisplay::RegisterSingleMessage(const string& msg, double delay) {
+       //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 + 400;             // 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;
@@ -209,13 +218,13 @@ void FGATCDisplay::RegisterSingleMessage(string msg, int delay) {
        //cout << "Single message registered\n";
 }
 
-void FGATCDisplay::RegisterRepeatingMessage(string msg) {
+void FGATCDisplay::RegisterRepeatingMessage(const string& msg) {
        rep_msg = true;
        rep_msg_str = msg;
        return;
 }
 
-void FGATCDisplay::ChangeRepeatingMessage(string newmsg) {
+void FGATCDisplay::ChangeRepeatingMessage(const string& newmsg) {
        rep_msg_str = newmsg;
        change_msg_flag = true;
        return;