2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 void doTimeRemaining()
26 map.remainingSeconds--;
28 if ((map.remainingMinutes == 0) && (map.remainingSeconds <= 10) && (map.remainingSeconds > 0))
30 audio.playSound(SND_CLOCK, CH_TOUCH);
33 if (map.remainingSeconds < 0)
35 if (map.remainingMinutes > 0)
37 map.remainingSeconds = 59;
38 map.remainingMinutes--;
42 if ((map.remainingSeconds == 0) && (map.remainingMinutes == 0))
46 Math::removeBit(&player.flags, ENT_FLIES);
47 game.setMissionOver(MIS_TIMEUP);
50 replayData.header.time++;
55 static Graphics::SurfaceCache healthCache;
56 static Graphics::SurfaceCache oxygenCache;
57 static Graphics::SurfaceCache jetpackCache;
59 graphics.setFontSize(0);
60 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
64 graphics.blit(graphics.infoBar, 0, 0, graphics.screen, false);
66 graphics.drawString(_("Health"), 50, 5, TXT_RIGHT, graphics.screen, healthCache);
68 for (int i = 0 ; i < MAX_HEALTH ; i++)
70 if (i < player.health)
71 graphics.blit(graphics.getSprite("HealthBlock", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
73 graphics.blit(graphics.getSprite("HealthBlockEmpty", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
76 if (player.health <= 3)
77 if (engine.getFrameLoop() < 30)
78 for (int i = 0 ; i < player.health ; i++)
79 graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
81 if ((!game.hasAquaLung) && (!engine.cheatExtras))
83 graphics.drawString(_("Oxygen"), 305, 5, TXT_RIGHT, graphics.screen, oxygenCache);
85 for (int i = 0 ; i < 7 ; i++)
87 if (i < player.oxygen)
88 graphics.blit(graphics.getSprite("OxygenBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
90 graphics.blit(graphics.getSprite("OxygenBlockEmpty", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
93 if (player.oxygen <= 3)
94 if (engine.getFrameLoop() < 30)
95 for (int i = 0 ; i < player.oxygen ; i++)
96 graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
98 else if ((game.hasJetPack) || (engine.cheatExtras))
100 graphics.drawString(_("Jetpack"), 305, 5, TXT_RIGHT, graphics.screen, jetpackCache);
102 for (int i = 0 ; i < 7 ; i++)
105 graphics.blit(graphics.getSprite("OxygenBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
107 graphics.blit(graphics.getSprite("OxygenBlockEmpty", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
110 if ((player.fuel < 3) && (!(player.flags & ENT_FLIES)))
111 if (engine.getFrameLoop() < 30)
112 for (int i = 0 ; i < player.fuel ; i++)
113 graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
116 if ((map.mainBossPart == NULL || strstr(engine.message, "Aqua") || strstr(engine.message, "Jet")) && (game.missionOverReason != MIS_GAMECOMPLETE))
118 if (engine.messageTime > -1)
120 switch (engine.messageType)
123 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
126 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
129 graphics.setFontColor(0xff, 0xaa, 0x00, 0x00, 0x00, 0x00);
132 graphics.setFontColor(0x00, 0xff, 0xff, 0x00, 0x00, 0x00);
135 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
139 static Graphics::SurfaceCache cache;
140 graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
141 graphics.drawString(_(engine.message), 320, 466, true, graphics.screen, cache);
143 engine.messageTime--;
144 if (engine.messageTime == -1)
146 engine.messagePriority = -1;
147 engine.message[0] = 0;
150 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
155 if (map.mainBossPart != NULL)
157 graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
159 static Graphics::SurfaceCache cache;
160 graphics.drawString(_(map.mainBossPart->name), 255, 460, TXT_RIGHT, graphics.screen, cache);
161 graphics.drawRect(265 - 1, 463 - 1, 200 + 2, 10 + 2, graphics.white, graphics.screen);
162 graphics.drawRect(265, 463, 200, 10, graphics.black, graphics.screen);
164 if (map.mainBossPart->health > 0)
166 graphics.drawRect(265, 463, (int)(map.mainBossPart->health * map.bossEnergyMeterBit), 10, graphics.red, graphics.screen);
171 static Graphics::SurfaceCache weaponCache;
172 snprintf(string, sizeof string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
173 graphics.drawString(string, 630, 5, TXT_RIGHT, graphics.screen, weaponCache);
177 snprintf(string, sizeof string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
178 graphics.blit(graphics.infoBar, 0, 25, graphics.screen, false);
180 if ((map.remainingMinutes > 0) || (map.remainingSeconds > 0))
182 if (map.remainingMinutes == 0)
184 if (map.remainingSeconds > 0)
186 if (map.remainingSeconds <= 10)
188 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
190 else if (map.remainingSeconds <= 30)
192 graphics.setFontColor(0xff, 0xff, 0x00, 0x00, 0x00, 0x00);
196 static Graphics::SurfaceCache cache;
197 graphics.drawString(string, 320, 35, TXT_CENTERED, graphics.screen, cache);
201 static Graphics::SurfaceCache cache;
202 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
203 graphics.setFontSize(3);
204 graphics.drawString(_("Mission Failed! Time Up!"), 320, 220, TXT_CENTERED, graphics.screen, cache);
205 graphics.setFontSize(0);
206 game.canContinue = 0;
224 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
227 snprintf(string, sizeof string, _("Position = %d:%d"), (int)player.x, (int)player.y);
228 graphics.drawString(string, 5, 25, false, graphics.screen);
231 graphics.drawString(_("*** PAUSED ***"), 320, y, TXT_CENTERED, graphics.screen);
233 graphics.drawString(_("MIAs in Area"), col1, y += 30, TXT_RIGHT, graphics.screen);
234 snprintf(string, sizeof string, "%d", map.totalMIAs - map.foundMIAs);
235 graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
237 graphics.drawString(_("Enemies Defeated"), col1, y += 20, TXT_RIGHT, graphics.screen);
238 snprintf(string, sizeof string, "%d", game.currentMissionEnemiesDefeated);
239 graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
241 graphics.drawString(_("Items Collected"), col1, y += 20, TXT_RIGHT, graphics.screen);
242 snprintf(string, sizeof string, "%d / %d", map.foundItems, map.totalItems);
243 graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
245 graphics.drawString(_("Best Combo"), col1, y += 20, TXT_RIGHT, graphics.screen);
246 snprintf(string, sizeof string, _("%d Hits"), game.maxComboHits);
247 graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
249 graphics.drawString(_("++ Inventory ++"), 320, y += 40, TXT_CENTERED, graphics.screen);
252 // Do the objectives list
253 Objective *objective = (Objective*)map.objectiveList.getHead();
258 if (map.totalMIAs > 0)
260 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
261 snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
262 graphics.drawString(message, col1, y, TXT_RIGHT, graphics.screen);
264 if (map.foundMIAs < map.requiredMIAs)
266 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
267 snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
268 graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
272 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
273 graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.screen);
277 while (objective->next != NULL)
279 objective = (Objective*)objective->next;
283 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
285 if ((game.skill < 3) && (strstr(objective->description, "L.R.T.S.")) && (!gameData.completedWorld))
287 graphics.drawString(_("???? ???????? ????"), col1, y, TXT_RIGHT, graphics.screen);
291 graphics.drawString(_(objective->description), col1, y, TXT_RIGHT, graphics.screen);
294 // this is a fake objective (for the 4th Ancient Tomb)
295 if (objective->targetValue == -1)
297 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
298 graphics.drawString(_("Incomplete"), col2, y, TXT_LEFT, graphics.screen);
300 else if (objective->currentValue < objective->targetValue)
302 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
303 if (objective->targetValue == 1)
305 graphics.drawString(_("Incomplete"), col2, y, TXT_LEFT, graphics.screen);
309 snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
310 graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
313 if (!objective->required)
315 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
316 graphics.drawString(_("(optional)"), 450, y, TXT_LEFT, graphics.screen);
321 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
322 graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.screen);
326 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
328 snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
329 graphics.drawString(string, 320, 430, TXT_CENTERED, graphics.screen);
332 SDL_Surface *createMusicInfo(void)
334 graphics.setFontSize(0);
335 graphics.setFontColor(0xff, 0xff, 0xff, 0x40, 0x40, 0x40);
338 SDL_Surface *text2 = NULL;
339 SDL_Surface *text3 = NULL;
340 SDL_Surface *icon = NULL;
346 text1 = graphics.getString(audio.songtitle, true);
350 if(audio.songalbum[0])
352 graphics.setFontColor(0x80, 0xc0, 0xff, 0x40, 0x40, 0x40);
354 text2 = graphics.getString(audio.songalbum, true);
361 if(audio.songartist[0])
363 graphics.setFontColor(0xff, 0xc0, 0x80, 0x40, 0x40, 0x40);
365 text3 = graphics.getString(audio.songartist, true);
371 if(audio.songlicense >= 0)
373 icon = graphics.license[audio.songlicense];
383 panel = graphics.createSurface(w + 10, h + 10);
384 SDL_FillRect(panel, NULL, SDL_MapRGBA(panel->format, 0, 0, 0, 128));
388 graphics.blit(text1, x - text1->w, y, panel, false);
389 SDL_FreeSurface(text1);
394 graphics.blit(text2, x - text2->w, y, panel, false);
395 SDL_FreeSurface(text2);
400 graphics.blit(text3, x - text3->w, y, panel, false);
401 SDL_FreeSurface(text3);
406 graphics.blit(icon, x - icon->w, y, panel, false);
412 void doMusicInfo(unsigned int ticks)
414 if(!audio.songtitle[0])
417 static SDL_Surface *panel;
422 if (ticks > 12000 || ticks < 5000)
426 SDL_FreeSurface(panel);
434 alpha = 1 - (6000 - ticks) / 1000.0f;
435 else if(ticks > 11000)
436 alpha = (12000 - ticks) / 1000.0f;
443 panel = createMusicInfo();
447 SDL_SetAlpha(panel, 255 * alpha);
448 graphics.blit(panel, 620 - panel->w, 420 - panel->h, graphics.screen, false);