]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/info.cpp
Import of version 1.14 minus music and sounds.
[quix0rs-blobwars.git] / src / info.cpp
1 /*
2 Copyright (C) 2004 Parallel Realities
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #include "info.h"
22
23 void doTimeRemaining()
24 {               
25         map.remainingSeconds--;
26         
27         if ((map.remainingMinutes == 0) && (map.remainingSeconds <= 10) && (map.remainingSeconds > 0))
28         {
29                 audio.playSound(SND_CLOCK, CH_TOUCH);
30         }
31         
32         if (map.remainingSeconds < 0)
33         {
34                 if (map.remainingMinutes > 0)
35                 {
36                         map.remainingSeconds = 59;
37                         map.remainingMinutes--;
38                 }
39         }
40         
41         if ((map.remainingSeconds == 0) && (map.remainingMinutes == 0))
42         {
43                 player.health = 0;
44                 player.immune = 0;
45                 Math::removeBit(&player.flags, ENT_FLIES);
46                 game.setMissionOver(MIS_TIMEUP);
47         }
48         
49         replayData.header.time++;
50 }
51
52 void doStatusBar()
53 {
54         graphics.setFontSize(0);
55         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
56
57         char string[1024];
58
59         graphics.blit(graphics.infoBar, 0, 0, graphics.screen, false);
60
61         graphics.drawString(_("Health"), 50, 5, TXT_RIGHT, graphics.screen);
62
63         for (int i = 0 ; i < MAX_HEALTH ; i++)
64         {
65                 if (i < player.health)
66                         graphics.blit(graphics.getSprite("HealthBlock", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
67                 else
68                         graphics.blit(graphics.getSprite("HealthBlockEmpty", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
69         }
70
71         if (player.health <= 3)
72                 if (engine.getFrameLoop() < 30)
73                         for (int i = 0 ; i < player.health ; i++)
74                                 graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 60 + (i * 15), 7, graphics.screen, false);
75
76         if ((!game.hasAquaLung) && (!engine.cheatExtras))
77         {
78                 graphics.drawString(_("Oxygen"), 305, 5, TXT_RIGHT, graphics.screen);
79
80                 for (int i = 0 ; i < 7 ; i++)
81                 {
82                         if (i < player.oxygen)
83                                 graphics.blit(graphics.getSprite("OxygenBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
84                         else
85                                 graphics.blit(graphics.getSprite("OxygenBlockEmpty", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
86                 }
87
88                 if (player.oxygen <= 3)
89                         if (engine.getFrameLoop() < 30)
90                                 for (int i = 0 ; i < player.oxygen ; i++)
91                                         graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
92         }
93         else if ((game.hasJetPack) || (engine.cheatExtras))
94         {
95                 graphics.drawString(_("Jetpack"), 305, 5, TXT_RIGHT, graphics.screen);
96
97                 for (int i = 0 ; i < 7 ; i++)
98                 {
99                         if (i < player.fuel)
100                                 graphics.blit(graphics.getSprite("OxygenBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
101                         else
102                                 graphics.blit(graphics.getSprite("OxygenBlockEmpty", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
103                 }
104
105                 if ((player.fuel < 3) && (!(player.flags & ENT_FLIES)))
106                         if (engine.getFrameLoop() < 30)
107                                 for (int i = 0 ; i < player.fuel ; i++)
108                                         graphics.blit(graphics.getSprite("WarningBlock", true)->getCurrentFrame(), 315 + (i * 15), 7, graphics.screen, false);
109         }
110
111         if ((map.mainBossPart == NULL || strstr(engine.message, "Aqua") || strstr(engine.message, "Jet")) && (game.missionOverReason != MIS_GAMECOMPLETE))
112         {
113                 if (engine.messageTime > -1)
114                 {
115                         switch (engine.messageType)
116                         {
117                                 case INFO_NORMAL:
118                                         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
119                                         break;
120                                 case INFO_OBJECTIVE:
121                                         graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
122                                         break;
123                                 case INFO_HINT:
124                                         graphics.setFontColor(0xff, 0xaa, 0x00, 0x00, 0x00, 0x00);
125                                         break;
126                                 case INFO_ACTIVATE:
127                                         graphics.setFontColor(0x00, 0xff, 0xff, 0x00, 0x00, 0x00);
128                                         break;
129                                 case INFO_BAD:
130                                         graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
131                                         break;
132                         }
133         
134                         graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
135                         graphics.drawString(_(engine.message), 320, 466, true, graphics.screen);
136                         
137                         engine.messageTime--;
138                         if (engine.messageTime == -1)
139                         {
140                                 engine.messagePriority = -1;
141                                 strcpy(engine.message, "");
142                         }
143         
144                         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
145                 }
146         }
147         else
148         {
149                 if (map.mainBossPart != NULL)
150                 {
151                         graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
152                         
153                         graphics.drawString(_(map.mainBossPart->name), 255, 460, TXT_RIGHT, graphics.screen);
154                         graphics.drawRect(265 - 1, 463 - 1, 200 + 2, 10 + 2, graphics.white, graphics.screen);
155                         graphics.drawRect(265, 463, 200, 10, graphics.black, graphics.screen);
156                         
157                         if (map.mainBossPart->health > 0)
158                         {
159                                 graphics.drawRect(265, 463, (int)(map.mainBossPart->health * map.bossEnergyMeterBit), 10, graphics.red, graphics.screen);
160                         }
161                 }
162         }
163
164         sprintf(string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
165         graphics.drawString(string, 630, 5, TXT_RIGHT, graphics.screen);
166         
167         if (game.skill == 3)
168         {
169                 sprintf(string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
170                 graphics.blit(graphics.infoBar, 0, 25, graphics.screen, false);
171                 
172                 if ((map.remainingMinutes > 0) || (map.remainingSeconds > 0))
173                 {
174                         if (map.remainingMinutes == 0)
175                         {
176                                 if (map.remainingSeconds > 0)
177                                 {
178                                         if (map.remainingSeconds <= 10)
179                                         {
180                                                 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
181                                         }
182                                         else if (map.remainingSeconds <= 30)
183                                         {
184                                                 graphics.setFontColor(0xff, 0xff, 0x00, 0x00, 0x00, 0x00);
185                                         }
186                                 }
187                         }
188                         graphics.drawString(string, 320, 35, TXT_CENTERED, graphics.screen);
189                 }
190                 else
191                 {
192                         graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
193                         graphics.setFontSize(3);
194                         graphics.drawString(_("Mission Failed! Time Up!"), 320, 220, TXT_CENTERED, graphics.screen);
195                         graphics.setFontSize(0);
196                         game.canContinue = 0;
197                 }
198         }
199 }
200
201 void doPauseInfo()
202 {
203         int col1, col2, y;
204
205         col1 = 310;
206         col2 = 330;
207         y = 60;
208
209         graphics.fade(130);
210
211         char string[1024];
212         strcpy(string, "");
213         
214         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
215
216         //#if !USEPAK
217         sprintf(string, _("Position = %d:%d"), (int)player.x, (int)player.y);
218         graphics.drawString(string, 5, 25, false, graphics.screen);
219         //#endif
220
221         graphics.drawString(_("*** PAUSED ***"), 320, y, TXT_CENTERED, graphics.screen);
222
223         graphics.drawString(_("MIAs in Area"), col1, y += 30, TXT_RIGHT, graphics.screen);
224         sprintf(string, "%d", map.totalMIAs - map.foundMIAs);
225         graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
226
227         graphics.drawString(_("Enemies Defeated"), col1, y += 20, TXT_RIGHT, graphics.screen);
228         sprintf(string, "%d", game.currentMissionEnemiesDefeated);
229         graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
230
231         graphics.drawString(_("Items Collected"), col1, y += 20, TXT_RIGHT, graphics.screen);
232         sprintf(string, "%d / %d", map.foundItems, map.totalItems);
233         graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
234
235         graphics.drawString(_("Best Combo"), col1, y += 20, TXT_RIGHT, graphics.screen);
236         sprintf(string, _("%d Hits"), game.maxComboHits);
237         graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
238
239         graphics.drawString(_("++ Inventory ++"), 320, y += 40, TXT_CENTERED, graphics.screen);
240         showCarriedItems();
241
242         // Do the objectives list
243         Objective *objective = (Objective*)map.objectiveList.getHead();
244         char message[100];
245
246         y += 60;
247
248         if (map.totalMIAs > 0)
249         {
250                 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
251                 sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
252                 graphics.drawString(message, col1, y, TXT_RIGHT, graphics.screen);
253
254                 if (map.foundMIAs < map.requiredMIAs)
255                 {
256                         graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
257                         sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
258                         graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
259                 }
260                 else
261                 {
262                         graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
263                         graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.screen);
264                 }
265         }
266
267         while (objective->next != NULL)
268         {
269                 objective = (Objective*)objective->next;
270
271                 y += 20;
272                 
273                 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
274                 
275                 if ((game.skill < 3) &&  (strstr(objective->description, "L.R.T.S.")) && (!gameData.completedWorld))
276                 {
277                         graphics.drawString(_("???? ???????? ????"), col1, y, TXT_RIGHT, graphics.screen);
278                 }
279                 else
280                 {
281                         graphics.drawString(_(objective->description), col1, y, TXT_RIGHT, graphics.screen);
282                 }
283                 
284                 // this is a fake objective (for the 4th Ancient Tomb)
285                 if (objective->targetValue == -1)
286                 {
287                         graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
288                         graphics.drawString(_("Incomplete"), col2, y, TXT_LEFT, graphics.screen);
289                 }
290                 else if (objective->currentValue < objective->targetValue)
291                 {
292                         graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
293                         if (objective->targetValue == 1)
294                         {
295                                 graphics.drawString(_("Incomplete"), col2, y, TXT_LEFT, graphics.screen);
296                         }
297                         else
298                         {
299                                 sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
300                         graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
301                         }
302
303                         if (!objective->required)
304                         {
305                                 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
306                                 graphics.drawString(_("(optional)"), 450, y, TXT_LEFT, graphics.screen);
307                         }
308                 }
309                 else
310                 {
311                         graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
312                         graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.screen);
313                 }
314         }
315
316         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
317
318         y += 10;
319
320         sprintf(string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
321         graphics.drawString(string, 320, 430, TXT_CENTERED, graphics.screen);
322 }