]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/title.cpp
Cache text surfaces.
[quix0rs-blobwars.git] / src / title.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 777b142..b022cdb
@@ -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);
+               strncpy(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);
+               strncpy(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);
+       strncpy(widget->label, GAMEPLAYMANUAL, sizeof widget->label);
 
        showTitleWidgets();
 }
@@ -192,12 +194,12 @@ int title()
        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);
 
-       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);
@@ -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);
@@ -512,10 +516,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 +553,8 @@ void doCredits()
                        graphics.drawRect(0, 0, 640, 30, graphics.black, graphics.screen);
                }
 
+               doMusicInfo(SDL_GetTicks() - (now + 10000));
+
                SDL_Delay(16);
        }