Allow for important messages to be created (such as maydays from capital ships).
This commit is contained in:
parent
344b2d27b8
commit
38eca9480d
|
@ -31,7 +31,7 @@ void initMessageBox(void)
|
||||||
tail = &head;
|
tail = &head;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addMessageBox(char *title, char *body)
|
void addMessageBox(char *title, char *body, int important)
|
||||||
{
|
{
|
||||||
MessageBox *msg;
|
MessageBox *msg;
|
||||||
float time;
|
float time;
|
||||||
|
@ -52,6 +52,7 @@ void addMessageBox(char *title, char *body)
|
||||||
STRNCPY(msg->title, title, MAX_NAME_LENGTH);
|
STRNCPY(msg->title, title, MAX_NAME_LENGTH);
|
||||||
STRNCPY(msg->body, body, MAX_DESCRIPTION_LENGTH);
|
STRNCPY(msg->body, body, MAX_DESCRIPTION_LENGTH);
|
||||||
msg->time = time * FPS;
|
msg->time = time * FPS;
|
||||||
|
msg->important = important;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doMessageBox(void)
|
void doMessageBox(void)
|
||||||
|
@ -113,8 +114,17 @@ void drawMessageBox(void)
|
||||||
r.x = (SCREEN_WIDTH - r.w) / 2;
|
r.x = (SCREEN_WIDTH - r.w) / 2;
|
||||||
|
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
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_RenderFillRect(app.renderer, &r);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 128);
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 128);
|
||||||
SDL_RenderDrawRect(app.renderer, &r);
|
SDL_RenderDrawRect(app.renderer, &r);
|
||||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||||
|
@ -123,7 +133,7 @@ void drawMessageBox(void)
|
||||||
|
|
||||||
limitTextWidth(575);
|
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);
|
limitTextWidth(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,12 @@ static void executeNextLine(ScriptRunner *runner)
|
||||||
else if (strcmp(command, "MSG_BOX") == 0)
|
else if (strcmp(command, "MSG_BOX") == 0)
|
||||||
{
|
{
|
||||||
sscanf(line, "%*s %255[^;]%*c%255[^\n]", strParam[0], strParam[1]);
|
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)
|
else if (strcmp(command, "WAIT") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,7 +27,7 @@ extern void failMission(void);
|
||||||
extern void retreatEnemies(void);
|
extern void retreatEnemies(void);
|
||||||
extern void retreatAllies(void);
|
extern void retreatAllies(void);
|
||||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
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 activateEntities(char *name);
|
||||||
extern void activateEntityGroups(char *groupName);
|
extern void activateEntityGroups(char *groupName);
|
||||||
extern void activateLocations(char *locations);
|
extern void activateLocations(char *locations);
|
||||||
|
|
|
@ -425,6 +425,7 @@ struct MessageBox {
|
||||||
char body[MAX_DESCRIPTION_LENGTH];
|
char body[MAX_DESCRIPTION_LENGTH];
|
||||||
int time;
|
int time;
|
||||||
int height;
|
int height;
|
||||||
|
int important;
|
||||||
MessageBox *next;
|
MessageBox *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue