Allow for new campaign to be started: Normal or Easy.

This commit is contained in:
Steve 2017-05-14 17:01:00 +01:00
parent 7144d57647
commit a7e3e85dc8
4 changed files with 108 additions and 26 deletions

View File

@ -191,6 +191,25 @@ void updateStarSystemMissions(void)
}
}
int hasCompletedAnyMission(void)
{
StarSystem *starSystem;
Mission *mission;
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
{
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
{
if (mission->completed)
{
return 1;
}
}
}
return 0;
}
void destroyStarSystems(void)
{
StarSystem *starSystem;

View File

@ -27,6 +27,28 @@ void initGame(void)
STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH);
}
void resetCampaign(int difficulty)
{
StarSystem *starSystem;
Mission *mission;
game.difficulty = difficulty;
STRNCPY(game.selectedStarSystem, "Sol", MAX_NAME_LENGTH);
for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next)
{
starSystem->completedMissions = 0;
starSystem->activeMission = NULL;
for (mission = starSystem->missionHead.next ; mission != NULL ; mission = mission->next)
{
mission->available = 0;
mission->completed = 0;
}
}
}
void destroyGame(void)
{
}

View File

@ -37,9 +37,12 @@ static void quit(void);
static void returnFromOptions(void);
static void newCampaign(void);
static void easyCampaign(void);
static void normalCampaign(void);
static void continueCampaign(void);
static void back(void);
static void doEasyCampaign(void);
static void doNewCampaign(void);
static void ignoreNewCampaign(void);
static void drawEasyModeHints(void);
static SDL_Texture *background;
static SDL_Texture *logo;
@ -49,6 +52,7 @@ static PointF earth;
static Entity fighters[NUM_FIGHTERS];
static const char *fighterTextures[] = {"gfx/fighters/firefly.png", "gfx/fighters/hammerhead.png", "gfx/fighters/hyena.png", "gfx/fighters/lynx.png", "gfx/fighters/kingfisher.png", "gfx/fighters/leopard.png", "gfx/fighters/nymph.png", "gfx/fighters/ray.png", "gfx/fighters/rook.png", "gfx/fighters/taf.png"};
static int show;
static int hasActiveCampaign;
void initTitle(void)
{
@ -83,6 +87,8 @@ void initTitle(void)
updateAllMissions();
hasActiveCampaign = hasCompletedAnyMission();
getWidget("campaign", "title")->action = campaign;
getWidget("challenges", "title")->action = challenges;
getWidget("trophies", "title")->action = trophies;
@ -92,13 +98,11 @@ void initTitle(void)
getWidget("quit", "title")->action = quit;
getWidget("new", "campaign")->action = newCampaign;
getWidget("easy", "campaign")->action = easyCampaign;
getWidget("continue", "campaign")->action = continueCampaign;
getWidget("continue", "campaign")->enabled = hasActiveCampaign;
getWidget("back", "campaign")->action = back;
getWidget("easy", "campaignDifficulty")->action = easyCampaign;
getWidget("normal", "campaignDifficulty")->action = normalCampaign;
getWidget("back", "campaignDifficulty")->action = back;
getWidget("ok", "stats")->action = ok;
getWidget("ok", "trophies")->action = ok;
@ -194,7 +198,7 @@ static void draw(void)
blit(pandoranWar, SCREEN_WIDTH / 2, 110, 1);
drawText(10, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2016");
drawText(10, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2017");
drawText(SCREEN_WIDTH - 10, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "Version %.2f-%d", VERSION, REVISION);
switch (show)
@ -205,6 +209,7 @@ static void draw(void)
case SHOW_CAMPAIGN:
drawWidgets("campaign");
drawEasyModeHints();
break;
case SHOW_STATS:
@ -247,46 +252,79 @@ static void campaign(void)
show = SHOW_CAMPAIGN;
}
static void drawEasyModeHints(void)
{
drawText(SCREEN_WIDTH / 2, 525, 16, TA_CENTER, colors.white, _("Easy Campaign features reduced AI aggression, as well as reduced Boost and ECM recharge times."));
drawText(SCREEN_WIDTH / 2, 550, 16, TA_CENTER, colors.white, _("The player also benefits from increased fighter armour and shield recharge rates."));
drawText(SCREEN_WIDTH / 2, 575, 16, TA_CENTER, colors.white, _("Some players may find this mode more accessible than the normal campaign difficulty."));
drawText(SCREEN_WIDTH / 2, 600, 16, TA_CENTER, colors.white, _("Note that the difficulty cannot be changed once the campaign is started."));
}
static void newCampaign(void)
{
}
static void continueCampaign(void)
{
}
static void back(void)
{
switch (show)
if (!hasActiveCampaign)
{
case SHOW_CAMPAIGN:
show = SHOW_TITLE;
break;
case SHOW_CAMPAIGN_NEW:
show = SHOW_CAMPAIGN;
break;
doNewCampaign();
}
else
{
showOKCancelDialog(&doNewCampaign, &ignoreNewCampaign, _("Start a new campaign? Your current campaign progress will be lost."));
}
}
static void doNewCampaign(void)
{
app.modalDialog.type = MD_NONE;
resetCampaign(DIFFICULTY_NORMAL);
destroyBattle();
initGalacticMap();
}
static void easyCampaign(void)
{
game.difficulty = DIFFICULTY_EASY;
if (!hasActiveCampaign)
{
doEasyCampaign();
}
else
{
showOKCancelDialog(&doEasyCampaign, &ignoreNewCampaign, _("Start a new campaign? Your current campaign progress will be lost."));
}
}
static void doEasyCampaign(void)
{
app.modalDialog.type = MD_NONE;
resetCampaign(DIFFICULTY_EASY);
destroyBattle();
initGalacticMap();
}
static void normalCampaign(void)
static void continueCampaign(void)
{
game.difficulty = DIFFICULTY_NORMAL;
app.modalDialog.type = MD_NONE;
destroyBattle();
initGalacticMap();
}
static void ignoreNewCampaign(void)
{
app.modalDialog.type = MD_NONE;
}
static void back(void)
{
show = SHOW_TITLE;
}
static void challenges(void)
{
destroyBattle();

View File

@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SHOW_OPTIONS 2
#define SHOW_TROPHIES 3
#define SHOW_CAMPAIGN 4
#define SHOW_CAMPAIGN_NEW 5
#define NUM_FIGHTERS 12
@ -62,6 +61,10 @@ extern void clearInput(void);
extern void initTrophiesDisplay(void);
extern void drawTrophies(void);
extern void initCredits(void);
extern void resetCampaign(int difficulty);
extern void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...);
extern char *getTranslatedString(char *string);
extern int hasCompletedAnyMission(void);
extern App app;
extern Battle battle;