Set message box time automatically. Added WAIT_MSG_BOX command.

This commit is contained in:
Steve 2015-11-28 17:00:54 +00:00
parent d231be1bd2
commit 008e2aac8c
7 changed files with 44 additions and 23 deletions

View File

@ -63,7 +63,7 @@
"lines" : [
"ACTIVATE_ENTITY Pandoran",
"ACTIVATE_OBJECTIVE 1",
"MSG_BOX 6 Alba Control;Patrol A-82, you have hostiles incoming. Identified as 3 Mitikas fighters; Jackals, possibly Pandoran. Engage, but exercise extreme caution."
"MSG_BOX Alba Control;Patrol A-82, you have hostiles incoming. Identified as 3 Mitikas fighters; Jackals, possibly Pandoran. Engage, but exercise extreme caution."
]
}
]

View File

@ -81,25 +81,24 @@
{
"function" : "ALLIES_KILLED 70",
"lines" : [
"MSG_BOX 4 UNF Pilot #1;We're getting our arses kicked here! Any chance of any backup?!"
"MSG_BOX UNF Pilot #1;We're getting our arses kicked here! Any chance of any backup?!"
]
},
{
"function" : "ALLIES_KILLED 80",
"lines" : [
"MSG_BOX 4 UNF Pilot #2;The White Knights are here! Finally!",
"MSG_BOX UNF Pilot #2;The White Knights are here! Finally!",
"ACTIVATE_ENTITY ATAFs"
]
},
{
"function" : "ALLIES_KILLED 90",
"lines" : [
"MSG_BOX 6 UNF Talos;All fighters, Captain Bailey has signalled the retreat. Coyote is lost. Fall back to the extraction point.",
"MSG_BOX 4 Cdr de Winter;You all heard the Captain - fall back, we'll cover the retreat.",
"WAIT 8",
"MSG_BOX 4 Lt Cdr Dodds;Estelle, we've got this. We can take them.",
"MSG_BOX 4 Cdr de Winter;We're taking too many losses, Dodds. Fall back now, that's an order.",
"WAIT 8",
"MSG_BOX UNF Talos;All fighters, Captain Bailey has signalled the retreat. Coyote is lost. Fall back to the extraction point.",
"MSG_BOX Cdr de Winter;You all heard the Captain - fall back, we'll cover the retreat.",
"MSG_BOX Lt Cdr Dodds;Estelle, we've got this. We can take them.",
"MSG_BOX Cdr de Winter;We're taking too many losses, Dodds. Fall back now, that's an order.",
"WAIT_MSG_BOX",
"ACTIVATE_ENTITY Extraction Point",
"RETREAT_ALLIES"
]

View File

@ -120,7 +120,7 @@
{
"function" : "Waypoint #2",
"lines" : [
"MSG_BOX 5 Alexandria Orbital;Patrol, we're again identifying a handful of crates drifting close to your current position. Please effect pick up.",
"MSG_BOX Alexandria Orbital;Patrol, we're again identifying a handful of crates drifting close to your current position. Please effect pick up.",
"ACTIVATE_ENTITY package",
"ACTIVATE_OBJECTIVE 1"
]
@ -128,9 +128,9 @@
{
"function" : "Waypoint #4",
"lines" : [
"MSG_BOX 8 Alexandria Orbital;Patrol, a stranded Dart has been spotted nearby. A tug has been dispatch to bring it in. Please escort it to the target's location.",
"MSG_BOX 4 1st Lt Carr;Know anything about the occupant, or affiliation?",
"MSG_BOX 6 Alexandria Orbital;Negative, Lieutenant. We'll know more once it's brought in.",
"MSG_BOX Alexandria Orbital;Patrol, a stranded Dart has been spotted nearby. A tug has been dispatch to bring it in. Please escort it to the target's location.",
"MSG_BOX 1st Lt Carr;Know anything about the occupant, or affiliation?",
"MSG_BOX Alexandria Orbital;Negative, Lieutenant. We'll know more once it's brought in.",
"ACTIVATE_ENTITY Stranded Dart",
"ACTIVATE_ENTITY Tug",
"ACTIVATE_OBJECTIVE 2"
@ -140,14 +140,14 @@
"function" : "TOWING Stranded Dart",
"lines" : [
"WAIT 2",
"MSG_BOX 4 Tug;Tow cable attached. Ready to head home.",
"MSG_BOX 4 1st Lt Carr;We're done here. Let's bring our mystery guest in.",
"MSG_BOX Tug;Tow cable attached. Ready to head home.",
"MSG_BOX 1st Lt Carr;We're done here. Let's bring our mystery guest in.",
"ACTIVATE_ENTITY Extraction Point",
"WAIT 20",
"ACTIVATE_ENTITY Dart",
"ACTIVATE_OBJECTIVE 3",
"MSG_BOX 4 TAF Pilot;Dan, we've got enemy vessels inbound. More Darts.",
"MSG_BOX 4 1st Lt Carr;Prepare to engage. Protect the asset!"
"MSG_BOX TAF Pilot;Dan, we've got enemy vessels inbound. More Darts.",
"MSG_BOX 1st Lt Carr;Prepare to engage. Protect the asset!"
]
}
]

View File

@ -29,13 +29,19 @@ void initMessageBox(void)
tail = &head;
}
void addMessageBox(int time, char *title, char *body)
void addMessageBox(char *title, char *body)
{
MessageBox *msg = malloc(sizeof(MessageBox));
MessageBox *msg;
float time;
msg = malloc(sizeof(MessageBox));
memset(msg, 0, sizeof(MessageBox));
tail->next = msg;
tail = msg;
time = 0.075 * strlen(body);
time = MIN(MAX(time, 3), 7);
STRNCPY(msg->title, title, MAX_NAME_LENGTH);
STRNCPY(msg->body, body, MAX_DESCRIPTION_LENGTH);
msg->time = time * FPS;
@ -66,6 +72,11 @@ void doMessageBox(void)
}
}
int showingMessageBoxes(void)
{
return head.next != NULL;
}
void drawMessageBox(void)
{
MessageBox *msg = head.next;

View File

@ -44,7 +44,12 @@ void doScript(void)
{
runner->delay = MAX(0, runner->delay - 1);
if (!runner->delay)
if (runner->waitForMessageBox)
{
runner->waitForMessageBox = showingMessageBoxes();
}
if (!runner->delay && !runner->waitForMessageBox)
{
executeNextLine(runner);
@ -133,14 +138,18 @@ static void executeNextLine(ScriptRunner *runner)
}
else if (strcmp(command, "MSG_BOX") == 0)
{
sscanf(line, "%*s %d %[^;]%*c%[^\n]", &intParam[0], strParam[0], strParam[1]);
addMessageBox(intParam[0], strParam[0], strParam[1]);
sscanf(line, "%*s %[^;]%*c%[^\n]", strParam[0], strParam[1]);
addMessageBox(strParam[0], strParam[1]);
}
else if (strcmp(command, "WAIT") == 0)
{
sscanf(line, "%*s %d", &intParam[0]);
runner->delay = intParam[0] * FPS;
}
else if (strcmp(command, "WAIT_MSG_BOX") == 0)
{
runner->waitForMessageBox = 1;
}
else if (strcmp(command, "COMPLETE_MISSION") == 0)
{
addHudMessage(colors.green, "Mission Complete!");

View File

@ -29,10 +29,11 @@ extern void failMission(void);
extern void retreatEnemies(void);
extern void retreatAllies(void);
extern void addHudMessage(SDL_Color c, char *format, ...);
extern void addMessageBox(int time, char *title, char *format, ...);
extern void addMessageBox(char *title, char *format, ...);
extern void activateEntities(char *name);
extern void activateEntityGroup(char *groupName);
extern void activateObjective(int num);
extern int showingMessageBoxes(void);
extern Battle battle;
extern Colors colors;

View File

@ -255,6 +255,7 @@ typedef struct {
struct ScriptRunner {
struct cJSON *line;
long delay;
int waitForMessageBox;
ScriptRunner *next;
};