2015-10-20 13:51:49 +02:00
|
|
|
/*
|
2018-04-29 11:01:09 +02:00
|
|
|
Copyright (C) 2015-2018 Parallel Realities
|
2015-10-20 13:51:49 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "missionInfo.h"
|
|
|
|
|
|
|
|
static void drawMissionSummary(SDL_Texture *title);
|
2016-02-28 14:02:57 +01:00
|
|
|
static void drawObjectives(void);
|
|
|
|
static void drawChallenges(void);
|
2015-10-20 13:51:49 +02:00
|
|
|
|
|
|
|
static SDL_Texture *missionStartTexture;
|
|
|
|
static SDL_Texture *missionInProgressTexture;
|
|
|
|
static SDL_Texture *missionCompleteTexture;
|
|
|
|
static SDL_Texture *missionFailedTexture;
|
2016-03-05 16:34:37 +01:00
|
|
|
static SDL_Texture *timeUpTexture;
|
2016-02-28 14:45:17 +01:00
|
|
|
static const char *objectiveStatus[OS_MAX];
|
2016-07-19 10:26:19 +02:00
|
|
|
static char *OBJECTIVES_TEXT;
|
|
|
|
static char *NONE_TEXT;
|
|
|
|
static char *TIME_LIMIT_TEXT;
|
2015-10-20 13:51:49 +02:00
|
|
|
|
|
|
|
void initMissionInfo(void)
|
|
|
|
{
|
2016-03-02 07:46:13 +01:00
|
|
|
int isChallenge = game.currentMission->challengeData.isChallenge;
|
|
|
|
|
2016-02-28 14:45:17 +01:00
|
|
|
objectiveStatus[OS_INCOMPLETE] = _("Incomplete");
|
|
|
|
objectiveStatus[OS_COMPLETE] = _("Complete");
|
|
|
|
objectiveStatus[OS_FAILED] = _("Failed");
|
|
|
|
objectiveStatus[OS_CONDITION] = _("Condition");
|
|
|
|
|
2016-07-19 10:26:19 +02:00
|
|
|
OBJECTIVES_TEXT = _("OBJECTIVES");
|
|
|
|
NONE_TEXT = _("(none)");
|
|
|
|
TIME_LIMIT_TEXT = _("Time Limit: %s");
|
|
|
|
|
2016-03-02 07:46:13 +01:00
|
|
|
missionStartTexture = !isChallenge ? getTexture("gfx/battle/missionStart.png") : getTexture("gfx/battle/challengeStart.png");
|
|
|
|
missionInProgressTexture = !isChallenge ? getTexture("gfx/battle/missionInProgress.png") : getTexture("gfx/battle/challengeInProgress.png");
|
|
|
|
missionCompleteTexture = !isChallenge ? getTexture("gfx/battle/missionComplete.png") : getTexture("gfx/battle/challengeComplete.png");
|
|
|
|
missionFailedTexture = !isChallenge ? getTexture("gfx/battle/missionFailed.png") : getTexture("gfx/battle/challengeFailed.png");
|
2016-03-05 16:34:37 +01:00
|
|
|
timeUpTexture = getTexture("gfx/battle/timeUp.png");
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void drawMissionInfo(void)
|
|
|
|
{
|
|
|
|
switch (battle.status)
|
|
|
|
{
|
|
|
|
case MS_START:
|
|
|
|
drawMissionSummary(missionStartTexture);
|
|
|
|
drawWidgets("startBattle");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_PAUSED:
|
|
|
|
drawMissionSummary(missionInProgressTexture);
|
|
|
|
drawWidgets("startBattle");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MS_COMPLETE:
|
|
|
|
case MS_FAILED:
|
2016-01-25 15:58:07 +01:00
|
|
|
if (!battle.unwinnable)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
2016-01-25 15:58:07 +01:00
|
|
|
if (battle.missionFinishedTimer <= -FPS)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
2016-01-25 15:58:07 +01:00
|
|
|
drawMissionSummary(battle.status == MS_COMPLETE ? missionCompleteTexture : missionFailedTexture);
|
|
|
|
|
|
|
|
if (battle.missionFinishedTimer <= -(FPS * 2))
|
|
|
|
{
|
|
|
|
drawWidgets(battle.status == MS_COMPLETE ? "battleWon" : "battleLost");
|
|
|
|
}
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2016-03-05 16:34:37 +01:00
|
|
|
|
|
|
|
case MS_TIME_UP:
|
|
|
|
if (battle.missionFinishedTimer <= -FPS)
|
|
|
|
{
|
|
|
|
drawMissionSummary(timeUpTexture);
|
|
|
|
|
|
|
|
if (battle.missionFinishedTimer <= -(FPS * 2))
|
|
|
|
{
|
|
|
|
drawWidgets("battleWon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drawMissionSummary(SDL_Texture *header)
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
|
|
|
SDL_RenderFillRect(app.renderer, NULL);
|
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
|
|
|
|
|
|
|
blit(header, SCREEN_WIDTH / 2, 150, 1);
|
|
|
|
|
2016-03-02 07:46:13 +01:00
|
|
|
if (!game.currentMission->challengeData.isChallenge)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
2016-02-28 14:02:57 +01:00
|
|
|
drawObjectives();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drawChallenges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drawObjectives(void)
|
|
|
|
{
|
|
|
|
Objective *o;
|
|
|
|
SDL_Color color;
|
|
|
|
int y = 215;
|
|
|
|
|
2016-07-19 10:26:19 +02:00
|
|
|
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.white, OBJECTIVES_TEXT);
|
2016-02-27 13:14:29 +01:00
|
|
|
|
2016-02-28 14:02:57 +01:00
|
|
|
y += 10;
|
|
|
|
|
|
|
|
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
|
|
|
|
{
|
|
|
|
if (o->active)
|
2015-10-22 08:08:03 +02:00
|
|
|
{
|
2016-02-28 14:02:57 +01:00
|
|
|
y += 50;
|
|
|
|
|
|
|
|
switch (o->status)
|
2015-10-29 12:08:47 +01:00
|
|
|
{
|
2016-02-28 14:02:57 +01:00
|
|
|
case OS_INCOMPLETE:
|
|
|
|
color = colors.white;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OS_COMPLETE:
|
|
|
|
color = colors.green;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OS_FAILED:
|
|
|
|
color = colors.red;
|
|
|
|
break;
|
2015-10-29 12:08:47 +01:00
|
|
|
}
|
|
|
|
|
2016-02-28 14:02:57 +01:00
|
|
|
drawText(SCREEN_WIDTH / 2 - 100, y, 22, TA_RIGHT, colors.white, o->description);
|
2016-04-07 13:39:53 +02:00
|
|
|
|
|
|
|
if (o->targetValue > 1 && !o->hideNumbers)
|
2016-02-28 14:02:57 +01:00
|
|
|
{
|
|
|
|
drawText(SCREEN_WIDTH / 2, y, 22, TA_CENTER, colors.white, "%d / %d", o->currentValue, o->targetValue);
|
|
|
|
}
|
2016-04-07 13:39:53 +02:00
|
|
|
|
2016-02-28 14:02:57 +01:00
|
|
|
drawText(SCREEN_WIDTH / 2 + 100, y, 22, TA_LEFT, color, objectiveStatus[o->status]);
|
2015-10-22 08:08:03 +02:00
|
|
|
}
|
2016-02-28 14:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!battle.objectiveHead.next)
|
|
|
|
{
|
|
|
|
y += 50;
|
2015-10-20 13:51:49 +02:00
|
|
|
|
2016-07-19 10:26:19 +02:00
|
|
|
drawText(SCREEN_WIDTH / 2, y, 22, TA_CENTER, colors.white, NONE_TEXT);
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
|
2016-02-28 14:02:57 +01:00
|
|
|
y += 75;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drawChallenges(void)
|
|
|
|
{
|
2016-03-03 00:20:37 +01:00
|
|
|
int i;
|
2016-02-28 14:02:57 +01:00
|
|
|
Challenge *c;
|
|
|
|
char *challengeStatus;
|
|
|
|
SDL_Color color;
|
|
|
|
int y = 215;
|
|
|
|
|
|
|
|
drawText(SCREEN_WIDTH / 2, y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
|
|
|
|
2016-03-02 07:46:13 +01:00
|
|
|
if (battle.status == MS_START && game.currentMission->challengeData.timeLimit)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
2016-02-28 14:02:57 +01:00
|
|
|
y+= 50;
|
2015-10-20 13:51:49 +02:00
|
|
|
|
2016-07-19 10:26:19 +02:00
|
|
|
drawText(SCREEN_WIDTH / 2, y, 20, TA_CENTER, colors.white, TIME_LIMIT_TEXT, timeToString(game.currentMission->challengeData.timeLimit, 0));
|
2016-02-28 14:02:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
y += 25;
|
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
2016-02-28 14:02:57 +01:00
|
|
|
{
|
2016-03-03 08:44:04 +01:00
|
|
|
c = game.currentMission->challengeData.challenges[i];
|
2016-03-03 00:20:37 +01:00
|
|
|
|
2016-03-03 10:12:08 +01:00
|
|
|
if (c)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
2016-03-03 10:12:08 +01:00
|
|
|
y += 50;
|
2015-10-20 13:51:49 +02:00
|
|
|
|
2016-03-03 10:12:08 +01:00
|
|
|
color = colors.white;
|
|
|
|
|
|
|
|
challengeStatus = _("Incomplete");
|
2015-10-20 13:51:49 +02:00
|
|
|
|
2016-03-03 10:12:08 +01:00
|
|
|
if (c->passed)
|
|
|
|
{
|
|
|
|
color = colors.green;
|
|
|
|
|
|
|
|
challengeStatus = _("Complete");
|
|
|
|
}
|
|
|
|
else if (battle.status == MS_COMPLETE ||battle.status == MS_FAILED)
|
|
|
|
{
|
|
|
|
color = colors.red;
|
|
|
|
|
|
|
|
challengeStatus = _("Failed");
|
|
|
|
}
|
|
|
|
|
|
|
|
drawText(SCREEN_WIDTH / 2 - 50, y, 22, TA_RIGHT, colors.white, "%s", getChallengeDescription(c));
|
|
|
|
drawText(SCREEN_WIDTH / 2 + 50, y, 22, TA_LEFT, color, challengeStatus);
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-28 14:02:57 +01:00
|
|
|
|