/*
-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
engine.getInput();
config.populate();
- if ((config.isControl(CONTROL::PAUSE)) || (engine.keyState[SDLK_ESCAPE]))
+ if ((config.isControl(CONTROL::PAUSE)) || (engine.keyState[SDL_SCANCODE_ESCAPE]))
{
- engine.keyState[SDLK_ESCAPE] = 0;
+ engine.keyState[SDL_SCANCODE_ESCAPE] = 0;
config.resetControl(CONTROL::PAUSE);
break;
}
doParticles();
- if ((SDL_GetAppState() & SDL_APPINPUTFOCUS) == 0)
- {
- engine.paused = true;
- }
-
replayData.set(config.command);
replayData.commit();
}
}
SDL_Surface *gameover = graphics.quickSprite("Game Over", graphics.loadImage("gfx/main/gameover.png"));
+ graphics.setTransparent(gameover);
audio.loadGameOverMusic();
audio.playMusic();
if (game.canContinue > 1)
{
Widget *widget = engine.getWidgetByName("gameOverNo");
- sprintf(widget->label, "%s (%d)", widget->label, game.canContinue);
+ char postfix[100];
+ snprintf(postfix, sizeof postfix, " (%d)", game.canContinue);
+ strlcat(widget->label, postfix, sizeof widget->label);
}
while (true)
SDL_Surface *panel = graphics.createSurface(400, 300);
SDL_Surface *panelBack = graphics.alphaRect(400, 300, 0x00, 0x00, 0x00);
- SDL_SetColorKey(panel, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(panel->format, 0, 0, 0));
+ SDL_SetColorKey(panel, SDL_RLEACCEL, SDL_MapRGB(panel->format, 0, 0, 0));
graphics.drawRect(1, 1, 398, 298, graphics.black, graphics.white, panelBack);
- char message[100];
+ char message[256];
int col1 = 25;
int col2 = 375;
int y = 30;
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_LEFT, panel);
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_RIGHT, panel);
}
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_RIGHT, panel);
}
}
if (game.skill == 3)
{
graphics.setFontColor(0xff, 0xff, 0x00, 0x00, 0x00, 0x00);
- sprintf(message, _("Time Limit - %d:%.2d Minutes"), map.remainingMinutes, map.remainingSeconds);
+ snprintf(message, sizeof message, _("Time Limit - %d:%.2d Minutes"), map.remainingMinutes, map.remainingSeconds);
graphics.drawString(message, 200, 260, TXT_CENTERED, panel);
}
SDL_FillRect(graphics.screen, NULL, graphics.black);
graphics.delay(1000);
- Uint32 then, frames, frameLimit, millis, frameCounter;
+ Uint32 then, frames, frameLimit, millis;
+ Uint32 start, cur;
#if DEBUG
- Uint32 now;
+ Uint32 now, frameCounter;
char fps[10];
- strcpy(fps, "fps");
+ strlcpy(fps, "fps", sizeof fps);
#endif
engine.messageTime = -1;
frameLimit = SDL_GetTicks() + 16;
frames = millis = 0;
- then = SDL_GetTicks();
+ start = then = SDL_GetTicks();
+#ifdef DEBUG
frameCounter = SDL_GetTicks();
+#endif
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))
+ if ((engine.keyState[SDL_SCANCODE_ESCAPE]) && (game.missionOver == 0))
{
if (replayData.replayMode == REPLAY_MODE::NONE)
{
SDL_Delay(16);
}
- if ((engine.keyState[SDLK_F3]) && (engine.cheatSkipLevel))
+ if ((engine.keyState[SDL_SCANCODE_F3]) && (engine.cheatSkipLevel))
{
autoCompleteAllObjectives(true);
+ engine.keyState[SDL_SCANCODE_F3] = 0;
engine.setInfoMessage("Skipping Mission...", 2, INFO_OBJECTIVE);
}
#if DEBUG
- if (engine.keyState[SDLK_F1])
+ if (engine.keyState[SDL_SCANCODE_F1])
{
autoCompleteAllObjectives(false);
}
engine.delay(frameLimit);
}
- if (engine.keyState[SDLK_F5])
+ if (engine.keyState[SDL_SCANCODE_F5])
{
replayData.fast = !replayData.fast;
- engine.keyState[SDLK_F5] = 0;
+ engine.keyState[SDL_SCANCODE_F5] = 0;
}
frameLimit = SDL_GetTicks() + 16;
frameLimit = SDL_GetTicks() + 64;
#if DEBUG
- graphics.drawString(fps, 600, 30, true, graphics.screen);
+ static Graphics::SurfaceCache fpsCache;
+ graphics.drawString(fps, 600, 30, true, graphics.screen, fpsCache);
if (SDL_GetTicks() > frameCounter + 500)
{
now = SDL_GetTicks();
- sprintf(fps, "%2.2f fps", ((double)frames*1000)/(now - then));
+ snprintf(fps, sizeof fps, "%2.2f fps", ((double)frames*1000)/(now - then));
then = frameCounter = SDL_GetTicks();
frames = 0;
}
if (strcmp(map.name, "Space Station"))
{
graphics.delay(1000);
- audio.loadMusic("music/commando.xm");
+ audio.loadMusic("music/grasslands");
audio.playMusic();
graphics.fadeToBlack();