From f2c8359e59a848a3e006b3cd62c074aafa5d3fda Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 21 Feb 2018 08:16:18 +0000 Subject: [PATCH] Start of post mission screen. --- src/hub/postMission.c | 99 +++++++++++++++++++++++++++++++++++++++---- src/hub/postMission.h | 10 +++++ 2 files changed, 101 insertions(+), 8 deletions(-) diff --git a/src/hub/postMission.c b/src/hub/postMission.c index d2ebc0c..f634bac 100644 --- a/src/hub/postMission.c +++ b/src/hub/postMission.c @@ -23,20 +23,38 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void logic(void); static void draw(void); static void updateMissionStatus(void); + static int status; +static float missionCompleteY; +static Atlas *background; +static Texture *atlasTexture; +static float oNum; +static int canContinue; void initPostMission(void) { startSectionTransition(); + atlasTexture = getTexture("gfx/atlas/atlas.png"); + background = getImageFromAtlas("gfx/radar/background.png"); + updateMissionStatus(); - app.delegate.logic = logic; - app.delegate.draw = draw; - - app.restrictTrophyAlert = 0; - - endSectionTransition(); + if (status != MS_INCOMPLETE) + { + app.delegate.logic = logic; + app.delegate.draw = draw; + + app.restrictTrophyAlert = 0; + + canContinue = 0; + + missionCompleteY = SCREEN_HEIGHT; + + playSound(SND_MISSION_COMPLETE, 0); + + endSectionTransition(); + } } static void updateMissionStatus(void) @@ -69,11 +87,76 @@ static void updateMissionStatus(void) static void logic(void) { - destroyWorld(); + int done; + + done = (status == MS_INCOMPLETE); + + missionCompleteY = limit(missionCompleteY - 10, 50, SCREEN_HEIGHT); + + if (missionCompleteY == 50) + { + oNum += 0.1; + } + + if (canContinue && isAcceptControl()) + { + done = 1; + + clearControls(); + } + + if (done) + { + destroyWorld(); - initHub(); + initHub(); + } } static void draw(void) { + Objective *o; + SDL_Color c; + char *status; + int x, y, w, i; + + blitRectScaled(atlasTexture->texture, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, &background->rect, 0); + + drawText(SCREEN_WIDTH / 2, missionCompleteY, 45, TA_CENTER, colors.white, "Mission Complete!"); + + i = 0; + + if (missionCompleteY == 50) + { + w = 800; + x = (SCREEN_WIDTH - w) / 2; + y = 150; + + for (o = world.objectiveHead.next ; o != NULL ; o = o->next) + { + c = o->required ? colors.red : colors.white; + status = _("Incomplete"); + + if (o->currentValue >= o->targetValue) + { + c = colors.green; + status = _("Complete"); + } + + drawText(x + 20, y, 24, TA_LEFT, c, o->description); + drawText(SCREEN_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue); + drawText(x + w - 20, y, 24, TA_RIGHT, c, status); + + y += 55; + + if (oNum < ++i) + { + return; + } + } + + drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 80, 24, TA_CENTER, colors.white, _("Press Fire to Continue")); + + canContinue = 1; + } } diff --git a/src/hub/postMission.h b/src/hub/postMission.h index 101aec6..721fac2 100644 --- a/src/hub/postMission.h +++ b/src/hub/postMission.h @@ -27,7 +27,17 @@ extern void saveGame(void); extern void saveWorld(void); extern void destroyWorld(void); extern int getMissionStatus(void); +extern Texture *getTexture(const char *filename); +extern Atlas *getImageFromAtlas(char *filename); +extern void blitRectScaled(SDL_Texture *texture, int x, int y, int w, int h, SDL_Rect *srcRect, int center); +extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); +extern void drawLine(int x1, int y1, int x2, int y2, int r, int g, int b, int a); +extern float limit(float i, float low, float high); +extern void playSound(int snd, int ch); +extern int isAcceptControl(void); +extern void clearControls(void); extern App app; +extern Colors colors; extern Game game; extern World world;