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,6 +131,34 @@ 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
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(); msgList_itr = msgList.begin();
int i = 0; int i = 0;
while(msgList_itr != msgList.end()) { while(msgList_itr != msgList.end()) {
@ -141,7 +169,8 @@ void FGATCDisplay::update(double dt) {
msgList_itr = msgList.erase(msgList_itr); msgList_itr = msgList.erase(msgList_itr);
} else if(m.counter > m.start_count) { } else if(m.counter > m.start_count) {
guiFnt.drawString( m.msg.c_str(), guiFnt.drawString( m.msg.c_str(),
100, (iwidth - (m.msg.size() * 8))/2,
//iwidth/2,
(iheight - 40) ); // TODO - relate the distance in that the string is rendered to the string length. (iheight - 40) ); // TODO - relate the distance in that the string is rendered to the string length.
++m.counter; ++m.counter;
msgList[i] = m; msgList[i] = m;
@ -155,6 +184,7 @@ void FGATCDisplay::update(double dt) {
} }
} }
} }
}
glEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );
glEnable( GL_LIGHTING ); glEnable( GL_LIGHTING );
glMatrixMode( GL_PROJECTION ); glMatrixMode( GL_PROJECTION );
@ -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;