Base length of time messages are displayed for on dt rather than iterations in order to de-couple it from frame rate
This commit is contained in:
parent
df2ce45ab7
commit
3364b6f19d
2 changed files with 12 additions and 12 deletions
|
@ -145,14 +145,14 @@ void FGATCDisplay::update(double dt) {
|
||||||
guiFnt.drawString( m.msg.c_str(),
|
guiFnt.drawString( m.msg.c_str(),
|
||||||
int(iwidth - 10 - m.dsp_offset),
|
int(iwidth - 10 - m.dsp_offset),
|
||||||
(iheight - 40) );
|
(iheight - 40) );
|
||||||
++m.counter;
|
m.counter += dt;
|
||||||
m.dsp_offset += (80.0/fps);
|
m.dsp_offset += (80.0/fps);
|
||||||
msgList[i] = m;
|
msgList[i] = m;
|
||||||
++msgList_itr;
|
++msgList_itr;
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
//cout << "Not yet started single message\n";
|
//cout << "Not yet started single message\n";
|
||||||
++m.counter;
|
m.counter += dt;
|
||||||
msgList[i] = m;
|
msgList[i] = m;
|
||||||
++msgList_itr;
|
++msgList_itr;
|
||||||
++i;
|
++i;
|
||||||
|
@ -172,12 +172,12 @@ void FGATCDisplay::update(double dt) {
|
||||||
(iwidth - (m.msg.size() * 8))/2,
|
(iwidth - (m.msg.size() * 8))/2,
|
||||||
//iwidth/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 += dt;
|
||||||
msgList[i] = m;
|
msgList[i] = m;
|
||||||
++msgList_itr;
|
++msgList_itr;
|
||||||
++i;
|
++i;
|
||||||
} else {
|
} else {
|
||||||
++m.counter;
|
m.counter += dt;
|
||||||
msgList[i] = m;
|
msgList[i] = m;
|
||||||
++msgList_itr;
|
++msgList_itr;
|
||||||
++i;
|
++i;
|
||||||
|
@ -194,13 +194,13 @@ void FGATCDisplay::update(double dt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FGATCDisplay::RegisterSingleMessage(string msg, int delay) {
|
void FGATCDisplay::RegisterSingleMessage(string msg, double delay) {
|
||||||
atcMessage m;
|
atcMessage m;
|
||||||
m.msg = msg;
|
m.msg = msg;
|
||||||
m.repeating = false;
|
m.repeating = false;
|
||||||
m.counter = 0;
|
m.counter = 0.0;
|
||||||
m.start_count = delay * 30; // Fixme - need to use actual FPS
|
m.start_count = delay;
|
||||||
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.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';
|
//cout << "m.stop_count = " << m.stop_count << '\n';
|
||||||
m.id = 0;
|
m.id = 0;
|
||||||
m.dsp_offset = 0.0;
|
m.dsp_offset = 0.0;
|
||||||
|
|
|
@ -38,9 +38,9 @@ SG_USING_STD(string);
|
||||||
struct atcMessage {
|
struct atcMessage {
|
||||||
string msg;
|
string msg;
|
||||||
bool repeating;
|
bool repeating;
|
||||||
int counter; // count of how many iterations since posting
|
double counter; // count of how many seconds since the message was registered
|
||||||
int start_count; // value of counter at which display should start
|
double start_count; // value of counter at which display should start (seconds)
|
||||||
int stop_count; // value of counter at which display should stop
|
double stop_count; // value of counter at which display should stop (seconds)
|
||||||
int id;
|
int id;
|
||||||
double dsp_offset;
|
double dsp_offset;
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
|
|
||||||
// Register a single message for display after a delay of delay seconds
|
// Register a single message for display after a delay of delay seconds
|
||||||
// Will automatically stop displaying after a suitable interval.
|
// Will automatically stop displaying after a suitable interval.
|
||||||
void RegisterSingleMessage(string msg, int delay); // OK - I know passing a string in and out is probably not good but it will have to do for now.
|
void RegisterSingleMessage(string msg, double delay); // OK - I know passing a string in and out is probably not good but it will have to do for now.
|
||||||
|
|
||||||
// For now we will assume only one repeating message at once
|
// For now we will assume only one repeating message at once
|
||||||
// This is not really robust
|
// This is not really robust
|
||||||
|
|
Loading…
Add table
Reference in a new issue