struct Message {
long start_time, show_until;
char *str;
+ Vec3 color;
Message *next;
};
static Message *msglist;
void show_message(const char *fmt, ...)
{
va_list ap;
+ va_start(ap, fmt);
+ show_messagev(timeout, Vec3(1, 1, 1), fmt, ap);
+ va_end(ap);
+}
+
+void show_message(long timeout, const Vec3 &color, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ show_messagev(timeout, color, fmt, ap);
+ va_end(ap);
+}
+
+void show_messagev(long timeout, const Vec3 &color, const char *fmt, va_list ap)
+{
char buf[512];
init();
- va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
- va_end(ap);
Message *msg = new Message;
int len = strlen(buf);
memcpy(msg->str, buf, len + 1);
msg->start_time = time_msec;
msg->show_until = time_msec + timeout;
+ msg->color = color;
Message dummy;
dummy.next = msglist;
long dur = msg->show_until - msg->start_time;
float alpha = smoothstep(0, trans_time, t) *
(1.0 - smoothstep(dur - trans_time, dur, t));
- glColor4f(1.0, 0.5, 0.1, alpha);
+ glColor4f(msg->color.x, msg->color.y, msg->color.z, alpha);
glTranslatef(0, -dtx_line_height(), 0);
dtx_string(msg->str);
msg = msg->next;