]> git.mxchange.org Git - quix0rs-blobwars.git/blob - src/hub.cpp
Use DEBUG instead of USEPAK to enable debugging code.
[quix0rs-blobwars.git] / src / hub.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 "hub.h"
22
23 void createStatsPanel(int page)
24 {
25         SDL_Surface *image = graphics.getSprite("infoPanel", true)->image[0];
26
27         graphics.drawRect(1, 1, image->w - 2, image->h - 2, graphics.black, graphics.white, image);
28
29         char string[100];
30         int x1 = 80;
31         int x2 = 270;
32         int x3 = 300;
33         int y = 15;
34
35         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
36
37         graphics.drawString(_("Metal Blob Solid : Statistics"), 200, y, true, image);
38         y += 10;
39         
40         Sprite *arrows = graphics.getSprite("HubArrows", true);
41
42         switch (page)
43         {
44                 case 0:
45                         graphics.drawString(_("Skill Level:"), x1, y += 20, false, image);
46                         snprintf(string, sizeof string, "%s", _(skill[game.skill]));
47                         graphics.drawString(string, x2, y, false, image);
48
49                         graphics.drawString(_("Score:"), x1, y += 20, false, image);
50                         snprintf(string, sizeof string, "%d", game.score);
51                         graphics.drawString(string, x2, y, false, image);
52
53                         graphics.drawString(_("MIAs Saved:"), x1, y += 20, false, image);
54                         snprintf(string, sizeof string, "%d", game.totalMIAsRescued);
55                         graphics.drawString(string, x2, y, false, image);
56
57                         graphics.drawString(_("Objectives Completed:"), x1, y += 20, false, image);
58                         snprintf(string, sizeof string, "%d", game.totalObjectivesCompleted);
59                         graphics.drawString(string, x2, y, false, image);
60
61                         // Don't do this on Extreme or it will always say 100%
62                         if (game.skill < 3)
63                         {
64                                 graphics.drawString(_("Percentage Complete:"), x1, y += 20, false, image);
65                                 snprintf(string, sizeof string, "%d%%", gameData.getPercentageComplete());
66                                 graphics.drawString(string, x2, y, false, image);
67                         }
68
69                         snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Total Game Time"), game.totalHours, game.totalMinutes, game.totalSeconds);
70                         graphics.drawString(string, 200, y += 110, true, image);
71
72                         break;
73
74                 case 1:
75
76                         graphics.drawString(_("Enemies Defeated:"), x1, y += 20, false, image);
77                         snprintf(string, sizeof string, "%d", game.totalEnemiesDefeated);
78                         graphics.drawString(string, x2, y, false, image);
79
80                         graphics.drawString(_("Items Collected:"), x1, y += 20, false, image);
81                         snprintf(string, sizeof string, "%d", game.totalItemsCollected);
82                         graphics.drawString(string, x2, y, false, image);
83
84                         graphics.drawString(_("Bonuses Picked Up:"), x1, y += 20, false, image);
85                         snprintf(string, sizeof string, "%d", game.totalBonusesCollected);
86                         graphics.drawString(string, x2, y, false, image);
87
88                         graphics.drawString(_("Best Combo:"), x1, y += 20, false, image);
89                         snprintf(string, sizeof string, _("%d Hits"), game.maxComboHits);
90                         graphics.drawString(string, x2, y, false, image);
91                         
92                         graphics.drawString(_("Missions Started:"), x1, y += 20, false, image);
93                         snprintf(string, sizeof string, "%d", game.levelsStarted);
94                         graphics.drawString(string, x2, y, false, image);
95
96                         graphics.drawString(_("Continues Used:"), x1, y += 20, false, image);
97                         snprintf(string, sizeof string, "%d", game.continuesUsed);
98                         graphics.drawString(string, x2, y, false, image);
99                         
100                         if ((game.continuesUsed > 0) && (game.levelsStarted > 0))
101                         {
102                                 graphics.drawString(_("Average Continue Usage:"), x1, y += 20, false, image);
103                                 snprintf(string, sizeof string, "%d", (game.continuesUsed / game.levelsStarted));
104                                 graphics.drawString(string, x2, y, false, image);
105                         }
106
107                         graphics.drawString(_("Escapes Used:"), x1, y += 20, false, image);
108                         snprintf(string, sizeof string, "%d", game.escapes);
109                         graphics.drawString(string, x2, y, false, image);
110
111                         break;
112
113                 case 2:
114                 
115                         x1 = 20;
116                         x2 = 170;
117                         x3 = 300;
118
119                         graphics.drawString(_("Weapon"), x1, y += 20, false, image);
120                         graphics.drawString(_("Ammo Used"), x2, y, false, image);
121                         graphics.drawString(_("Accuracy"), x3, y, false, image);
122
123                         graphics.drawString(_("Pistol"), x1, y += 30, false, image);
124                         snprintf(string, sizeof string, "%d", game.bulletsFired[WP_PISTOL]);
125                         graphics.drawString(string, x2, y, false, image);
126                         snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_PISTOL));
127                         graphics.drawString(string, x3, y, false, image);
128
129                         graphics.drawString(_("Machine Gun"), x1, y += 20, false, image);
130                         snprintf(string, sizeof string, "%d", game.bulletsFired[WP_MACHINEGUN]);
131                         graphics.drawString(string, x2, y, false, image);
132                         snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_MACHINEGUN));
133                         graphics.drawString(string, x3, y, false, image);
134
135                         graphics.drawString(_("Laser Cannon"), x1, y += 20, false, image);
136                         snprintf(string, sizeof string, "%d", game.bulletsFired[WP_LASER]);
137                         graphics.drawString(string, x2, y, false, image);
138                         snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_LASER));
139                         graphics.drawString(string, x3, y, false, image);
140                         
141                         graphics.drawString(_("Grenades"), x1, y += 20, false, image);
142                         snprintf(string, sizeof string, "%d", game.bulletsFired[WP_GRENADES]);
143                         graphics.drawString(string, x2, y, false, image);
144                         snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_GRENADES));
145                         graphics.drawString(string, x3, y, false, image);
146
147                         graphics.drawString(_("Spread Gun"), x1, y += 20, false, image);
148                         snprintf(string, sizeof string, "%d", game.bulletsFired[WP_SPREAD]);
149                         graphics.drawString(string, x2, y, false, image);
150                         snprintf(string, sizeof string, "%d%%", game.getWeaponAccuracy(WP_SPREAD));
151                         graphics.drawString(string, x3, y, false, image);
152                         
153                         graphics.drawString(_("Total"), x1, y += 30, false, image);
154                         snprintf(string, sizeof string, "%d", game.getTotalBulletsFired());
155                         graphics.drawString(string, x2, y, false, image);
156                         snprintf(string, sizeof string, "%d%%", game.getTotalAccuracy());
157                         graphics.drawString(string, x3, y, false, image);
158
159                         snprintf(string, sizeof string, "%s - %s", _("Most Used Weapon"), _(weapon[game.getMostUsedWeapon()].name));
160                         graphics.drawString(string, 200, y += 50, true, image);
161
162                         break;
163         }
164
165         graphics.blit(arrows->image[0], 150, 260, image, false);
166         graphics.blit(arrows->image[2], 200, 260, image, false);
167
168         if (page == 0)
169                 graphics.blit(arrows->image[1], 150, 260, image, false);
170
171         if (page == 2)
172                 graphics.blit(arrows->image[3], 200, 260, image, false);
173 }
174
175 void loadLevelBrief(const char *levelName)
176 {
177         char briefLine[1024];
178
179         if (!engine.loadData(_("data/levelBrief")))
180         {
181                 graphics.showErrorAndExit("Couldn't load mission briefing file (%s)", _("data/levelBrief"));
182         }
183
184         char *line = strtok((char*)engine.dataBuffer, "\n");
185         bool collectData = false;
186         SDL_Surface *image = graphics.getSprite("infoPanel", true)->image[0];
187
188         int i = 0 ;
189
190         graphics.clearChatString();
191
192         while (true)
193         {
194                 if (collectData)
195                 {
196                         sscanf(line, "%[^\n\r]", briefLine);
197
198                         if (strcmp(briefLine, "@EOF@") == 0)
199                                 break;
200
201                         if (line[0] == '[')
202                                 break;
203
204                         graphics.createChatString(line);
205                 }
206                 else
207                 {
208                         if (line[0] == '[')
209                         {
210                                 sscanf(line, "%*c %[^]]", briefLine);
211                                 if (strcmp(briefLine, levelName) == 0)
212                                         collectData = true;
213                         }
214                 }
215
216                 line = strtok(NULL, "\n");
217                 if (line == NULL)
218                         break;
219
220                 i++;
221
222                 // sanity check!
223                 if (i == 10000)
224                         break;
225         }
226         
227         graphics.drawChatString(image, 40);
228 }
229
230 void createObjectivesPanel(const char *levelName)
231 {
232         SDL_Surface *image = graphics.getSprite("infoPanel", true)->image[0];
233
234         Data *data = (Data*)gameData.dataList.getHead();
235
236         bool found = false;
237
238         graphics.drawRect(1, 1, image->w - 2, image->h - 2, graphics.black, graphics.white, image);
239
240         char string[100];
241         char levelMIAKey[100];
242         int x1 = 60;
243         int x2 = 260;
244         int y = 15;
245         
246         snprintf(levelMIAKey, sizeof levelMIAKey, "%s MIAs", levelName);
247
248         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
249
250         snprintf(string, sizeof string, _("Information for %s"), _(levelName));
251         graphics.drawString(string, 200, y, true, image);
252         y += 10;
253
254         while (data->next != NULL)
255         {
256                 data = (Data*)data->next;
257
258                 if ((strcmp(data->key, levelName) == 0) || (strstr(data->key, levelMIAKey)))
259                 {
260                         found = true;
261
262                         if (strstr(data->key, "MIAs"))
263                         {
264                                 // if it says 0 / 0 don't bother...
265                                 if (strcmp(data->value, "0 / 0"))
266                                 {
267                                         graphics.drawString(_("MIAs Rescued"), x1, y += 20, false, image);
268                                         snprintf(string, sizeof string, "%d / %d", data->current, data->target);
269                                         (data->isComplete()) ? graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00) : graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
270                                         graphics.drawString(string, x2, y, false, image);
271                                 }
272                         }
273                         else if (!strstr(data->value, "MIA_"))
274                         {
275                                 if ((game.skill < 3) &&  (strstr(data->value, "L.R.T.S.")) && (!gameData.completedWorld))
276                                 {
277                                         graphics.drawString(_("???? ???????? ????"), x1, y += 20, false, image);
278                                 }
279                                 else
280                                 {
281                                         strncpy(string, _(data->value), sizeof string);
282                                         
283                                         if (strlen(string) >= 25)
284                                         {
285                                                 int cut_char = 25;
286                                                 // don't break unicode characters
287                                                 while (((string[cut_char] >> 6) & 3) == 2)
288                                                 {
289                                                         cut_char--;
290                                                 }
291
292                                                 string[cut_char++] = '.';
293                                                 string[cut_char++] = '.';
294                                                 string[cut_char++] = '.';
295                                                 string[cut_char] = '\0';
296                                         }
297                                         
298                                         graphics.drawString(string, x1, y += 20, false, image);
299                                 }
300                                 
301                                 if (data->target == 1)
302                                 {
303                                         snprintf(string, sizeof string, "%s", (data->isComplete()) ? _("Completed") : _("Incomplete"));
304                                 }
305                                 else
306                                 {
307                                         snprintf(string, sizeof string, "%d / %d", data->current, data->target);
308                                 }
309                                 
310                                 (data->isComplete()) ? graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00) : graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
311                                 graphics.drawString(string, x2, y, false, image);
312                         }
313                 }
314
315                 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
316         }
317
318         if (!found)
319                 loadLevelBrief(levelName);
320 }
321
322 void createMIAPanel(int start, int max)
323 {
324         char string[100];
325         char name[100];
326         int x1 = 20;
327         int x2 = 130;
328         int x3 = 310;
329         int y = 15;
330
331         int current = 0;
332         int end = 0;
333
334         SDL_Surface *image = graphics.getSprite("infoPanel", true)->image[0];
335
336         Data *data = (Data*)gameData.dataList.getHead();
337
338         graphics.drawRect(1, 1, image->w - 2, image->h - 2, graphics.black, graphics.white, image);
339
340         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
341
342         graphics.drawString(_("MIA Statistics"), 200, y, true, image);
343
344         graphics.drawString(_("Name"), x1, y += 20, false, image);
345         graphics.drawString(_("Location"), x2, y, false, image);
346         graphics.drawString(_("Status"), x3, y, false, image);
347
348         y += 10;
349
350         while (data->next != NULL)
351         {
352                 data = (Data*)data->next;
353
354                 if (strstr(data->value, "MIA_"))
355                 {
356                         if (current < start)
357                         {
358                                 current++;
359                                 continue;
360                         }
361
362                         snprintf(name, sizeof name, "%s", data->value);
363                         strtok(name, "_");
364
365                         snprintf(string, sizeof string, "%s", strtok(NULL, "_"));
366                         graphics.drawString(string, x1, y += 20, false, image);
367
368                         graphics.drawString(_(data->key), x2, y, false, image);
369
370                         if (data->isComplete())
371                         {
372                                 snprintf(string, sizeof string, "%s", _("Found"));
373                                 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
374                         }
375                         else
376                         {
377                                 snprintf(string, sizeof string, "%s", _("Missing"));
378                                 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
379                         }
380
381                         graphics.drawString(string, x3, y, false, image);
382
383                         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
384
385                         end++;
386
387                         if (end == 9)
388                                 break;
389                 }
390         }
391
392         Sprite *arrows = graphics.getSprite("HubArrows", true);
393
394         if (start > 0)
395                 graphics.blit(arrows->image[0], 150, 260, image, false);
396         else
397                 graphics.blit(arrows->image[1], 150, 260, image, false);
398
399         if ((end == 9) && (current + 9 < max))
400                 graphics.blit(arrows->image[2], 200, 260, image, false);
401         else
402                 graphics.blit(arrows->image[3], 200, 260, image, false);
403 }
404
405 bool requirementMet(const char *requiredLevel)
406 {
407         if (strstr(requiredLevel, "Stages"))
408         {
409                 int stages = 0;
410                 sscanf(requiredLevel, "%*s %d", &stages);
411
412                 if (game.stagesCleared >= stages)
413                 {
414                         presentPlayerMedal(requiredLevel);
415                         return true;
416                 }
417         }
418         
419         if (engine.cheatLevels)
420         {
421                 return true;
422         }
423
424         if (strcmp(requiredLevel, "@none@") == 0)
425         {
426                 return true;
427         }
428
429         return gameData.requiredLevelCleared(requiredLevel);
430 }
431
432 int doHub()
433 {
434         SDL_FillRect(graphics.screen, NULL, graphics.black);
435         graphics.delay(1000);
436         
437         graphics.free();
438         audio.free();
439
440         graphics.loadBackground("gfx/main/worldMap.jpg");
441         audio.loadMusic("music/forAFriend.mod");
442         
443         // we might want this now, for medals
444         audio.loadSound(SND_ITEM, "sound/item.wav");
445         
446         graphics.quickSprite("cheatHeader", graphics.loadImage("gfx/main/cheats.png"));
447         graphics.quickSprite("optionsHeader", graphics.loadImage("gfx/main/options.png"));
448         graphics.quickSprite("keyHeader", graphics.loadImage("gfx/main/keyConfig.png"));
449         graphics.quickSprite("joystickHeader", graphics.loadImage("gfx/main/joystickConfig.png"));
450         graphics.quickSprite("optionsBackground", graphics.loadImage("gfx/main/optionsBackground.png"));
451
452         char string[80];
453
454         Sprite *cursor = graphics.addSprite("Cursor");
455         for (int i = 0 ; i < 6 ; i++)
456         {
457                 snprintf(string, sizeof string, "gfx/main/cursor%d.png", i + 1);
458                 cursor->setFrame(i, graphics.loadImage(string), 10);
459         }
460
461         Sprite *newTarget = graphics.addSprite("NewTarget");
462         Sprite *visitedTarget = graphics.addSprite("VisitedTarget");
463         
464         for (int i = 0 ; i < 5 ; i++)
465         {
466                 snprintf(string, sizeof string, "gfx/sprites/miaSignal%d.png", i + 1);
467                 
468                 newTarget->setFrame(i, graphics.loadImage(string, -60, 0, 0), 15);
469                 visitedTarget->setFrame(i, graphics.loadImage(string, 0, 0, 0), 15);
470         }
471
472         Sprite *hubIcons = graphics.addSprite("HubIcons");
473         for (int i = 0 ; i < 6 ; i++)
474         {
475                 snprintf(string, sizeof string, "gfx/main/hubIcon%d.png", i + 1);
476                 hubIcons->setFrame(i, graphics.loadImage(string), 60);
477         }
478
479         SDL_Surface *infoPanel = graphics.quickSprite("infoPanel", graphics.createSurface(400, 300));
480
481         Sprite *hubArrows = graphics.addSprite("HubArrows");
482         hubArrows->setFrame(0, graphics.loadImage("gfx/main/hubArrowLeft.png"), 60);
483         hubArrows->setFrame(1, graphics.loadImage("gfx/main/hubArrowLeft2.png"), 60);
484         hubArrows->setFrame(2, graphics.loadImage("gfx/main/hubArrowRight.png"), 60);
485         hubArrows->setFrame(3, graphics.loadImage("gfx/main/hubArrowRight2.png"), 60);
486
487         List hubList;
488         HubLevel *hubPoint;
489
490         engine.loadData("data/hub");
491
492         char *line = strtok((char*)engine.dataBuffer, "\n");
493
494         char name[50], level[50], requiredLevel[50];
495         int x, y;
496
497         #if DEBUG
498         char pos[50];
499         #endif
500
501         graphics.setFontSize(0);
502         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
503         
504         int numberOfHubs = 0;
505         
506         gameData.calculateWorldCompleted();
507
508         while (true)
509         {
510                 sscanf(line, "%*c %[^\"] %*c %*c %[^\"] %*c %d %d %*c %[^\"] %*c", name, level, &x, &y, requiredLevel);
511
512                 if (strcmp(name, "@EOF@") == 0)
513                 {
514                         break;
515                 }
516                 
517                 // don't show boss levels on Easy (they might be cheating!)
518                 if (game.skill == 0)
519                 {
520                         if (strstr(name, "BioMech"))
521                         {
522                                 line = strtok(NULL, "\n");
523                                 continue;
524                         }
525                 }
526
527                 if (requirementMet(requiredLevel))
528                 {
529                         if (!gameData.levelPrefectlyCleared(name))
530                         {
531                                 hubPoint = new HubLevel;
532                                 hubPoint->set(name, level, x, y);
533                                 hubPoint->levelNameImage = graphics.getString(_(name), false);
534                                 
535                                 (!gameData.stagePreviouslyCleared(name)) ? hubPoint->target = newTarget : hubPoint->target = visitedTarget;
536                                 
537                                 hubList.add(hubPoint);
538                                 numberOfHubs++;
539                         }
540                 }
541
542                 line = strtok(NULL, "\n");
543         }
544
545         int rtn = -1;
546         
547         strncpy(level, "@none@", sizeof level);
548         strncpy(game.stageName, "@none@", sizeof game.stageName);
549
550         bool showData = false;
551         bool showStats = false;
552         bool showMIAs = false;
553         
554         int miaStart = 0;
555         int miaMax = 0;
556         int page = 0;
557         
558         int labelX, labelY;
559
560         Data *data = (Data*)gameData.dataList.getHead();
561
562         while (data->next != NULL)
563         {
564                 data = (Data*)data->next;
565
566                 if (strstr(data->value, "MIA_"))
567                 {
568                         miaMax++;
569                 }
570         }
571         
572         bool validStage = false;
573         
574         if ((numberOfHubs == 0) && (gameData.completedWorld))
575         {
576                 game.setMapName("data/spaceStation");
577                 strncpy(game.stageName, "Space Station", sizeof game.stageName);
578                 createObjectivesPanel("Space Station");
579                 showData = true;
580                 showStats = showMIAs = false;
581                 validStage = true;
582                 
583                 // Wait wait wait... we're in easy mode. Game ends here.
584                 if (game.skill == 0)
585                 {
586                         hubList.clear();
587                         return SECTION_EASYOVER;
588                 }
589                 
590                 presentPlayerMedal("World_Complete");
591         }
592         
593         audio.playMusic();
594
595         int labelWidth = 0;
596         Uint32 frameLimit = SDL_GetTicks() + 16;
597         
598         int mouseXDelta = 0;
599         int mouseYDelta = 0;
600
601         while (rtn == -1)
602         {
603                 graphics.updateScreen();
604                 graphics.drawBackground();
605                 graphics.animateSprites();
606
607                 if (validStage)
608                 {
609                         graphics.drawRect(10, 400, 620, 20, graphics.black, graphics.white, graphics.screen);
610                         snprintf(string, sizeof string, "%s : %s", _("Selected Destination"), _(game.stageName));
611                         graphics.drawString(string, 320, 409, true, graphics.screen);
612                 }
613                 
614                 graphics.drawRect(10, 430, 620, 40, graphics.black, graphics.white, graphics.screen);
615
616                 #if DEBUG
617                 snprintf(pos, sizeof pos, "%.3d:%.3d", engine.getMouseX(), engine.getMouseY());
618                 graphics.drawString(pos, 320, 15, true, graphics.screen);
619                 #endif
620
621                 engine.getInput();
622                 config.populate();
623                 
624                 if (config.isControl(CONTROL::RIGHT))
625                 {
626                         mouseXDelta = 5;
627                 }
628                 
629                 if (config.isControl(CONTROL::LEFT))
630                 {
631                         mouseXDelta = -5;
632                 }
633                 
634                 if (config.isControl(CONTROL::DOWN))
635                 {
636                         mouseYDelta = 5;
637                 }
638                 
639                 if (config.isControl(CONTROL::UP) || config.isControl(CONTROL::JUMP))
640                 {
641                         mouseYDelta = -5;
642                 }
643
644                 if ((mouseXDelta != 0) || (mouseYDelta != 0))
645                 {
646                         engine.setMouse(engine.getMouseX() + (int)mouseXDelta, engine.getMouseY() + (int)mouseYDelta);
647                         mouseXDelta = 0;
648                         mouseYDelta = 0;
649                 }
650
651                 hubPoint = (HubLevel*)hubList.getHead();
652
653                 // Collisions for Hub Points
654                 while (hubPoint->next != NULL)
655                 {
656                         hubPoint = (HubLevel*)hubPoint->next;
657
658                         graphics.blit(hubPoint->target->getCurrentFrame(), hubPoint->x, hubPoint->y, graphics.screen, false);
659
660                         if (Collision::collision(engine.getMouseX(), engine.getMouseY(), 1, 1, hubPoint->x, hubPoint->y, 16, 16))
661                         {
662                                 labelX = engine.getMouseX();
663                                 labelY = engine.getMouseY() - 20;
664
665                                 labelWidth = hubPoint->levelNameImage->w / 2;
666
667                                 Math::limitInt(&labelX, 10 + labelWidth, 630 - labelWidth);
668
669                                 graphics.blit(hubPoint->levelNameImage, labelX, labelY, graphics.screen, true);
670
671                                 if (engine.mouseLeft || config.isControl(CONTROL::FIRE))
672                                 {
673                                         game.setMapName(hubPoint->filename);
674                                         game.setStageName(hubPoint->stageName);
675                                         validStage = true;
676                                         engine.mouseLeft = 0;
677                                         config.resetControl(CONTROL::FIRE);
678                                 }
679
680                                 if (engine.mouseRight || config.isControl(CONTROL::MAP))
681                                 {
682                                         game.setMapName(hubPoint->filename);
683                                         game.setStageName(hubPoint->stageName);
684                                         createObjectivesPanel(game.stageName);
685                                         showData = true;
686                                         showStats = false;
687                                         engine.mouseRight = 0;
688                                         config.resetControl(CONTROL::MAP);
689                                 }
690                         }
691                 }
692
693                 // Collisions for Panel
694                 for (int i = ((1 - validStage) * 2) ; i < 6 ; i++)
695                 {
696                         graphics.blit(hubIcons->image[i], 50 + (i * 100), 440, graphics.screen, false);
697                         if (Collision::collision(engine.getMouseX(), engine.getMouseY(), 1, 1, 50 + (i * 100), 440, hubIcons->image[i]->w, hubIcons->image[i]->h))
698                         {
699                                 if (engine.mouseLeft || config.isControl(CONTROL::FIRE))
700                                 {
701                                         switch (i)
702                                         {
703                                                 case 0:
704                                                         rtn = SECTION_GAME;
705                                                         break;
706                                                 case 1:
707                                                         createObjectivesPanel(game.stageName);
708                                                         showData = !showData;
709                                                         showStats = showMIAs = false;
710                                                         break;
711                                                 case 2:
712                                                         createMIAPanel(miaStart, miaMax);
713                                                         showStats = showData = false;
714                                                         showMIAs = !showMIAs;
715                                                         break;
716                                                 case 3:
717                                                         createStatsPanel(page);
718                                                         showStats = !showStats;
719                                                         showData = showMIAs = false;
720                                                         break;
721                                                 case 4:
722                                                         showOptions();
723                                                         graphics.setFontSize(0);
724                                                         graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
725                                                         break;
726                                                 case 5:
727                                                         rtn = SECTION_TITLE;
728                                                         break;
729                                         }
730
731                                         engine.mouseLeft = false;
732                                         config.resetControl(CONTROL::FIRE);
733                                 }
734                         }
735                 }
736                 
737                 // Collisions for Panel Buttons
738                 if ((showMIAs) || (showStats))
739                 {
740                     // SDLK_LCTRL is the "fire" button.
741                         if (engine.mouseLeft || config.isControl(CONTROL::FIRE))
742                         {
743                                 if (Collision::collision(engine.getMouseX(), engine.getMouseY(), 1, 1, 270, 310, 32, 32))
744                                 {
745                                         if (showMIAs)
746                                         {
747                                                 if (miaStart > 0)
748                                                 {
749                                                         Math::limitInt(&(miaStart -= 9), 0, miaMax);
750                                                         createMIAPanel(miaStart, miaMax);
751                                                 }
752                                         }
753
754                                         if (showStats)
755                                         {
756                                                 Math::limitInt(&(--page), 0, 2);
757                                                 createStatsPanel(page);
758                                         }
759
760                                         engine.mouseLeft = 0;
761                                         config.resetControl(CONTROL::FIRE);
762                                 }
763
764
765                                 if (Collision::collision(engine.getMouseX(), engine.getMouseY(), 1, 1, 320, 310, 32, 32))
766                                 {
767                                         if (showMIAs)
768                                         {
769                                                 if (miaStart + 9 < miaMax)
770                                                 {
771                                                         Math::limitInt(&(miaStart += 9), 0, miaMax);
772                                                         createMIAPanel(miaStart, miaMax);
773                                                 }
774                                         }
775
776                                         if (showStats)
777                                         {
778                                                 Math::limitInt(&(++page), 0, 2);
779                                                 createStatsPanel(page);
780                                         }
781
782                                         engine.mouseLeft = 0;
783                                         config.resetControl(CONTROL::FIRE);
784                                 }
785                         }
786                 }
787
788                 if ((showData) || (showStats) || (showMIAs))
789                 {
790                         graphics.blit(infoPanel, 320, 200, graphics.screen, true);
791                         if (engine.mouseLeft || config.isControl(CONTROL::FIRE))
792                         {
793                                 showData = showStats = showMIAs = false;
794                         }
795                 }
796
797                 graphics.blit(cursor->getCurrentFrame(), engine.getMouseX(), engine.getMouseY(), graphics.screen, true);
798
799                 engine.delay(frameLimit);
800                 frameLimit = SDL_GetTicks() + 16;
801         }
802
803         hubList.clear();
804
805         return rtn;
806 }