diff --git a/data/widgets/galacticMap.json b/data/widgets/galacticMap.json index c510270..60f2dd7 100644 --- a/data/widgets/galacticMap.json +++ b/data/widgets/galacticMap.json @@ -38,5 +38,15 @@ "y" : 515, "w" : 200, "h": 34 + }, + { + "name" : "ok", + "group" : "fallen", + "type" : "WT_BUTTON", + "text" : "OK", + "x" : -1, + "y" : 400, + "w" : 200, + "h": 34 } ] diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index b2fa652..8ba4a9e 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -44,8 +44,11 @@ static void quit(void); static void startMission(void); static void returnFromOptions(void); static void doStarSystemView(void); +static void updatePandoranAdvance(void); +static void drawFallenView(void); +static void fallenOK(void); -static StarSystem *selectedStarSystem; +static StarSystem *selectedStarSystem, *fallenStarSystem; static Mission *selectedMission = {0}; static SDL_Texture *background; static SDL_Texture *starSystemTexture; @@ -80,14 +83,14 @@ void initGalacticMap(void) centerOnSelectedStarSystem(); + updatePandoranAdvance(); + saveGame(); pulseTimer = 0; arrowPulse = 0; - show = SHOW_GALAXY; - /* clear the pulses */ destroyGalacticMap(); @@ -103,6 +106,8 @@ void initGalacticMap(void) getWidget("ok", "stats")->action = statsOK; + getWidget("ok", "fallen")->action = fallenOK; + updateStarSystemMissions(); setMouse(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); @@ -112,6 +117,23 @@ void initGalacticMap(void) playMusic("music/Pressure.ogg"); } +static void updatePandoranAdvance(void) +{ + StarSystem *starSystem; + + for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) + { + if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0) + { + starSystem->side = SIDE_PANDORAN; + + show = SHOW_FALLEN_MESSAGE; + + fallenStarSystem = starSystem; + } + } +} + static void logic(void) { handleKeyboard(); @@ -175,11 +197,6 @@ static void doStarSystems(void) } } } - - if (starSystem->side != SIDE_PANDORAN && starSystem->fallsToPandorans && starSystem->completedMissions == starSystem->totalMissions && starSystem->totalMissions > 0) - { - starSystem->side = SIDE_PANDORAN; - } } } } @@ -322,6 +339,10 @@ static void draw(void) case SHOW_OPTIONS: drawOptions(); break; + + case SHOW_FALLEN_MESSAGE: + drawFallenView(); + break; } presentScene(); @@ -547,6 +568,34 @@ static void drawStarSystemDetail(void) drawWidgets("starSystem"); } +static void fallenOK(void) +{ + show = SHOW_GALAXY; +} + +static void drawFallenView(void) +{ + SDL_Rect r; + + r.w = 800; + r.h = 150; + r.x = (SCREEN_WIDTH / 2) - (r.w / 2); + r.y = (SCREEN_HEIGHT / 2) - (r.h / 2); + SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND); + + SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 225); + SDL_RenderFillRect(app.renderer, &r); + + SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 200); + SDL_RenderDrawRect(app.renderer, &r); + + SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE); + + drawText(SCREEN_WIDTH / 2, r.y + 25, 24, TA_CENTER, colors.white, "%s has fallen to the Pandorans", fallenStarSystem->name); + + drawWidgets("fallen"); +} + static void handleKeyboard(void) { if (app.keyboard[SDL_SCANCODE_ESCAPE]) diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 9a83384..0ecb079 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -20,11 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../common.h" -#define SHOW_GALAXY 0 -#define SHOW_STAR_SYSTEM 1 -#define SHOW_MENU 2 -#define SHOW_OPTIONS 3 -#define SHOW_STATS 4 +#define SHOW_GALAXY 0 +#define SHOW_STAR_SYSTEM 1 +#define SHOW_MENU 2 +#define SHOW_OPTIONS 3 +#define SHOW_STATS 4 +#define SHOW_FALLEN_MESSAGE 5 extern void prepareScene(void); extern void presentScene(void);