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"
|
|
|
|
|
2018-12-06 09:37:19 +01:00
|
|
|
static void drawMissionSummary(AtlasImage *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
|
|
|
|
2018-12-06 09:37:19 +01:00
|
|
|
static AtlasImage *missionStartTexture;
|
|
|
|
static AtlasImage *missionInProgressTexture;
|
|
|
|
static AtlasImage *missionCompleteTexture;
|
|
|
|
static AtlasImage *missionFailedTexture;
|
|
|
|
static AtlasImage *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");
|
|
|
|
|
2018-12-06 09:37:19 +01:00
|
|
|
missionStartTexture = !isChallenge ? getAtlasImage("gfx/battle/missionStart.png") : getAtlasImage("gfx/battle/challengeStart.png");
|
|
|
|
missionInProgressTexture = !isChallenge ? getAtlasImage("gfx/battle/missionInProgress.png") : getAtlasImage("gfx/battle/challengeInProgress.png");
|
|
|
|
missionCompleteTexture = !isChallenge ? getAtlasImage("gfx/battle/missionComplete.png") : getAtlasImage("gfx/battle/challengeComplete.png");
|
|
|
|
missionFailedTexture = !isChallenge ? getAtlasImage("gfx/battle/missionFailed.png") : getAtlasImage("gfx/battle/challengeFailed.png");
|
|
|
|
timeUpTexture = getAtlasImage("gfx/battle/timeUp.png");
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void drawMissionInfo(void)
|
|
|
|
{
|
2018-12-14 09:00:16 +01:00
|
|
|
setAtlasColor(255, 255, 255, 255);
|
|
|
|
|
2015-10-20 13:51:49 +02:00
|
|
|
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
|
|
|
}
|
2018-12-13 08:59:31 +01:00
|
|
|
|
|
|
|
SDL_SetRenderTarget(app.renderer, app.backBuffer);
|
2015-10-20 13:51:49 +02:00
|
|
|
}
|
|
|
|
|
2018-12-06 09:37:19 +01:00
|
|
|
static void drawMissionSummary(AtlasImage *header)
|
2015-10-20 13:51:49 +02:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
2018-12-17 09:30:47 +01:00
|
|
|
SDL_SetRenderTarget(app.renderer, app.uiBuffer);
|
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
blit(header, UI_WIDTH / 2, 150, 1);
|
2015-10-20 13:51:49 +02:00
|
|
|
|
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;
|
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_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
|
|
|
}
|
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_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
|
|
|
{
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_WIDTH / 2, y, 22, TA_CENTER, colors.white, "%d / %d", o->currentValue, o->targetValue);
|
2016-02-28 14:02:57 +01:00
|
|
|
}
|
2016-04-07 13:39:53 +02:00
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_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
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_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;
|
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_WIDTH / 2, y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
2016-02-28 14:02:57 +01:00
|
|
|
|
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
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_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");
|
|
|
|
}
|
|
|
|
|
2018-12-14 09:00:16 +01:00
|
|
|
drawText(UI_WIDTH / 2 - 50, y, 22, TA_RIGHT, colors.white, "%s", getChallengeDescription(c));
|
|
|
|
drawText(UI_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
|
|
|
|