From 38eca9480dde71fabf295f6fb03c8286690d36ba Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 16 Apr 2016 11:00:19 +0100 Subject: [PATCH] Allow for important messages to be created (such as maydays from capital ships). --- src/battle/messageBox.c | 16 +++++++++++++--- src/battle/script.c | 7 ++++++- src/battle/script.h | 2 +- src/structs.h | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/battle/messageBox.c b/src/battle/messageBox.c index dcfeb37..29dc97d 100644 --- a/src/battle/messageBox.c +++ b/src/battle/messageBox.c @@ -31,7 +31,7 @@ void initMessageBox(void) tail = &head; } -void addMessageBox(char *title, char *body) +void addMessageBox(char *title, char *body, int important) { MessageBox *msg; float time; @@ -52,6 +52,7 @@ void addMessageBox(char *title, char *body) STRNCPY(msg->title, title, MAX_NAME_LENGTH); STRNCPY(msg->body, body, MAX_DESCRIPTION_LENGTH); msg->time = time * FPS; + msg->important = important; } void doMessageBox(void) @@ -113,8 +114,17 @@ void drawMessageBox(void) r.x = (SCREEN_WIDTH - r.w) / 2; SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND); - SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128); + + if (!msg->important) + { + SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128); + } + else + { + SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 64); + } SDL_RenderFillRect(app.renderer, &r); + SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 128); SDL_RenderDrawRect(app.renderer, &r); SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE); @@ -123,7 +133,7 @@ void drawMessageBox(void) limitTextWidth(575); - drawText(r.x + 10, r.y + 30, 18, TA_LEFT, colors.white, msg->body); + drawText(r.x + 10, r.y + 30, 18, TA_LEFT, (!msg->important) ? colors.white : colors.red, msg->body); limitTextWidth(0); } diff --git a/src/battle/script.c b/src/battle/script.c index d299911..2e2654a 100644 --- a/src/battle/script.c +++ b/src/battle/script.c @@ -226,7 +226,12 @@ static void executeNextLine(ScriptRunner *runner) else if (strcmp(command, "MSG_BOX") == 0) { sscanf(line, "%*s %255[^;]%*c%255[^\n]", strParam[0], strParam[1]); - addMessageBox(strParam[0], _(strParam[1])); + addMessageBox(strParam[0], _(strParam[1]), 0); + } + else if (strcmp(command, "IMPORTANT_MSG_BOX") == 0) + { + sscanf(line, "%*s %255[^;]%*c%255[^\n]", strParam[0], strParam[1]); + addMessageBox(strParam[0], _(strParam[1]), 1); } else if (strcmp(command, "WAIT") == 0) { diff --git a/src/battle/script.h b/src/battle/script.h index 073c08c..e0e9b5e 100644 --- a/src/battle/script.h +++ b/src/battle/script.h @@ -27,7 +27,7 @@ extern void failMission(void); extern void retreatEnemies(void); extern void retreatAllies(void); extern void addHudMessage(SDL_Color c, char *format, ...); -extern void addMessageBox(char *title, char *format, ...); +extern void addMessageBox(char *title, char *body, int important); extern void activateEntities(char *name); extern void activateEntityGroups(char *groupName); extern void activateLocations(char *locations); diff --git a/src/structs.h b/src/structs.h index a4f92ae..a83af67 100644 --- a/src/structs.h +++ b/src/structs.h @@ -425,6 +425,7 @@ struct MessageBox { char body[MAX_DESCRIPTION_LENGTH]; int time; int height; + int important; MessageBox *next; };