mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-13 07:05:12 +01:00
Make queueMessage take a printf-style format string
This commit is contained in:
parent
f12c77463d
commit
17e2f4816c
@ -11,12 +11,21 @@ StatusBar::StatusBar() : Menu(Gui::gui->small_font), TimeoutHandler()
|
||||
}
|
||||
|
||||
|
||||
void StatusBar::queueMessage(const char *message)
|
||||
void StatusBar::queueMessage(const char *fmt, ...)
|
||||
{
|
||||
char buf[255];
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
va_start(ap, fmt);
|
||||
r = vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Free the existing message if we are overwriting it */
|
||||
free((void*)this->messages[this->head]);
|
||||
|
||||
this->messages[this->head] = xstrdup(message);
|
||||
this->messages[this->head] = xstrdup(buf);
|
||||
|
||||
/* If this is the first message, display it as soon as possible */
|
||||
if (this->head == this->tail)
|
||||
|
@ -13,7 +13,7 @@ class StatusBar : public Menu, public TimeoutHandler
|
||||
public:
|
||||
StatusBar();
|
||||
|
||||
void queueMessage(const char *message);
|
||||
void queueMessage(const char *message, ...);
|
||||
|
||||
virtual void draw(SDL_Surface *where);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user