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