X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2Ftitle.cpp;h=7b5e05028726094f4963c5a03223bb0d11af9f56;hb=ba027fd5579c333f6ff7049995f712c1237e9e07;hp=777b1427e16699e38f6571ffbbe7ecff842e2054;hpb=a882955f339b23b5e61f92ef7cb5aae76405d95b;p=quix0rs-blobwars.git diff --git a/src/title.cpp b/src/title.cpp index 777b142..7b5e050 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -1,5 +1,5 @@ /* -Copyright (C) 2004 Parallel Realities +Copyright (C) 2004-2011 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "title.h" +extern void doMusicInfo(unsigned int); + /** * Displays the skill level widgets and hide the others */ @@ -111,20 +113,20 @@ void showTitleWidgets() void setupSaveWidgets() { char widgetName[10]; - strcpy(widgetName, ""); + widgetName[0] = 0; for (int i = 0 ; i < 5 ; i++) { - sprintf(widgetName, "save%d", i + 1); - strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]); + snprintf(widgetName, sizeof widgetName, "save%d", i + 1); + strlcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label); if ((strstr(engine.saveSlot[i], _("Empty"))) || (strstr(engine.saveSlot[i], _("Corrupt")))) { engine.enableWidget(widgetName, false); } - sprintf(widgetName, "slot%d", i + 1); - strcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i]); + snprintf(widgetName, sizeof widgetName, "slot%d", i + 1); + strlcpy(engine.getWidgetByName(widgetName)->label, engine.saveSlot[i], sizeof engine.getWidgetByName(widgetName)->label); } } @@ -143,7 +145,7 @@ void loadTitleWidgets() setupSaveWidgets(); Widget *widget = engine.getWidgetByName("labelManual"); - strcpy(widget->label, GAMEPLAYMANUAL); + strlcpy(widget->label, GAMEPLAYMANUAL, sizeof widget->label); showTitleWidgets(); } @@ -187,20 +189,20 @@ int title() SDL_Surface *subTitle = graphics.quickSprite("SubTitle", graphics.getString(_("Blob Wars : Episode I"), true)); graphics.setFontSize(0); - SDL_Surface *copyright = graphics.quickSprite("Copyright", graphics.getString(_("Copyright (C) 2004, 2005 Parallel Realities"), true)); + SDL_Surface *copyright = graphics.quickSprite("Copyright", graphics.getString(_("Copyright (C) 2004-2011 Parallel Realities"), true)); char v[50]; #define STRINGIFY_VALUE(x) STRINGIFY(x) #define STRINGIFY(x) #x - sprintf(v, _("Version %s"), STRINGIFY_VALUE(VERSION)); + snprintf(v, sizeof v, _("Version %s"), STRINGIFY_VALUE(VERSION)); SDL_Surface *version = graphics.quickSprite("Version", graphics.getString(v, true)); - SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, 0); + SDL_SetSurfaceAlphaMod(title, 0); - audio.loadMusic("music/helmet-shake.mod"); + audio.loadMusic("music/title"); graphics.loadBackground("gfx/main/CircuitBoard.jpg"); - SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, 0); + SDL_SetSurfaceAlphaMod(graphics.background, 0); int startNewGame, options, quit, help, easy, normal, hard, extreme, back, practice; int load, cont, save[5], slot[6]; @@ -266,8 +268,8 @@ int title() engine.clearInput(); backAlpha = 255; titleAlpha = 255; - SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, (int)backAlpha); - SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, (int)titleAlpha); + SDL_SetSurfaceAlphaMod(graphics.background, backAlpha); + SDL_SetSurfaceAlphaMod(title, titleAlpha); } } @@ -276,7 +278,7 @@ int title() if (backAlpha < 255) { backAlpha++; - SDL_SetAlpha(graphics.background, SDL_SRCALPHA|SDL_RLEACCEL, (int)backAlpha); + SDL_SetSurfaceAlphaMod(graphics.background, backAlpha); } } @@ -285,7 +287,7 @@ int title() if (titleAlpha < 255) { titleAlpha++; - SDL_SetAlpha(title, SDL_SRCALPHA|SDL_RLEACCEL, (int)titleAlpha); + SDL_SetSurfaceAlphaMod(title, titleAlpha); } else { @@ -294,6 +296,8 @@ int title() graphics.blit(version, (630 - version->w), 460, graphics.screen, false); allFadedOn = true; } + + doMusicInfo(SDL_GetTicks() - (now + 39000)); } Math::wrapFloat(&(offX -= 0.25), -graphics.background->w, 0); @@ -385,7 +389,7 @@ int title() if (save[3]) {load = 4; break;} if (save[4]) {load = 5; break;} - if (engine.keyState[SDLK_ESCAPE]) + if (engine.keyState[SDL_SCANCODE_ESCAPE]) { audio.playMenuSound(2); back = 1; @@ -416,10 +420,7 @@ int title() if (quit) { - if (engine.useAudio) - { - SDL_Delay(1000); - } + doQuit(); exit(0); } @@ -512,10 +513,11 @@ void doCredits() SDL_Surface *device = graphics.quickSprite("credit", graphics.loadImage("gfx/main/creditsDevice.png")); float deviceY = y[numberOfCredits - 7] - 50; - audio.loadMusic("music/autumnsDawning.s3m"); + audio.loadMusic("music/credits"); audio.playMusic(); engine.resetTimeDifference(); + Uint32 now = SDL_GetTicks(); while (y[numberOfCredits - 1] > 350) { @@ -548,6 +550,8 @@ void doCredits() graphics.drawRect(0, 0, 640, 30, graphics.black, graphics.screen); } + doMusicInfo(SDL_GetTicks() - (now + 10000)); + SDL_Delay(16); } @@ -558,3 +562,33 @@ void doCredits() delete[] y; delete[] credit; } + +/** +* Shows the exit screen, mentioning the sequel and the book by Stephen Sweeney +*/ +void doQuit() +{ + SDL_FillRect(graphics.screen, NULL, graphics.black); + SDL_Surface *sequel = graphics.loadImage("gfx/main/sequel.png"); + SDL_Surface *book = graphics.loadImage("gfx/main/book.png"); + + graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00); + graphics.setFontSize(1); + graphics.drawString(_("If you like Blob Wars: Metal Blob Solid, you might also like:"), 320, 20, true, graphics.screen); + graphics.blit(sequel, 160, 200, graphics.screen, true); + graphics.blit(book, 480, 200, graphics.screen, true); + graphics.setFontSize(0); + graphics.drawString("http://blobandconquer.sf.net", 160, 380, true, graphics.screen); + graphics.drawString("http://www.battleforthesolarsystem.com", 480, 380, true, graphics.screen); + graphics.setFontSize(3); + graphics.drawString(_("Thank you for playing Blob Wars!"), 320, 430, true, graphics.screen); + graphics.setFontSize(0); + graphics.drawString(_("Press Space to Exit."), 320, 460, true, graphics.screen); + + graphics.updateScreen(); + + do { + SDL_Delay(16); + engine.getInput(); + } while(!engine.userAccepts()); +}