tbftss/src/battle/missionInfo.c

215 lines
5.3 KiB
C
Raw Normal View History

2015-10-20 13:51:49 +02:00
/*
2016-02-21 16:50:27 +01:00
Copyright (C) 2015-2016 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;
static SDL_Texture *timeUpTexture;
2016-02-28 14:45:17 +01:00
static const char *objectiveStatus[OS_MAX];
2015-10-20 13:51:49 +02:00
void initMissionInfo(void)
{
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");
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");
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:
if (!battle.unwinnable)
2015-10-20 13:51:49 +02:00
{
if (battle.missionFinishedTimer <= -FPS)
2015-10-20 13:51:49 +02: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;
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);
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;
drawText(SCREEN_WIDTH / 2, y, 28, TA_CENTER, colors.white, _("OBJECTIVES"));
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)
{
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]);
}
2016-02-28 14:02:57 +01:00
}
if (!battle.objectiveHead.next)
{
y += 50;
2015-10-20 13:51:49 +02:00
2016-02-28 14:02:57 +01:00
drawText(SCREEN_WIDTH / 2, y, 22, TA_CENTER, colors.white, _("(none)"));
2015-10-20 13:51:49 +02:00
}
2016-02-28 14:02:57 +01:00
y += 75;
}
static void drawChallenges(void)
{
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);
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
drawText(SCREEN_WIDTH / 2, y, 20, TA_CENTER, colors.white, _("Time Limit: %s"), timeToString(game.currentMission->challengeData.timeLimit, 0));
2016-02-28 14:02:57 +01:00
}
y += 25;
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];
if (c)
2015-10-20 13:51:49 +02:00
{
y += 50;
2015-10-20 13:51:49 +02:00
color = colors.white;
challengeStatus = _("Incomplete");
2015-10-20 13:51:49 +02: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