in roboschool/cpp-household/render-hud.cpp [7:107]
void Viz::_paint_hud()
{
using namespace SimpleRender;
const float MARGIN = 5.0f;
// if (!billboards.empty()) {
// const int TIMEOUT_SEC = 3;
// if (billboards.back().ts + 1000*TIMEOUT_SEC < QDateTime::currentMSecsSinceEpoch())
// billboards.pop_back();
// for (ConsoleMessage& msg: billboards) {
// glRasterPos3f( msg.pos.x(), msg.pos.y(), msg.pos.z() );
// glPixelZoom(1.0, -1.0);
// glDrawPixels(
// msg.msg_image.width(), msg.msg_image.height(),
// GL_BGRA, GL_UNSIGNED_BYTE,
// msg.msg_image.bits() );
// msg.pos.m_floats[2] += 0.01*Household::SCALE; // float upwards
// }
// }
if ((~view_options & (VIEW_NO_HUD|VIEW_NO_CAPTIONS))==0) return;
render_viewport->hud_update_start();
int top;
if (~view_options&VIEW_NO_CAPTIONS)
top = render_viewport->hud_print_score(score);
else
top = MARGIN;
QRect area(QPoint(0,0), render_viewport->hud_image.size());
QPainter p(&render_viewport->hud_image);
p.setCompositionMode(QPainter::CompositionMode_Source);
p.setPen(QColor(0xFFFFFF));
p.setFont(cx->score_font_small);
int bottom = win_h - MARGIN;
top += MARGIN;
if (( !console.empty() || !caption.msg_image.isNull() ) && (~view_options&VIEW_NO_CAPTIONS)) {
const int CONSOLE_SPACING = 10;
const int CONSOLE_TIMEOUT_SEC = 7;
if (!console.empty() && console.back().ts + 1000*CONSOLE_TIMEOUT_SEC < QDateTime::currentMSecsSinceEpoch())
console.pop_back();
if (!caption.msg_text.isEmpty()) {
QRect r(0, win_h - caption.msg_image.height(), caption.msg_image.width(), caption.msg_image.height());
p.drawImage(r, caption.msg_image);
render_viewport->hud_update(r);
bottom -= caption.msg_image.height();
}
for (const ConsoleMessage& msg: console) {
bottom -= msg.msg_image.height();
if (bottom < 0) break;
QRect r(MARGIN, bottom, msg.msg_image.width(), msg.msg_image.height());
p.drawImage(r, msg.msg_image);
render_viewport->hud_update(r);
bottom -= CONSOLE_SPACING;
}
}
history_advance(true);
int right = area.right() - HIST - MARGIN;
if (obs_hist.size() && (~view_options&VIEW_NO_HUD)) {
for (int c=0; c<(int)obs.size(); ++c) {
int x = right;
int y = top + 26*c;
QRect r(x, y, HIST, 20);
if ( (area & r) != r ) continue;
if ( r.bottom() > bottom ) continue;
drawhist(p, "obs", c, r, &obs_hist[0] + HIST*c, &obs[0] + c);
}
}
int top_reward = bottom;
if (reward_hist.size() && (~view_options&VIEW_NO_HUD)) {
for (int c=0; c<(int)reward.size(); ++c) {
int x = MARGIN;
int y = bottom - 56.0*((int)reward.size()-1-c);
QRect r(x, y-50, HIST, 50);
if ( (area & r) != r ) continue;
top_reward = r.top();
if ( r.top() < top ) continue;
drawhist(p, "rew", c, r, &reward_hist[0] + HIST*c, &reward[0] + c);
}
}
if (action_hist.size() && (~view_options&VIEW_NO_HUD)) {
for (int c=0; c<(int)action.size(); ++c) {
int x = MARGIN;
int y = top + 26*c;
QRect r(x, y, HIST, 20);
if ( (area & r) != r ) continue;
if ( r.bottom() > top_reward ) continue;
drawhist(p, "act", c, r, &action_hist[0] + HIST*c, &action[0] + c);
}
}
render_viewport->hud_update_finish();
}