X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fui.cc;h=1a183240f38b0d7fd9bbae8a25e6d9429337da2c;hp=33fbccf60cc838aa507c775095a4c2ed7e75fdc7;hb=017ce4cb4c27802eb620227fd822f5e4e03efa3b;hpb=31e1ffedb543e048673b7ba969607fbb8214ac9a diff --git a/src/ui.cc b/src/ui.cc index 33fbccf..1a18324 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -14,6 +14,7 @@ static bool init(); struct Message { long start_time, show_until; char *str; + Vec3 color; Message *next; }; static Message *msglist; @@ -30,13 +31,26 @@ void set_message_timeout(long tm) 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); @@ -44,6 +58,7 @@ void show_message(const char *fmt, ...) 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; @@ -90,7 +105,7 @@ void draw_ui() 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;