quickSound = NULL;
levelMusicName[0] = 0;
+ songtitle[0] = 0;
+ songalbum[0] = 0;
+ songartist[0] = 0;
+ songlicense = -1;
}
void Audio::setSoundVolume(int soundVolume)
music = Mix_LoadMUS(filename);
#endif
+ songtitle[0] = 0;
+ songalbum[0] = 0;
+ songartist[0] = 0;
+ songlicense = -1;
+
if (!music)
{
debug(("WARNING - Failed to load %s\n", filename));
return false;
}
-
+
+ snprintf(tempPath, sizeof tempPath, "%s.tags", filename);
+ FILE *fp = fopen(tempPath, "r");
+ char line[1024];
+
+ while(fp && fgets(line, sizeof line, fp))
+ {
+ int l = strlen(line);
+ if(line[l - 1] == '\n')
+ line[l - 1] = 0;
+
+ if(!strncasecmp(line, "title=", 6))
+ strncpy(songtitle, line + 6, sizeof songtitle);
+ else if(!strncasecmp(line, "album=", 6))
+ strncpy(songalbum, line + 6, sizeof songalbum);
+ else if(!strncasecmp(line, "artist=", 7))
+ strncpy(songartist, line + 7, sizeof songartist);
+ else if(!strncasecmp(line, "license=", 8))
+ {
+ if(!strncasecmp(line + 8, "CC-BY ", 6))
+ songlicense = 0;
+ else if(!strncasecmp(line + 8, "CC-BY-SA ", 9))
+ songlicense = 1;
+ }
+ }
+
+ fprintf(stderr, "%s\n%s\n\"%s\"\n%d\n", songartist, songalbum, songtitle, songlicense);
+
+ if(fp)
+ fclose(fp);
+
strncpy(levelMusicName, filename, sizeof levelMusicName);
return true;
Mix_Music *music;
public:
+ char songtitle[128];
+ char songalbum[128];
+ char songartist[128];
+ int songlicense;
int output;
bool useSound, useMusic;
}
}
-SDL_Surface *Graphics::loadImage(const char *filename)
+SDL_Surface *Graphics::loadImage(const char *filename, bool srcalpha)
{
SDL_Surface *image, *newImage;
newImage = image;
}
- setTransparent(newImage);
+ if(srcalpha)
+ SDL_SetAlpha(newImage, SDL_SRCALPHA, 255);
+ else
+ setTransparent(newImage);
return newImage;
}
SDL_Surface *tile[MAX_TILES];
SDL_Surface *medal[4];
+ SDL_Surface *license[2];
SDL_Surface *infoBar;
void delay(int time);
void RGBtoHSV(float r, float g, float b, float *h, float *s, float *v);
void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v);
- SDL_Surface *loadImage(const char *filename);
+ SDL_Surface *loadImage(const char *filename, bool srcalpha = false);
SDL_Surface *loadImage(const char *filename, int hue, int sat, int value);
SDL_Surface *quickSprite(const char *name, SDL_Surface *image);
void fade(int amount);
graphics.delay(1000);
Uint32 then, frames, frameLimit, millis, frameCounter;
+ Uint32 start, cur;
#if DEBUG
Uint32 now;
frameLimit = SDL_GetTicks() + 16;
frames = millis = 0;
- then = SDL_GetTicks();
+ start = then = SDL_GetTicks();
frameCounter = SDL_GetTicks();
if ((strcmp(map.name, "Space Station") == 0) && (!game.continueFromCheckPoint))
{
++frames;
++millis;
+ cur = SDL_GetTicks();
if (game.missionOverReason != MIS_PLAYEROUT)
{
drawMapTopLayer();
doStatusBar();
+ doMusicInfo(cur - start);
if ((engine.keyState[SDLK_ESCAPE]) && (game.missionOver == 0))
{
extern void doTimeRemaining();
extern void doStatusBar();
+extern void doMusicInfo(unsigned int);
extern void doPauseInfo();
extern void doItems();
snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
graphics.drawString(string, 320, 430, TXT_CENTERED, graphics.screen);
}
+
+void doMusicInfo(unsigned int ticks)
+{
+ if(!audio.songtitle[0])
+ return;
+
+ if(ticks != (unsigned int)-1) {
+ if(ticks > 12000 || ticks < 5000)
+ return;
+
+ unsigned int r = rand() & 0x3ff;
+
+ if(ticks - 5000 < r || 12000 - ticks < r)
+ return;
+ }
+
+ graphics.setFontSize(0);
+ graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
+
+ const int x = 620;
+ int y = 420;
+
+ graphics.drawString(audio.songtitle, x, y, TXT_RIGHT, graphics.screen);
+ y -= 16;
+
+ if(audio.songalbum[0])
+ {
+ graphics.setFontColor(0x80, 0xc0, 0xff, 0x00, 0x00, 0x00);
+ graphics.drawString(audio.songalbum, x, y, TXT_RIGHT, graphics.screen);
+ y -= 16;
+ }
+
+ if(audio.songartist[0])
+ {
+ graphics.setFontColor(0xff, 0xc0, 0x80, 0x00, 0x00, 0x00);
+ graphics.drawString(audio.songartist, x, y, TXT_RIGHT, graphics.screen);
+ y -= 16;
+ }
+
+ if(audio.songlicense >= 0)
+ {
+ SDL_Surface *icon = graphics.license[audio.songlicense];
+ graphics.blit(icon, x - icon->w, y - icon->h, graphics.screen, false);
+ }
+}
+
graphics.medal[2] = graphics.loadImage("gfx/main/shield.png");
graphics.medal[3] = graphics.loadImage("gfx/main/ruby.png");
+ graphics.license[0] = graphics.loadImage("gfx/main/cc-by.png", true);
+ graphics.license[1] = graphics.loadImage("gfx/main/cc-by-sa.png", true);
+
SDL_Surface *device = graphics.loadImage("gfx/main/alienDevice.png");
#ifndef SDL_FRAMEWORK
else if (strcmp(argv[i], "-playback") == 0) {recordMode = REPLAY_MODE::PLAYBACK; strncpy(replayData.filename, argv[++i], sizeof replayData.filename);}
else if (strcmp(argv[i], "-map") == 0) {game.setMapName(argv[++i]); requiredSection = SECTION_GAME;}
else if (strcmp(argv[i], "-listmaps") == 0) listMaps();
+ else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS;
#if DEBUG
else if (strcmp(argv[i], "-showsprites") == 0) showSprites = true;
else if (strcmp(argv[i], "-hub") == 0) hub = true;
else if (strcmp(argv[i], "-randomscreens") == 0) graphics.takeRandomScreenShots = true;
else if (strcmp(argv[i], "-nomonsters") == 0) engine.devNoMonsters = true;
- else if (strcmp(argv[i], "-credits") == 0) requiredSection = SECTION_CREDITS;
#endif
}
engine.flushInput();
engine.clearInput();
+ doMusicInfo(-1);
+
while (true)
{
engine.getInput();
extern void initMIAPhrases();
extern void addWindParticles();
extern void getMapTokens();
+extern void doMusicInfo(unsigned int);
extern Audio audio;
extern Config config;