Implemented mission quit option.
This commit is contained in:
parent
edde9fac2f
commit
e745a287f4
|
@ -233,7 +233,6 @@ enum
|
||||||
WS_PAUSED,
|
WS_PAUSED,
|
||||||
WS_GAME_COMPLETE,
|
WS_GAME_COMPLETE,
|
||||||
WS_OBSERVING,
|
WS_OBSERVING,
|
||||||
WS_QUIT,
|
|
||||||
WS_COMPLETE,
|
WS_COMPLETE,
|
||||||
WS_MISSION_COMPLETE,
|
WS_MISSION_COMPLETE,
|
||||||
WS_GAME_OVER
|
WS_GAME_OVER
|
||||||
|
|
|
@ -39,7 +39,6 @@ extern Texture *getTexture(const char *filename);
|
||||||
extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center);
|
extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center);
|
||||||
extern void saveScreenshot(char *name);
|
extern void saveScreenshot(char *name);
|
||||||
extern void drawWidgets(void);
|
extern void drawWidgets(void);
|
||||||
extern char *timeToString(int seconds, int showHours);
|
|
||||||
extern float limit(float i, float low, float high);
|
extern float limit(float i, float low, float high);
|
||||||
extern int isControl(int type);
|
extern int isControl(int type);
|
||||||
extern void clearControl(int type);
|
extern void clearControl(int type);
|
||||||
|
|
|
@ -22,17 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
static void logic(void);
|
static void logic(void);
|
||||||
static void draw(void);
|
static void draw(void);
|
||||||
static void doPostMission(void);
|
|
||||||
static void updateMissionStatus(void);
|
static void updateMissionStatus(void);
|
||||||
|
static int status;
|
||||||
|
|
||||||
void initPostMission(void)
|
void initPostMission(void)
|
||||||
{
|
{
|
||||||
startSectionTransition();
|
startSectionTransition();
|
||||||
|
|
||||||
if (world.state != WS_QUIT)
|
|
||||||
{
|
|
||||||
updateMissionStatus();
|
updateMissionStatus();
|
||||||
}
|
|
||||||
|
|
||||||
app.delegate.logic = logic;
|
app.delegate.logic = logic;
|
||||||
app.delegate.draw = draw;
|
app.delegate.draw = draw;
|
||||||
|
@ -48,7 +45,7 @@ static void updateMissionStatus(void)
|
||||||
{
|
{
|
||||||
if (strcmp(t->key, world.id) == 0)
|
if (strcmp(t->key, world.id) == 0)
|
||||||
{
|
{
|
||||||
t->value.i = getMissionStatus();
|
t->value.i = status = getMissionStatus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,32 +56,22 @@ static void updateMissionStatus(void)
|
||||||
game.missionStatusTail = t;
|
game.missionStatusTail = t;
|
||||||
|
|
||||||
STRNCPY(t->key, world.id, MAX_NAME_LENGTH);
|
STRNCPY(t->key, world.id, MAX_NAME_LENGTH);
|
||||||
t->value.i = getMissionStatus();
|
t->value.i = status = getMissionStatus();
|
||||||
|
|
||||||
|
if (status != MS_INCOMPLETE)
|
||||||
|
{
|
||||||
|
saveGame();
|
||||||
|
saveWorld();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logic(void)
|
static void logic(void)
|
||||||
{
|
{
|
||||||
if (world.state != WS_QUIT)
|
destroyWorld();
|
||||||
{
|
|
||||||
doPostMission();
|
initHub();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
doPostMission();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(void)
|
static void draw(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doPostMission(void)
|
|
||||||
{
|
|
||||||
saveGame();
|
|
||||||
|
|
||||||
saveWorld();
|
|
||||||
|
|
||||||
destroyWorld();
|
|
||||||
|
|
||||||
initHub();
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ void initAtlasTest(void)
|
||||||
loadGame();
|
loadGame();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
STRNCPY(game.worldId, "", MAX_NAME_LENGTH);
|
STRNCPY(game.worldId, "beachFront1", MAX_NAME_LENGTH);
|
||||||
initWorld();
|
initWorld();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,4 @@ extern void initHub(void);
|
||||||
extern void loadGame(void);
|
extern void loadGame(void);
|
||||||
|
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
|
extern Game game;
|
||||||
|
|
|
@ -226,7 +226,7 @@ void drawMissionStatus(void)
|
||||||
drawRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 0, 0, 0, 128);
|
drawRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 0, 0, 0, 128);
|
||||||
drawOutlineRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 255, 255, 255, 200);
|
drawOutlineRect(x, (SCREEN_HEIGHT - h) / 2, w, h, 255, 255, 255, 200);
|
||||||
|
|
||||||
drawText(SCREEN_WIDTH / 2, 100, 40, TA_CENTER, colors.white, "OBJECTIVES");
|
drawText(SCREEN_WIDTH / 2, 100, 40, TA_CENTER, colors.white, _("Objectives"));
|
||||||
|
|
||||||
y = 180;
|
y = 180;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ static void stats(void);
|
||||||
static void trophies(void);
|
static void trophies(void);
|
||||||
static void quit(void);
|
static void quit(void);
|
||||||
static void returnFromTrophyStats(void);
|
static void returnFromTrophyStats(void);
|
||||||
|
static void drawQuit(void);
|
||||||
|
static void quitMission(void);
|
||||||
int getMissionStatus(void);
|
int getMissionStatus(void);
|
||||||
|
|
||||||
static Texture *background;
|
static Texture *background;
|
||||||
|
@ -95,6 +97,11 @@ void initWorld(void)
|
||||||
getWidget("trophies", "gamePaused")->action = trophies;
|
getWidget("trophies", "gamePaused")->action = trophies;
|
||||||
getWidget("quit", "gamePaused")->action = quit;
|
getWidget("quit", "gamePaused")->action = quit;
|
||||||
|
|
||||||
|
getWidget("ok", "stats")->action = returnFromTrophyStats;
|
||||||
|
getWidget("ok", "trophies")->action = returnFromTrophyStats;
|
||||||
|
getWidget("ok", "gameQuit")->action = quitMission;
|
||||||
|
getWidget("cancel", "gameQuit")->action = returnFromTrophyStats;
|
||||||
|
|
||||||
if (world.missionType == MT_BOSS)
|
if (world.missionType == MT_BOSS)
|
||||||
{
|
{
|
||||||
startMission();
|
startMission();
|
||||||
|
@ -127,24 +134,31 @@ static void logic(void)
|
||||||
case WS_START:
|
case WS_START:
|
||||||
doWorldStart();
|
doWorldStart();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_IN_PROGRESS:
|
case WS_IN_PROGRESS:
|
||||||
doWorldInProgress();
|
doWorldInProgress();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_OBSERVING:
|
case WS_OBSERVING:
|
||||||
doWorldObserving();
|
doWorldObserving();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_PAUSED:
|
case WS_PAUSED:
|
||||||
doWorldPaused();
|
doWorldPaused();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_COMPLETE:
|
case WS_COMPLETE:
|
||||||
doWorldComplete();
|
doWorldComplete();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_GAME_OVER:
|
case WS_GAME_OVER:
|
||||||
doGameOver();
|
doGameOver();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WS_GAME_COMPLETE:
|
case WS_GAME_COMPLETE:
|
||||||
doGameComplete();
|
doGameComplete();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +209,10 @@ static void draw(void)
|
||||||
case SHOW_TROPHIES:
|
case SHOW_TROPHIES:
|
||||||
drawTrophies();
|
drawTrophies();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SHOW_QUIT:
|
||||||
|
drawQuit();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,6 +379,15 @@ static void doWorldInProgress(void)
|
||||||
{
|
{
|
||||||
doTrophies();
|
doTrophies();
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_ESCAPE])
|
||||||
|
{
|
||||||
|
returnFromTrophyStats();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (showing == SHOW_QUIT)
|
||||||
|
{
|
||||||
|
handleWidgets();
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_ESCAPE])
|
if (app.keyboard[SDL_SCANCODE_ESCAPE])
|
||||||
{
|
{
|
||||||
returnFromTrophyStats();
|
returnFromTrophyStats();
|
||||||
|
@ -683,6 +710,42 @@ void observeActivation(Entity *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawQuit(void)
|
||||||
|
{
|
||||||
|
SDL_Rect r;
|
||||||
|
|
||||||
|
drawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0, 128);
|
||||||
|
|
||||||
|
r.w = 650;
|
||||||
|
r.h = 325;
|
||||||
|
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
|
||||||
|
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
|
||||||
|
|
||||||
|
drawRect(r.x, r.y, r.w, r.h, 0, 0, 0, 192);
|
||||||
|
|
||||||
|
drawOutlineRect(r.x, r.y, r.w, r.h, 200, 200, 200, 255);
|
||||||
|
|
||||||
|
limitTextWidth(r.w - 100);
|
||||||
|
drawText(SCREEN_WIDTH / 2, r.y + 10, 26, TA_CENTER, colors.white, "Quit and return to hub?");
|
||||||
|
|
||||||
|
if (world.missionType == MT_TRAINING)
|
||||||
|
{
|
||||||
|
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, "As this is a tutorial mission, you can skip it and move onto the main game.");
|
||||||
|
}
|
||||||
|
else if (world.isReturnVisit)
|
||||||
|
{
|
||||||
|
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, "Your progress on this mission will be saved.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawText(SCREEN_WIDTH / 2, r.y + 65, 26, TA_CENTER, colors.white, "Warning: if you quit now, you will lose all progress on this level.");
|
||||||
|
}
|
||||||
|
|
||||||
|
limitTextWidth(0);
|
||||||
|
|
||||||
|
drawWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
void exitRadar(void)
|
void exitRadar(void)
|
||||||
{
|
{
|
||||||
startSectionTransition();
|
startSectionTransition();
|
||||||
|
@ -718,15 +781,25 @@ static void trophies(void)
|
||||||
|
|
||||||
static void quit(void)
|
static void quit(void)
|
||||||
{
|
{
|
||||||
|
showing = SHOW_QUIT;
|
||||||
|
showWidgetGroup("gameQuit");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void returnFromTrophyStats(void)
|
static void returnFromTrophyStats(void)
|
||||||
{
|
{
|
||||||
showWidgetGroup("hub");
|
showWidgetGroup("gamePaused");
|
||||||
showing = SHOW_WIDGETS;
|
showing = SHOW_WIDGETS;
|
||||||
app.keyboard[SDL_SCANCODE_ESCAPE] = 0;
|
app.keyboard[SDL_SCANCODE_ESCAPE] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void quitMission(void)
|
||||||
|
{
|
||||||
|
resume();
|
||||||
|
stopMusic();
|
||||||
|
world.state = WS_COMPLETE;
|
||||||
|
world.missionCompleteTimer = (FPS * 1.5) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
void destroyWorld(void)
|
void destroyWorld(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -25,7 +25,8 @@ enum
|
||||||
SHOW_NONE,
|
SHOW_NONE,
|
||||||
SHOW_WIDGETS,
|
SHOW_WIDGETS,
|
||||||
SHOW_STATS,
|
SHOW_STATS,
|
||||||
SHOW_TROPHIES
|
SHOW_TROPHIES,
|
||||||
|
SHOW_QUIT
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Texture *getTexture(const char *filename);
|
extern Texture *getTexture(const char *filename);
|
||||||
|
@ -101,6 +102,7 @@ extern void drawStats(void);
|
||||||
extern void doStats(void);
|
extern void doStats(void);
|
||||||
extern void doTrophies(void);
|
extern void doTrophies(void);
|
||||||
extern void drawTrophies(void);
|
extern void drawTrophies(void);
|
||||||
|
extern void limitTextWidth(int width);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
Loading…
Reference in New Issue