1
0
Fork 0

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.

This commit is contained in:
daveluff 2003-03-17 11:32:51 +00:00
parent b3930c9c60
commit 47f46d151d
2 changed files with 58 additions and 26 deletions

View file

@ -82,6 +82,8 @@ void FGATCDisplay::update(double dt) {
glColor3f( 0.9, 0.4, 0.2 ); glColor3f( 0.9, 0.4, 0.2 );
float fps = general.get_frame_rate();
if(rep_msg) { if(rep_msg) {
//cout << "dsp_offset1 = " << dsp_offset1 << " dsp_offset2 = " << dsp_offset2 << endl; //cout << "dsp_offset1 = " << dsp_offset1 << " dsp_offset2 = " << dsp_offset2 << endl;
if(dsp_offset1 == 0) { if(dsp_offset1 == 0) {
@ -100,8 +102,6 @@ void FGATCDisplay::update(double dt) {
change_msg_flag = false; change_msg_flag = false;
} }
float fps = general.get_frame_rate();
// guiFnt.drawString( rep_msg_str.c_str(), // guiFnt.drawString( rep_msg_str.c_str(),
// int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset), // int(iwidth - guiFnt.getStringWidth(buf) - 10 - (int)dsp_offset),
// (iheight - 20) ); // (iheight - 20) );
@ -131,27 +131,57 @@ void FGATCDisplay::update(double dt) {
if(msgList.size()) { if(msgList.size()) {
//cout << "Attempting to render single message\n"; //cout << "Attempting to render single message\n";
// We have at least one non-repeating message to process // We have at least one non-repeating message to process
msgList_itr = msgList.begin(); if(fgGetBool("/ATC/display/scroll-single-messages")) { // Scroll single messages across the screen.
int i = 0; msgList_itr = msgList.begin();
while(msgList_itr != msgList.end()) { int i = 0;
atcMessage m = *msgList_itr; while(msgList_itr != msgList.end()) {
//cout << "m.counter = " << m.counter << '\n'; atcMessage m = *msgList_itr;
if(m.counter > m.stop_count) { //cout << "m.counter = " << m.counter << '\n';
//cout << "Stopping single message\n"; if(m.dsp_offset > (iwidth + (m.msg.size() * 10))) {
msgList_itr = msgList.erase(msgList_itr); //cout << "Stopping single message\n";
} else if(m.counter > m.start_count) { msgList_itr = msgList.erase(msgList_itr);
guiFnt.drawString( m.msg.c_str(), } else if(m.counter > m.start_count) {
100, //cout << "Drawing single message\n";
(iheight - 40) ); // TODO - relate the distance in that the string is rendered to the string length. guiFnt.drawString( m.msg.c_str(),
++m.counter; int(iwidth - 10 - m.dsp_offset),
msgList[i] = m; (iheight - 40) );
++msgList_itr; ++m.counter;
++i; m.dsp_offset += (80.0/fps);
} else { msgList[i] = m;
++m.counter; ++msgList_itr;
msgList[i] = m; ++i;
++msgList_itr; } else {
++i; //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.repeating = false;
m.counter = 0; m.counter = 0;
m.start_count = delay * 30; // Fixme - need to use actual FPS 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'; //cout << "m.stop_count = " << m.stop_count << '\n';
m.id = 0; m.id = 0;
m.dsp_offset = 0.0;
msgList.push_back(m); msgList.push_back(m);
//cout << "Single message registered\n"; //cout << "Single message registered\n";

View file

@ -42,6 +42,7 @@ struct atcMessage {
int start_count; // value of counter at which display should start int start_count; // value of counter at which display should start
int stop_count; // value of counter at which display should stop int stop_count; // value of counter at which display should stop
int id; 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 // 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: private:
bool rep_msg; // Flag to indicate there is a repeating transmission to display 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 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 double dsp_offset1; // Used to set the correct position of scrolling display
float dsp_offset2; double dsp_offset2;
string rep_msg_str; // The repeating transmission to play string rep_msg_str; // The repeating transmission to play
atcMessageList msgList; atcMessageList msgList;
atcMessageListIterator msgList_itr; atcMessageListIterator msgList_itr;