/*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
void doStatusBar()
{
+ static Graphics::SurfaceCache healthCache;
+ static Graphics::SurfaceCache oxygenCache;
+ static Graphics::SurfaceCache jetpackCache;
+
graphics.setFontSize(0);
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
graphics.blit(graphics.infoBar, 0, 0, graphics.screen, false);
- graphics.drawString(_("Health"), 50, 5, TXT_RIGHT, graphics.screen);
+ graphics.drawString(_("Health"), 50, 5, TXT_RIGHT, graphics.screen, healthCache);
for (int i = 0 ; i < MAX_HEALTH ; i++)
{
if ((!game.hasAquaLung) && (!engine.cheatExtras))
{
- graphics.drawString(_("Oxygen"), 305, 5, TXT_RIGHT, graphics.screen);
+ graphics.drawString(_("Oxygen"), 305, 5, TXT_RIGHT, graphics.screen, oxygenCache);
for (int i = 0 ; i < 7 ; i++)
{
}
else if ((game.hasJetPack) || (engine.cheatExtras))
{
- graphics.drawString(_("Jetpack"), 305, 5, TXT_RIGHT, graphics.screen);
+ graphics.drawString(_("Jetpack"), 305, 5, TXT_RIGHT, graphics.screen, jetpackCache);
for (int i = 0 ; i < 7 ; i++)
{
break;
}
+ static Graphics::SurfaceCache cache;
graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
- graphics.drawString(_(engine.message), 320, 466, true, graphics.screen);
+ graphics.drawString(_(engine.message), 320, 466, true, graphics.screen, cache);
engine.messageTime--;
if (engine.messageTime == -1)
{
engine.messagePriority = -1;
- strcpy(engine.message, "");
+ engine.message[0] = 0;
}
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
{
graphics.blit(graphics.infoBar, 0, 455, graphics.screen, false);
- graphics.drawString(_(map.mainBossPart->name), 255, 460, TXT_RIGHT, graphics.screen);
+ static Graphics::SurfaceCache cache;
+ graphics.drawString(_(map.mainBossPart->name), 255, 460, TXT_RIGHT, graphics.screen, cache);
graphics.drawRect(265 - 1, 463 - 1, 200 + 2, 10 + 2, graphics.white, graphics.screen);
graphics.drawRect(265, 463, 200, 10, graphics.black, graphics.screen);
}
}
- sprintf(string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
- graphics.drawString(string, 630, 5, TXT_RIGHT, graphics.screen);
+ static Graphics::SurfaceCache weaponCache;
+ snprintf(string, sizeof string, "%s %s", _("Weapon:"), _(player.currentWeapon->name));
+ graphics.drawString(string, 630, 5, TXT_RIGHT, graphics.screen, weaponCache);
if (game.skill == 3)
{
- sprintf(string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
+ snprintf(string, sizeof string, _("Time Remaining: %.2d:%.2d"), map.remainingMinutes, map.remainingSeconds);
graphics.blit(graphics.infoBar, 0, 25, graphics.screen, false);
if ((map.remainingMinutes > 0) || (map.remainingSeconds > 0))
}
}
}
- graphics.drawString(string, 320, 35, TXT_CENTERED, graphics.screen);
+ static Graphics::SurfaceCache cache;
+ graphics.drawString(string, 320, 35, TXT_CENTERED, graphics.screen, cache);
}
else
{
+ static Graphics::SurfaceCache cache;
graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
graphics.setFontSize(3);
- graphics.drawString(_("Mission Failed! Time Up!"), 320, 220, TXT_CENTERED, graphics.screen);
+ graphics.drawString(_("Mission Failed! Time Up!"), 320, 220, TXT_CENTERED, graphics.screen, cache);
graphics.setFontSize(0);
game.canContinue = 0;
}
graphics.fade(130);
char string[1024];
- strcpy(string, "");
+ string[0] = 0;
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
- //#if !USEPAK
- sprintf(string, _("Position = %d:%d"), (int)player.x, (int)player.y);
+ #if DEBUG
+ snprintf(string, sizeof string, _("Position = %d:%d"), (int)player.x, (int)player.y);
graphics.drawString(string, 5, 25, false, graphics.screen);
- //#endif
+ #endif
graphics.drawString(_("*** PAUSED ***"), 320, y, TXT_CENTERED, graphics.screen);
graphics.drawString(_("MIAs in Area"), col1, y += 30, TXT_RIGHT, graphics.screen);
- sprintf(string, "%d", map.totalMIAs - map.foundMIAs);
+ snprintf(string, sizeof string, "%d", map.totalMIAs - map.foundMIAs);
graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
graphics.drawString(_("Enemies Defeated"), col1, y += 20, TXT_RIGHT, graphics.screen);
- sprintf(string, "%d", game.currentMissionEnemiesDefeated);
+ snprintf(string, sizeof string, "%d", game.currentMissionEnemiesDefeated);
graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
graphics.drawString(_("Items Collected"), col1, y += 20, TXT_RIGHT, graphics.screen);
- sprintf(string, "%d / %d", map.foundItems, map.totalItems);
+ snprintf(string, sizeof string, "%d / %d", map.foundItems, map.totalItems);
graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
graphics.drawString(_("Best Combo"), col1, y += 20, TXT_RIGHT, graphics.screen);
- sprintf(string, _("%d Hits"), game.maxComboHits);
+ snprintf(string, sizeof string, _("%d Hits"), game.maxComboHits);
graphics.drawString(string, col2, y, TXT_LEFT, graphics.screen);
graphics.drawString(_("++ Inventory ++"), 320, y += 40, TXT_CENTERED, graphics.screen);
// Do the objectives list
Objective *objective = (Objective*)map.objectiveList.getHead();
- char message[100];
+ char message[256];
y += 60;
if (map.totalMIAs > 0)
{
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
- sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
+ snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
graphics.drawString(message, col1, y, TXT_RIGHT, graphics.screen);
if (map.foundMIAs < map.requiredMIAs)
{
graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
- sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
+ snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
}
else
}
else
{
- sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
+ snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
graphics.drawString(message, col2, y, TXT_LEFT, graphics.screen);
}
graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
- y += 10;
-
- sprintf(string, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
+ 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);
}
+
+SDL_Surface *createMusicInfo(void)
+{
+ graphics.setFontSize(0);
+ graphics.setFontColor(0xff, 0xff, 0xff, 0x40, 0x40, 0x40);
+
+ SDL_Surface *text1;
+ SDL_Surface *text2 = NULL;
+ SDL_Surface *text3 = NULL;
+ SDL_Surface *icon = NULL;
+ SDL_Surface *panel;
+
+ int w = 0;
+ int h = 0;
+
+ text1 = graphics.getString(audio.songtitle, true);
+ h = text1->h;
+ w = text1->w;
+
+ if(audio.songalbum[0])
+ {
+ graphics.setFontColor(0x80, 0xc0, 0xff, 0x40, 0x40, 0x40);
+
+ text2 = graphics.getString(audio.songalbum, true);
+ h += text2->h + 4;
+ if(text2->w > w)
+ w = text2->w;
+
+ }
+
+ if(audio.songartist[0])
+ {
+ graphics.setFontColor(0xff, 0xc0, 0x80, 0x40, 0x40, 0x40);
+
+ text3 = graphics.getString(audio.songartist, true);
+ h += text3->h + 4;
+ if(text3->w > w)
+ w = text3->w;
+ }
+
+ if(audio.songlicense >= 0)
+ {
+ icon = graphics.license[audio.songlicense];
+
+ h += icon->h + 8;
+ if(icon->w > w)
+ w = icon->w;
+ }
+
+ int y = h + 5;
+ int x = w + 5;
+
+ panel = graphics.createSurface(w + 10, h + 10);
+ SDL_FillRect(panel, NULL, SDL_MapRGBA(panel->format, 0, 0, 0, 128));
+
+ if (text1) {
+ y -= text1->h;
+ graphics.blit(text1, x - text1->w, y, panel, false);
+ SDL_FreeSurface(text1);
+ }
+
+ if (text2) {
+ y -= text2->h + 4;
+ graphics.blit(text2, x - text2->w, y, panel, false);
+ SDL_FreeSurface(text2);
+ }
+
+ if (text3) {
+ y -= text3->h + 4;
+ graphics.blit(text3, x - text3->w, y, panel, false);
+ SDL_FreeSurface(text3);
+ }
+
+ if (icon) {
+ y -= icon->h + 8;
+ graphics.blit(icon, x - icon->w, y, panel, false);
+ }
+
+ return panel;
+}
+
+void doMusicInfo(unsigned int ticks)
+{
+ if(!audio.songtitle[0])
+ return;
+
+ static SDL_Surface *panel;
+ float alpha = 1;
+
+ if (ticks != -1U)
+ {
+ if (ticks > 12000 || ticks < 5000)
+ {
+ if (panel)
+ {
+ SDL_FreeSurface(panel);
+ panel = NULL;
+ }
+
+ return;
+ }
+
+ if(ticks < 6000)
+ alpha = 1 - (6000 - ticks) / 1000.0f;
+ else if(ticks > 11000)
+ alpha = (12000 - ticks) / 1000.0f;
+ }
+
+ if (alpha > 0.99)
+ alpha = 0.99;
+
+ if (!panel)
+ panel = createMusicInfo();
+ if (!panel)
+ return;
+
+ SDL_SetAlpha(panel, 255 * alpha);
+ graphics.blit(panel, 620 - panel->w, 420 - panel->h, graphics.screen, false);
+}