]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Put a dark grey rectangle behind music credits to improve readability.
authorGuus Sliepen <guus@debian.org>
Sun, 4 Jul 2010 13:19:43 +0000 (15:19 +0200)
committerGuus Sliepen <guus@debian.org>
Sun, 4 Jul 2010 13:19:43 +0000 (15:19 +0200)
src/info.cpp

index 73be58dfcf3af0dffe479bf2e880d83a62b18d7e..7225629ce0fc52be0b83702569d75c6dc3413100 100644 (file)
@@ -337,32 +337,67 @@ void doMusicInfo(unsigned int ticks)
        }
 
        graphics.setFontSize(0);
-       graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
+       graphics.setFontColor(0xff, 0xff, 0xff, 0x40, 0x40, 0x40);
+
+       SDL_Surface *text;
 
        const int x = 620;
        int y = 420;
 
-       graphics.drawString(audio.songtitle, x, y, TXT_RIGHT, graphics.screen);
-       y -= 16;
+       static int w = 0;
+       static int h = 0;
+
+       if(w && h)
+               graphics.drawRect(x - w - 5, y - h - 5, w + 10, h + 10, graphics.darkGrey, graphics.screen);
+
+       w = h = 0;
+
+       text = graphics.getString(audio.songtitle, true);
+       y -= text->h;
+       h = text->h;
+       w = text->w;
+
+       graphics.blit(text, x - text->w, y, graphics.screen, false);
+       SDL_FreeSurface(text);
 
        if(audio.songalbum[0])
        {
-               graphics.setFontColor(0x80, 0xc0, 0xff, 0x00, 0x00, 0x00);
-               graphics.drawString(audio.songalbum, x, y, TXT_RIGHT, graphics.screen);
-               y -= 16;
+               graphics.setFontColor(0x80, 0xc0, 0xff, 0x40, 0x40, 0x40);
+               
+               text = graphics.getString(audio.songalbum, true);
+               y -= text->h + 4;
+               h += text->h + 4;
+               if(text->w > w)
+                       w = text->w;
+
+               graphics.blit(text, x - text->w, y, graphics.screen, false);
+               SDL_FreeSurface(text);
        }
 
        if(audio.songartist[0])
        {
-               graphics.setFontColor(0xff, 0xc0, 0x80, 0x00, 0x00, 0x00);
-               graphics.drawString(audio.songartist, x, y, TXT_RIGHT, graphics.screen);
-               y -= 16;
+               graphics.setFontColor(0xff, 0xc0, 0x80, 0x40, 0x40, 0x40);
+
+               text = graphics.getString(audio.songartist, true);
+               y -= text->h + 4;
+               h += text->h + 4;
+               if(text->w > w)
+                       w = text->w;
+
+               graphics.blit(text, x - text->w, y, graphics.screen, false);
+               SDL_FreeSurface(text);
        }
 
        if(audio.songlicense >= 0)
        {
                SDL_Surface *icon = graphics.license[audio.songlicense];
-               graphics.blit(icon, x - icon->w, y - icon->h, graphics.screen, false);
+
+               y -= icon->h + 8;
+               h += icon->h + 8;
+               if(icon->w > w)
+                       w = icon->w;
+
+               graphics.blit(icon, x - icon->w, y, graphics.screen, false);
        }
 }