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