Maximum of 3 challenges per challenge mission.
This commit is contained in:
parent
05185950e4
commit
cb34b3b9b6
|
@ -148,6 +148,7 @@ static void drawObjectives(void)
|
||||||
|
|
||||||
static void drawChallenges(void)
|
static void drawChallenges(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
char *challengeStatus;
|
char *challengeStatus;
|
||||||
SDL_Color color;
|
SDL_Color color;
|
||||||
|
@ -164,8 +165,10 @@ static void drawChallenges(void)
|
||||||
|
|
||||||
y += 25;
|
y += 25;
|
||||||
|
|
||||||
for (c = game.currentMission->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||||
{
|
{
|
||||||
|
c = mission->challengeData.challenges[i];
|
||||||
|
|
||||||
y += 50;
|
y += 50;
|
||||||
|
|
||||||
color = colors.white;
|
color = colors.white;
|
||||||
|
|
|
@ -45,7 +45,6 @@ static SDL_Texture *planetTexture;
|
||||||
static PointF planet;
|
static PointF planet;
|
||||||
static int totalChallenges;
|
static int totalChallenges;
|
||||||
static int show;
|
static int show;
|
||||||
static Challenge *challenge[3];
|
|
||||||
static char timeLimit[MAX_DESCRIPTION_LENGTH];
|
static char timeLimit[MAX_DESCRIPTION_LENGTH];
|
||||||
static char restrictions[MAX_DESCRIPTION_LENGTH];
|
static char restrictions[MAX_DESCRIPTION_LENGTH];
|
||||||
static int hasRestrictions;
|
static int hasRestrictions;
|
||||||
|
@ -179,20 +178,8 @@ static void doChallenges(void)
|
||||||
|
|
||||||
static void updateChallengeMissionData(void)
|
static void updateChallengeMissionData(void)
|
||||||
{
|
{
|
||||||
Challenge *c;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
STRNCPY(timeLimit, timeToString(game.currentMission->challengeData.timeLimit, 0), MAX_DESCRIPTION_LENGTH);
|
STRNCPY(timeLimit, timeToString(game.currentMission->challengeData.timeLimit, 0), MAX_DESCRIPTION_LENGTH);
|
||||||
sprintf(restrictions, "%s", listRestrictions());
|
sprintf(restrictions, "%s", listRestrictions());
|
||||||
|
|
||||||
memset(challenge, 0, sizeof(Challenge*) * 3);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for (c = game.currentMission->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
|
||||||
{
|
|
||||||
challenge[i++] = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addRestriction(char *buffer, int restricted, char *description)
|
static void addRestriction(char *buffer, int restricted, char *description)
|
||||||
|
@ -262,7 +249,8 @@ static void draw(void)
|
||||||
|
|
||||||
static void drawChallenges(void)
|
static void drawChallenges(void)
|
||||||
{
|
{
|
||||||
Mission *c;
|
Mission *m;
|
||||||
|
Challenge *c;
|
||||||
SDL_Rect r;
|
SDL_Rect r;
|
||||||
int i, endIndex;
|
int i, endIndex;
|
||||||
|
|
||||||
|
@ -273,16 +261,16 @@ static void drawChallenges(void)
|
||||||
endIndex = startIndex + MAX_ITEMS;
|
endIndex = startIndex + MAX_ITEMS;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (c = game.challengeMissionHead.next ; c != NULL ; c = c->next)
|
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
||||||
{
|
{
|
||||||
c->rect = r;
|
m->rect = r;
|
||||||
|
|
||||||
if (i >= startIndex && i <= endIndex)
|
if (i >= startIndex && i <= endIndex)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
|
|
||||||
if (game.currentMission == c)
|
if (game.currentMission == m)
|
||||||
{
|
{
|
||||||
SDL_SetRenderDrawColor(app.renderer, 64, 128, 200, SDL_ALPHA_OPAQUE);
|
SDL_SetRenderDrawColor(app.renderer, 64, 128, 200, SDL_ALPHA_OPAQUE);
|
||||||
SDL_RenderFillRect(app.renderer, &r);
|
SDL_RenderFillRect(app.renderer, &r);
|
||||||
|
@ -297,9 +285,9 @@ static void drawChallenges(void)
|
||||||
|
|
||||||
drawText(r.x + (r.w / 2), r.y + 28, 30, TA_CENTER, colors.white, "%d", i + 1);
|
drawText(r.x + (r.w / 2), r.y + 28, 30, TA_CENTER, colors.white, "%d", i + 1);
|
||||||
|
|
||||||
if (c->available)
|
if (m->available)
|
||||||
{
|
{
|
||||||
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, (c->completedChallenges < c->totalChallenges) ? colors.white : colors.green, "%d / %d", c->completedChallenges, c->totalChallenges);
|
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, (m->completedChallenges < m->totalChallenges) ? colors.white : colors.green, "%d / %d", m->completedChallenges, m->totalChallenges);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -337,23 +325,26 @@ static void drawChallenges(void)
|
||||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - r.y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - r.y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
||||||
|
|
||||||
r.y -= 50;
|
r.y -= 50;
|
||||||
|
c = game.currentMission->challengeData.challenges[0];
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Craft: %s"), game.currentMission->craft);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Craft: %s"), game.currentMission->craft);
|
||||||
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (challenge[0]->passed) ? colors.green : colors.white, "1. %s", getChallengeDescription(challenge[0]));
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, c ? colors.green : colors.white, "1. %s", getChallengeDescription(c));
|
||||||
|
|
||||||
r.y -= 30;
|
r.y -= 30;
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Time Limit: %s"), timeLimit);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Time Limit: %s"), timeLimit);
|
||||||
|
|
||||||
if (challenge[1])
|
c = game.currentMission->challengeData.challenges[1];
|
||||||
|
if (c)
|
||||||
{
|
{
|
||||||
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (challenge[1]->passed) ? colors.green : colors.white, "2. %s", getChallengeDescription(challenge[1]));
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "2. %s", getChallengeDescription(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
r.y -= 30;
|
r.y -= 30;
|
||||||
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, hasRestrictions ? colors.red : colors.white, _("Restrictions: %s"), restrictions);
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, hasRestrictions ? colors.red : colors.white, _("Restrictions: %s"), restrictions);
|
||||||
|
|
||||||
if (challenge[2])
|
c = game.currentMission->challengeData.challenges[2];
|
||||||
|
if (c)
|
||||||
{
|
{
|
||||||
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (challenge[2]->passed) ? colors.green : colors.white, "3. %s", getChallengeDescription(challenge[2]));
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c) ? colors.green : colors.white, "3. %s", getChallengeDescription(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,10 +94,13 @@ void doChallenges(void)
|
||||||
|
|
||||||
static void updateChallenges(void)
|
static void updateChallenges(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
|
|
||||||
for (c = game.currentMission->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||||
{
|
{
|
||||||
|
c = mission->challengeData.challenges[i];
|
||||||
|
|
||||||
if (!c->passed)
|
if (!c->passed)
|
||||||
{
|
{
|
||||||
switch (c->type)
|
switch (c->type)
|
||||||
|
@ -237,10 +240,13 @@ char *getChallengeDescription(Challenge *c)
|
||||||
|
|
||||||
Challenge *getChallenge(Mission *mission, int type, int value)
|
Challenge *getChallenge(Mission *mission, int type, int value)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
|
|
||||||
for (c = mission->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||||
{
|
{
|
||||||
|
c = mission->challengeData.challenges[i];
|
||||||
|
|
||||||
if (c->type == type && c->value == value)
|
if (c->type == type && c->value == value)
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
|
@ -265,6 +271,7 @@ static char *getFormattedChallengeDescription(const char *format, ...)
|
||||||
|
|
||||||
void updateChallengeMissions(void)
|
void updateChallengeMissions(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Mission *m;
|
Mission *m;
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
|
|
||||||
|
@ -272,8 +279,10 @@ void updateChallengeMissions(void)
|
||||||
{
|
{
|
||||||
m->totalChallenges = m->completedChallenges = 0;
|
m->totalChallenges = m->completedChallenges = 0;
|
||||||
|
|
||||||
for (c = m->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||||
{
|
{
|
||||||
|
c = mission->challengeData.challenges[i];
|
||||||
|
|
||||||
m->totalChallenges++;
|
m->totalChallenges++;
|
||||||
|
|
||||||
if (c->passed)
|
if (c->passed)
|
||||||
|
|
|
@ -55,6 +55,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#define MAX_STARS 500
|
#define MAX_STARS 500
|
||||||
|
|
||||||
|
#define MAX_CHALLENGES 3
|
||||||
|
|
||||||
#define MAX_FONTS 32
|
#define MAX_FONTS 32
|
||||||
#define NUM_TEXT_BUCKETS 64
|
#define NUM_TEXT_BUCKETS 64
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,9 @@ static char *getAutoPlanet(char *filename);
|
||||||
|
|
||||||
Mission *loadMissionMeta(char *filename)
|
Mission *loadMissionMeta(char *filename)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Mission *mission;
|
Mission *mission;
|
||||||
Challenge *challenge, *challengeTail;
|
Challenge *challenge;
|
||||||
cJSON *root, *node;
|
cJSON *root, *node;
|
||||||
char *text;
|
char *text;
|
||||||
|
|
||||||
|
@ -72,8 +73,6 @@ Mission *loadMissionMeta(char *filename)
|
||||||
STRNCPY(mission->craft, cJSON_GetObjectItem(node, "type")->valuestring, MAX_NAME_LENGTH);
|
STRNCPY(mission->craft, cJSON_GetObjectItem(node, "type")->valuestring, MAX_NAME_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
challengeTail = &mission->challengeData.challengeHead;
|
|
||||||
|
|
||||||
node = cJSON_GetObjectItem(root, "challenge");
|
node = cJSON_GetObjectItem(root, "challenge");
|
||||||
|
|
||||||
if (node)
|
if (node)
|
||||||
|
@ -92,7 +91,9 @@ Mission *loadMissionMeta(char *filename)
|
||||||
{
|
{
|
||||||
node = node->child;
|
node = node->child;
|
||||||
|
|
||||||
while (node)
|
i = 0;
|
||||||
|
|
||||||
|
while (node && i < MAX_CHALLENGES)
|
||||||
{
|
{
|
||||||
challenge = malloc(sizeof(Challenge));
|
challenge = malloc(sizeof(Challenge));
|
||||||
memset(challenge, 0, sizeof(Challenge));
|
memset(challenge, 0, sizeof(Challenge));
|
||||||
|
@ -100,10 +101,11 @@ Mission *loadMissionMeta(char *filename)
|
||||||
challenge->type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
challenge->type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||||
challenge->value = cJSON_GetObjectItem(node, "value")->valueint;
|
challenge->value = cJSON_GetObjectItem(node, "value")->valueint;
|
||||||
|
|
||||||
challengeTail->next = challenge;
|
mission->challengeData.challenges[i] = challenge;
|
||||||
challengeTail = challenge;
|
|
||||||
|
|
||||||
node = node->next;
|
node = node->next;
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ typedef struct {
|
||||||
int noBoost;
|
int noBoost;
|
||||||
int noECM;
|
int noECM;
|
||||||
int noGuns;
|
int noGuns;
|
||||||
Challenge challengeHead;
|
Challenge *challenges[MAX_CHALLENGES];
|
||||||
} ChallengeData;
|
} ChallengeData;
|
||||||
|
|
||||||
struct Mission {
|
struct Mission {
|
||||||
|
|
|
@ -95,6 +95,7 @@ static cJSON *getMissionsJSON(StarSystem *starSystem)
|
||||||
|
|
||||||
static void saveChallenges(cJSON *gameJSON)
|
static void saveChallenges(cJSON *gameJSON)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
Mission *mission;
|
Mission *mission;
|
||||||
Challenge *c;
|
Challenge *c;
|
||||||
cJSON *missionsJSON, *missionJSON, *challengesJSON, *challengeJSON;
|
cJSON *missionsJSON, *missionJSON, *challengesJSON, *challengeJSON;
|
||||||
|
@ -109,8 +110,10 @@ static void saveChallenges(cJSON *gameJSON)
|
||||||
|
|
||||||
challengesJSON = cJSON_CreateArray();
|
challengesJSON = cJSON_CreateArray();
|
||||||
|
|
||||||
for (c = mission->challengeData.challengeHead.next ; c != NULL ; c = c->next)
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||||
{
|
{
|
||||||
|
c = mission->challengeData.challenges[i];
|
||||||
|
|
||||||
challengeJSON = cJSON_CreateObject();
|
challengeJSON = cJSON_CreateObject();
|
||||||
cJSON_AddStringToObject(challengeJSON, "type", getLookupName("CHALLENGE_", c->type));
|
cJSON_AddStringToObject(challengeJSON, "type", getLookupName("CHALLENGE_", c->type));
|
||||||
cJSON_AddNumberToObject(challengeJSON, "value", c->value);
|
cJSON_AddNumberToObject(challengeJSON, "value", c->value);
|
||||||
|
|
Loading…
Reference in New Issue