From 47f46d151d856a8bf8b0c039bba3976d41012c6c Mon Sep 17 00:00:00 2001 From: daveluff Date: Mon, 17 Mar 2003 11:32:51 +0000 Subject: [PATCH] Add the ability to scroll single ATC messages - this is toggled using property /ATC/display/scroll-single-messages (off by default). Also increased the time that single messages are displayed in non-scrolling mode - this makes ATC transmissions easier to read. --- src/ATC/ATCdisplay.cxx | 79 +++++++++++++++++++++++++++++------------- src/ATC/ATCdisplay.hxx | 5 +-- 2 files changed, 58 insertions(+), 26 deletions(-) diff --git a/src/ATC/ATCdisplay.cxx b/src/ATC/ATCdisplay.cxx index e0c56f3ba..de77e9b89 100644 --- a/src/ATC/ATCdisplay.cxx +++ b/src/ATC/ATCdisplay.cxx @@ -82,6 +82,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 +102,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 +131,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; + m.dsp_offset += (80.0/fps); + msgList[i] = m; + ++msgList_itr; + ++i; + } else { + //cout << "Not yet started single message\n"; + ++m.counter; + 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) { + 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; + msgList[i] = m; + ++msgList_itr; + ++i; + } else { + ++m.counter; + msgList[i] = m; + ++msgList_itr; + ++i; + } } } } @@ -170,9 +200,10 @@ void FGATCDisplay::RegisterSingleMessage(string msg, int delay) { 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.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 //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"; diff --git a/src/ATC/ATCdisplay.hxx b/src/ATC/ATCdisplay.hxx index c17d36c06..d3c9e1fca 100644 --- a/src/ATC/ATCdisplay.hxx +++ b/src/ATC/ATCdisplay.hxx @@ -42,6 +42,7 @@ struct atcMessage { int start_count; // value of counter at which display should start int stop_count; // value of counter at which display should stop int id; + double dsp_offset; }; // ASSUMPTION - with two radios the list won't be long so we don't need to map the id's @@ -54,8 +55,8 @@ class FGATCDisplay : public FGSubsystem private: bool rep_msg; // Flag to indicate there is a repeating transmission to display bool change_msg_flag; // Flag to indicate that the repeating message has changed - float dsp_offset1; // Used to set the correct position of scrolling display - float dsp_offset2; + double dsp_offset1; // Used to set the correct position of scrolling display + double dsp_offset2; string rep_msg_str; // The repeating transmission to play atcMessageList msgList; atcMessageListIterator msgList_itr; -- 2.39.5