diff --git a/src/challenges/challengeHome.c b/src/challenges/challengeHome.c index 6da9c39..ad7426a 100644 --- a/src/challenges/challengeHome.c +++ b/src/challenges/challengeHome.c @@ -24,7 +24,6 @@ static void logic(void); static void draw(void); static void handleKeyboard(void); static void drawChallenges(void); -static void updateChallengeMissions(void); static void doChallenges(void); static void startChallengeMission(void); static void drawMenu(void); @@ -33,6 +32,7 @@ static void stats(void); static void options(void); static void statsOK(void); static void returnFromOptions(void); +static void unlockChallenges(void); static void quit(void); static SDL_Texture *background; @@ -48,7 +48,9 @@ void initChallengeHome(void) stopMusic(); - updateChallengeMissions(); + updateAllMissions(); + + unlockChallenges(); saveGame(); @@ -84,10 +86,9 @@ void initChallengeHome(void) endSectionTransition(); } -static void updateChallengeMissions(void) +static void unlockChallenges(void) { Mission *m; - Challenge *c; int i; i = completedChallenges = totalChallenges = 0; @@ -96,18 +97,6 @@ static void updateChallengeMissions(void) { m->available = i <= completedChallenges; - m->totalChallenges = m->completedChallenges = 0; - - for (c = m->challengeHead.next ; c != NULL ; c = c->next) - { - m->totalChallenges++; - - if (c->passed) - { - m->completedChallenges++; - } - } - completedChallenges += m->completedChallenges; totalChallenges += m->totalChallenges; @@ -174,7 +163,7 @@ static void draw(void) drawStars(); - drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, "Challenges"); + drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, _("Challenges")); drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", completedChallenges, totalChallenges); diff --git a/src/challenges/challengeHome.h b/src/challenges/challengeHome.h index 900a089..d776c9a 100644 --- a/src/challenges/challengeHome.h +++ b/src/challenges/challengeHome.h @@ -52,6 +52,8 @@ extern void initOptions(void (*returnFromOptions)(void)); extern void drawStats(void); extern void playSound(int sound); extern void selectWidget(const char *name, const char *group); +extern void updateAllMissions(void); +extern char *getTranslatedString(char *string); extern App app; extern Battle battle; diff --git a/src/defs.h b/src/defs.h index bdc04af..23f9b0a 100644 --- a/src/defs.h +++ b/src/defs.h @@ -261,11 +261,13 @@ enum CHALLENGE_LOSSES, CHALLENGE_PLAYER_KILLS, CHALLENGE_DISABLE, - CHALLENGE_TIME_MINS + CHALLENGE_TIME_MINS, + CHALLENGE_MAX }; enum { + STAT_PERCENT_COMPLETE, STAT_MISSIONS_STARTED, STAT_MISSIONS_COMPLETED, STAT_CHALLENGES_STARTED, diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index 556e844..52966f6 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -84,7 +84,7 @@ void initGalacticMap(void) centerOnSelectedStarSystem(); - updateStarSystemMissions(); + updateAllMissions(); updatePandoranAdvance(); @@ -597,7 +597,6 @@ static void handleKeyboard(void) case SHOW_GALAXY: selectWidget("resume", "galacticMap"); show = SHOW_MENU; - memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); playSound(SND_GUI_CLOSE); break; @@ -608,14 +607,12 @@ static void handleKeyboard(void) case SHOW_MENU: show = SHOW_GALAXY; - memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); break; case SHOW_OPTIONS: case SHOW_STATS: show = SHOW_MENU; selectWidget("resume", "galacticMap"); - memset(app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS); break; } diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 6f8f119..98b262f 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -55,7 +55,7 @@ extern void drawStats(void); extern void playSound(int id); extern void blitRotated(SDL_Texture *texture, int x, int y, float angle); extern void initStatsDisplay(void); -extern void updateStarSystemMissions(void); +extern void updateAllMissions(void); extern StarSystem *getStarSystem(char *name); extern void setMouse(int x, int y); extern void showOKDialog(void (*callback)(void), const char *format, ...); diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 323eff2..3b5b57b 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -865,6 +865,13 @@ Mission *getMission(char *filename) return NULL; } +void updateAllMissions(void) +{ + updateStarSystemMissions(); + + updateChallengeMissions(); +} + int isMissionAvailable(Mission *mission, Mission *prev) { return prev->completed && mission->requires <= game.completedMissions; diff --git a/src/galaxy/mission.h b/src/galaxy/mission.h index 3d981ce..742893e 100644 --- a/src/galaxy/mission.h +++ b/src/galaxy/mission.h @@ -49,6 +49,8 @@ extern void updateCapitalShipComponentProperties(Entity *parent); extern void countNumEnemies(void); extern void initMissionInfo(void); extern char *getTranslatedString(char *string); +extern void updateStarSystemMissions(void); +extern void updateChallengeMissions(void); extern Battle battle; extern Entity *player; diff --git a/src/game/title.c b/src/game/title.c index f628b14..a23f20b 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -74,6 +74,8 @@ void initTitle(void) initFighters(); + updateAllMissions(); + getWidget("campaign", "title")->action = campaign; getWidget("challenges", "title")->action = challenges; getWidget("stats", "title")->action = stats; diff --git a/src/game/title.h b/src/game/title.h index 4c1ff37..3c84658 100644 --- a/src/game/title.h +++ b/src/game/title.h @@ -55,6 +55,7 @@ extern void setMouse(int x, int y); extern void initChallengeHome(void); extern void selectWidget(const char *name, const char *group); extern void drawStats(void); +extern void updateAllMissions(void); extern App app; extern Battle battle; diff --git a/src/system/lookup.c b/src/system/lookup.c index 3b9b054..66c6868 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -116,6 +116,7 @@ void initLookups(void) addLookup("CHALLENGE_DISABLE", CHALLENGE_DISABLE); addLookup("CHALLENGE_TIME_MINS", CHALLENGE_TIME_MINS); + addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE); addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED); addLookup("STAT_MISSIONS_COMPLETED", STAT_MISSIONS_COMPLETED); addLookup("STAT_CHALLENGES_STARTED", STAT_CHALLENGES_STARTED);