2016-02-27 17:16:21 +01:00
|
|
|
/*
|
|
|
|
Copyright (C) 2015-2016 Parallel Realities
|
|
|
|
|
|
|
|
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 "challengeHome.h"
|
|
|
|
|
|
|
|
static void logic(void);
|
|
|
|
static void draw(void);
|
|
|
|
static void handleKeyboard(void);
|
|
|
|
static void drawChallenges(void);
|
|
|
|
static void doChallenges(void);
|
|
|
|
static void startChallengeMission(void);
|
2016-02-29 10:54:03 +01:00
|
|
|
static void drawMenu(void);
|
|
|
|
static void resume(void);
|
|
|
|
static void stats(void);
|
|
|
|
static void options(void);
|
|
|
|
static void statsOK(void);
|
|
|
|
static void returnFromOptions(void);
|
2016-02-29 11:47:10 +01:00
|
|
|
static void unlockChallenges(void);
|
2016-02-29 10:54:03 +01:00
|
|
|
static void quit(void);
|
2016-03-02 07:58:03 +01:00
|
|
|
static void updateChallengeMissionData(void);
|
|
|
|
static char *listRestrictions(void);
|
2016-02-27 17:16:21 +01:00
|
|
|
|
|
|
|
static SDL_Texture *background;
|
|
|
|
static int startIndex;
|
|
|
|
static Widget *start;
|
2016-02-29 10:23:41 +01:00
|
|
|
static int completedChallenges;
|
2016-02-29 13:09:36 +01:00
|
|
|
static SDL_Texture *planetTexture;
|
|
|
|
static PointF planet;
|
2016-02-29 10:23:41 +01:00
|
|
|
static int totalChallenges;
|
2016-02-29 10:54:03 +01:00
|
|
|
static int show;
|
2016-03-02 07:58:03 +01:00
|
|
|
static char timeLimit[MAX_DESCRIPTION_LENGTH];
|
|
|
|
static char restrictions[MAX_DESCRIPTION_LENGTH];
|
2016-03-02 23:19:26 +01:00
|
|
|
static int hasRestrictions;
|
2016-02-27 17:16:21 +01:00
|
|
|
|
|
|
|
void initChallengeHome(void)
|
|
|
|
{
|
|
|
|
startSectionTransition();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
stopMusic();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 11:47:10 +01:00
|
|
|
updateAllMissions();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 11:47:10 +01:00
|
|
|
unlockChallenges();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
|
|
|
checkStatTrophies();
|
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
saveGame();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
app.delegate.logic = &logic;
|
|
|
|
app.delegate.draw = &draw;
|
|
|
|
memset(&app.keyboard, 0, sizeof(int) * MAX_KEYBOARD_KEYS);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 17:00:32 +01:00
|
|
|
background = getTexture(getBackgroundTextureName(rand()));
|
|
|
|
planetTexture = getTexture(getPlanetTextureName(rand()));
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
battle.camera.x = battle.camera.y = 0;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 17:00:32 +01:00
|
|
|
planet.x = rand() % SCREEN_WIDTH;
|
|
|
|
planet.y = rand() % SCREEN_HEIGHT;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
startIndex = 0;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
show = SHOW_CHALLENGES;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
initBackground();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
start = getWidget("start", "challenges");
|
|
|
|
start->action = startChallengeMission;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
getWidget("resume", "challengesMenu")->action = resume;
|
|
|
|
getWidget("stats", "challengesMenu")->action = stats;
|
|
|
|
getWidget("options", "challengesMenu")->action = options;
|
|
|
|
getWidget("quit", "challengesMenu")->action = quit;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
getWidget("ok", "stats")->action = statsOK;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:24:59 +01:00
|
|
|
/* select first challenge if none chosen */
|
|
|
|
if (!game.currentMission)
|
|
|
|
{
|
|
|
|
game.currentMission = game.challengeMissionHead.next;
|
|
|
|
updateChallengeMissionData();
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
endSectionTransition();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 17:16:12 +01:00
|
|
|
playMusic("music/main/covert_operations.mp3");
|
2016-02-27 17:16:21 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 11:47:10 +01:00
|
|
|
static void unlockChallenges(void)
|
2016-02-27 17:16:21 +01:00
|
|
|
{
|
|
|
|
Mission *m;
|
2016-03-10 13:04:04 +01:00
|
|
|
|
2016-03-10 00:25:54 +01:00
|
|
|
int i, prevCompleted;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:23:41 +01:00
|
|
|
i = completedChallenges = totalChallenges = 0;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-10 00:25:54 +01:00
|
|
|
prevCompleted = 1;
|
2016-03-10 13:04:04 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
|
|
|
{
|
2016-03-10 00:25:54 +01:00
|
|
|
m->available = (prevCompleted > 0 || dev.debug);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:23:41 +01:00
|
|
|
completedChallenges += m->completedChallenges;
|
|
|
|
totalChallenges += m->totalChallenges;
|
2016-03-10 00:25:54 +01:00
|
|
|
prevCompleted = m->completedChallenges;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:23:41 +01:00
|
|
|
i++;
|
2016-02-27 17:16:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void logic(void)
|
|
|
|
{
|
|
|
|
handleKeyboard();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
scrollBackground(-0.25, 0);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
doStars(0.5, 0);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 13:09:36 +01:00
|
|
|
planet.x -= 0.25;
|
|
|
|
if (planet.x <= -200)
|
|
|
|
{
|
2016-03-02 07:58:03 +01:00
|
|
|
planet.x = SCREEN_WIDTH + 128 + (rand() % SCREEN_WIDTH);
|
2016-02-29 13:09:36 +01:00
|
|
|
planet.y = (rand() % SCREEN_HEIGHT - 128);
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
switch (show)
|
|
|
|
{
|
|
|
|
case SHOW_CHALLENGES:
|
|
|
|
doChallenges();
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_MENU:
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_STATS:
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_OPTIONS:
|
|
|
|
break;
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
|
|
|
doTrophies();
|
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
doWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void doChallenges(void)
|
|
|
|
{
|
|
|
|
Mission *c;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
for (c = game.challengeMissionHead.next ; c != NULL ; c = c->next)
|
|
|
|
{
|
|
|
|
if (app.mouse.button[SDL_BUTTON_LEFT] && collision(app.mouse.x, app.mouse.y, 3, 3, c->rect.x, c->rect.y, c->rect.w, c->rect.h))
|
|
|
|
{
|
2016-02-29 10:23:41 +01:00
|
|
|
if (c->available)
|
|
|
|
{
|
|
|
|
game.currentMission = c;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
updateChallengeMissionData();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-05 16:35:09 +01:00
|
|
|
start->enabled = 1;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-05 16:35:09 +01:00
|
|
|
playSound(SND_GUI_CLICK);
|
2016-03-02 07:58:03 +01:00
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
app.mouse.button[SDL_BUTTON_LEFT] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
static void updateChallengeMissionData(void)
|
|
|
|
{
|
|
|
|
STRNCPY(timeLimit, timeToString(game.currentMission->challengeData.timeLimit, 0), MAX_DESCRIPTION_LENGTH);
|
|
|
|
sprintf(restrictions, "%s", listRestrictions());
|
2016-03-02 23:19:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void addRestriction(char *buffer, int restricted, char *description)
|
|
|
|
{
|
|
|
|
if (restricted)
|
|
|
|
{
|
|
|
|
if (strlen(buffer) > 0)
|
|
|
|
{
|
|
|
|
strcat(buffer, ". ");
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
strcat(buffer, description);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
hasRestrictions = 1;
|
2016-03-02 07:58:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *listRestrictions(void)
|
|
|
|
{
|
2016-03-02 23:19:26 +01:00
|
|
|
static char textBuffer[MAX_DESCRIPTION_LENGTH];
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
memset(textBuffer, '\0', MAX_DESCRIPTION_LENGTH);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
hasRestrictions = 0;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
addRestriction(textBuffer, game.currentMission->challengeData.noMissiles, _("No Missiles"));
|
|
|
|
addRestriction(textBuffer, game.currentMission->challengeData.noECM, _("No ECM"));
|
|
|
|
addRestriction(textBuffer, game.currentMission->challengeData.noBoost, _("No Boost"));
|
|
|
|
addRestriction(textBuffer, game.currentMission->challengeData.noGuns, _("No Guns"));
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 23:19:26 +01:00
|
|
|
return strlen(textBuffer) > 0 ? textBuffer : "-";
|
2016-03-02 07:58:03 +01:00
|
|
|
}
|
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
static void draw(void)
|
|
|
|
{
|
|
|
|
drawBackground(background);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 17:00:32 +01:00
|
|
|
blit(planetTexture, planet.x, planet.y, 1);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
drawStars();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 11:47:10 +01:00
|
|
|
drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, _("Challenges"));
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:23:41 +01:00
|
|
|
drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", completedChallenges, totalChallenges);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
drawChallenges();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
switch (show)
|
|
|
|
{
|
|
|
|
case SHOW_CHALLENGES:
|
|
|
|
drawWidgets("challenges");
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_MENU:
|
|
|
|
drawMenu();
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_STATS:
|
|
|
|
drawStats();
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_OPTIONS:
|
|
|
|
drawOptions();
|
|
|
|
break;
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
|
|
|
doTrophyAlert();
|
2016-02-27 17:16:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void drawChallenges(void)
|
|
|
|
{
|
2016-03-03 00:20:37 +01:00
|
|
|
Mission *m;
|
|
|
|
Challenge *c;
|
2016-02-27 17:16:21 +01:00
|
|
|
SDL_Rect r;
|
|
|
|
int i, endIndex;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
r.x = 135;
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y = 165;
|
2016-02-27 17:16:21 +01:00
|
|
|
r.w = r.h = 96;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
endIndex = startIndex + MAX_ITEMS;
|
|
|
|
i = 0;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
for (m = game.challengeMissionHead.next ; m != NULL ; m = m->next)
|
2016-02-27 17:16:21 +01:00
|
|
|
{
|
2016-03-03 00:20:37 +01:00
|
|
|
m->rect = r;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
if (i >= startIndex && i <= endIndex)
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
|
|
|
SDL_RenderFillRect(app.renderer, &r);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
if (game.currentMission == m)
|
2016-02-27 17:16:21 +01:00
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 64, 128, 200, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderFillRect(app.renderer, &r);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 128, 192, 255, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &r);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &r);
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
drawText(r.x + (r.w / 2), r.y + 28, 30, TA_CENTER, colors.white, "%d", i + 1);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
if (m->available)
|
2016-02-29 10:23:41 +01:00
|
|
|
{
|
2016-03-03 00:20:37 +01:00
|
|
|
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, (m->completedChallenges < m->totalChallenges) ? colors.white : colors.green, "%d / %d", m->completedChallenges, m->totalChallenges);
|
2016-02-29 10:23:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-02 08:14:38 +01:00
|
|
|
drawText(r.x + (r.w / 2), r.y + r.w + 5, 18, TA_CENTER, colors.lightGrey, _("[Locked]"));
|
2016-02-29 10:23:41 +01:00
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
r.x += 150;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 08:14:38 +01:00
|
|
|
if (r.x > SCREEN_WIDTH - 200)
|
2016-02-27 17:16:21 +01:00
|
|
|
{
|
|
|
|
r.y += 165;
|
|
|
|
r.x = 135;
|
|
|
|
}
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
i++;
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y = SCREEN_HEIGHT - 245;
|
|
|
|
r.x = 100;
|
|
|
|
r.w = SCREEN_WIDTH - 200;
|
|
|
|
r.h = 150;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
|
|
|
|
SDL_RenderFillRect(app.renderer, &r);
|
|
|
|
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 64, 64, 64, SDL_ALPHA_OPAQUE);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &r);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y = 240;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-28 14:02:57 +01:00
|
|
|
if (game.currentMission)
|
|
|
|
{
|
2016-03-02 07:58:03 +01:00
|
|
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - r.y, 24, TA_CENTER, colors.white, game.currentMission->description);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y -= 50;
|
2016-03-03 00:20:37 +01:00
|
|
|
c = game.currentMission->challengeData.challenges[0];
|
2016-03-02 08:14:38 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Craft: %s"), game.currentMission->craft);
|
2016-03-03 08:44:04 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "1. %s", getChallengeDescription(c));
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y -= 30;
|
2016-03-02 08:14:38 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, colors.white, _("Time Limit: %s"), timeLimit);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
c = game.currentMission->challengeData.challenges[1];
|
|
|
|
if (c)
|
2016-03-02 23:19:26 +01:00
|
|
|
{
|
2016-03-03 00:20:37 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "2. %s", getChallengeDescription(c));
|
2016-03-02 23:19:26 +01:00
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-02 07:58:03 +01:00
|
|
|
r.y -= 30;
|
2016-03-02 23:19:26 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) - 25, SCREEN_HEIGHT - r.y, 18, TA_RIGHT, hasRestrictions ? colors.red : colors.white, _("Restrictions: %s"), restrictions);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-03 00:20:37 +01:00
|
|
|
c = game.currentMission->challengeData.challenges[2];
|
|
|
|
if (c)
|
2016-03-02 23:19:26 +01:00
|
|
|
{
|
2016-03-03 08:44:04 +01:00
|
|
|
drawText((SCREEN_WIDTH / 2) + 25, SCREEN_HEIGHT - r.y, 18, TA_LEFT, (c->passed) ? colors.green : colors.white, "3. %s", getChallengeDescription(c));
|
2016-03-02 23:19:26 +01:00
|
|
|
}
|
2016-02-28 14:02:57 +01:00
|
|
|
}
|
2016-02-27 17:16:21 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
static void drawMenu(void)
|
|
|
|
{
|
|
|
|
SDL_Rect r;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01: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);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
r.w = 400;
|
|
|
|
r.h = 400;
|
|
|
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
|
|
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
|
|
|
|
SDL_RenderFillRect(app.renderer, &r);
|
|
|
|
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
|
|
|
|
SDL_RenderDrawRect(app.renderer, &r);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
drawWidgets("challengesMenu");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void resume(void)
|
|
|
|
{
|
|
|
|
show = SHOW_CHALLENGES;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void options(void)
|
|
|
|
{
|
|
|
|
show = SHOW_OPTIONS;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
initOptions(returnFromOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void stats(void)
|
|
|
|
{
|
|
|
|
selectWidget("ok", "stats");
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
show = SHOW_STATS;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
initStatsDisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void statsOK(void)
|
|
|
|
{
|
|
|
|
selectWidget("resume", "challengesMenu");
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
show = SHOW_MENU;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void returnFromOptions(void)
|
|
|
|
{
|
|
|
|
show = SHOW_MENU;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
selectWidget("resume", "challengesMenu");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void quit(void)
|
|
|
|
{
|
|
|
|
initTitle();
|
|
|
|
}
|
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
static void handleKeyboard(void)
|
|
|
|
{
|
2016-03-05 14:49:07 +01:00
|
|
|
if (app.keyboard[SDL_SCANCODE_ESCAPE] && !app.awaitingWidgetInput)
|
2016-02-27 19:12:18 +01:00
|
|
|
{
|
2016-02-29 10:54:03 +01:00
|
|
|
switch (show)
|
|
|
|
{
|
|
|
|
case SHOW_CHALLENGES:
|
|
|
|
selectWidget("resume", "challengesMenu");
|
|
|
|
show = SHOW_MENU;
|
|
|
|
playSound(SND_GUI_CLOSE);
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_MENU:
|
|
|
|
show = SHOW_CHALLENGES;
|
|
|
|
break;
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
case SHOW_OPTIONS:
|
|
|
|
case SHOW_STATS:
|
|
|
|
show = SHOW_MENU;
|
|
|
|
selectWidget("resume", "challengesMenu");
|
|
|
|
break;
|
|
|
|
}
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-29 10:54:03 +01:00
|
|
|
playSound(SND_GUI_CLOSE);
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-03-05 16:35:09 +01:00
|
|
|
clearInput();
|
2016-02-27 19:12:18 +01:00
|
|
|
}
|
2016-02-27 17:16:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void startChallengeMission(void)
|
|
|
|
{
|
|
|
|
initBattle();
|
2016-03-09 13:31:33 +01:00
|
|
|
|
2016-02-27 17:16:21 +01:00
|
|
|
loadMission(game.currentMission->filename);
|
|
|
|
}
|