aboutsummaryrefslogtreecommitdiff
path: root/engines/lure/game.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2007-08-12 11:15:06 +0000
committerPaul Gilbert2007-08-12 11:15:06 +0000
commit81fa23f0918d239ae25064d8a71e46bdb564526c (patch)
tree651ecea1753613239c021c1e57685af3633952e2 /engines/lure/game.cpp
parent48499f3a5243d4f5513145d569473f61ef1227de (diff)
downloadscummvm-rg350-81fa23f0918d239ae25064d8a71e46bdb564526c.tar.gz
scummvm-rg350-81fa23f0918d239ae25064d8a71e46bdb564526c.tar.bz2
scummvm-rg350-81fa23f0918d239ae25064d8a71e46bdb564526c.zip
Skeleton code added for restart/restore screen
svn-id: r28548
Diffstat (limited to 'engines/lure/game.cpp')
-rw-r--r--engines/lure/game.cpp88
1 files changed, 64 insertions, 24 deletions
diff --git a/engines/lure/game.cpp b/engines/lure/game.cpp
index 5bffc6ade8..091cfbfe0a 100644
--- a/engines/lure/game.cpp
+++ b/engines/lure/game.cpp
@@ -24,12 +24,13 @@
*/
#include "lure/game.h"
-#include "lure/strings.h"
-#include "lure/room.h"
-#include "lure/scripts.h"
-#include "lure/res_struct.h"
#include "lure/animseq.h"
#include "lure/fights.h"
+#include "lure/res_struct.h"
+#include "lure/room.h"
+#include "lure/scripts.h"
+#include "lure/sound.h"
+#include "lure/strings.h"
#include "common/config-manager.h"
@@ -45,6 +46,7 @@ Game::Game() {
int_game = this;
_debugger = new Debugger();
_slowSpeedFlag = true;
+ _preloadFlag = true;
_soundFlag = true;
}
@@ -52,7 +54,7 @@ Game::~Game() {
delete _debugger;
}
-void Game::tick(bool fastSpeed) {
+void Game::tick() {
// Call the tick method for each hotspot - this is somewaht complicated
// by the fact that a tick proc can unload both itself and/or others,
// so we first get a list of the Ids, and call the tick proc for each
@@ -66,7 +68,7 @@ void Game::tick(bool fastSpeed) {
for (i = res.activeHotspots().begin(); i != res.activeHotspots().end(); ++i) {
Hotspot *hotspot = *i;
- if (!fastSpeed || ((hotspot->layer() != 0xff) &&
+ if (!_preloadFlag || ((hotspot->layer() != 0xff) &&
(hotspot->hotspotId() < FIRST_NONCHARACTER_ID)))
// Add hotspot to list to execute
idList[idSize++] = hotspot->hotspotId();
@@ -85,6 +87,21 @@ void Game::tick(bool fastSpeed) {
delete[] idList;
}
+void Game::tickCheck() {
+ Resources &res = Resources::getReference();
+ Room &room = Room::getReference();
+ bool remoteFlag = res.fieldList().getField(OLD_ROOM_NUMBER) != 0;
+
+ _state |= GS_TICK;
+ if ((room.roomNumber() == ROOMNUM_VILLAGE_SHOP) && !remoteFlag && ((_state & GS_TICK) != 0)) {
+ // In the village shop,
+ bool tockFlag = (_state & GS_TOCK) != 0;
+ Sound.addSound(tockFlag ? 16 : 50);
+
+ _state = _state ^ (GS_TICK | GS_TOCK);
+ }
+}
+
void Game::nextFrame() {
Resources &res = Resources::getReference();
Room &room = Room::getReference();
@@ -110,31 +127,41 @@ void Game::execute() {
ValueTableData &fields = res.fieldList();
uint32 timerVal = system.getMillis();
+ uint32 timerVal2 = system.getMillis();
screen.empty();
//_screen.resetPalette();
screen.setPaletteEmpty();
- setState(0);
+ while (!events.quitFlag) {
+ setState(0);
+ Script::execute(STARTUP_SCRIPT);
- Script::execute(STARTUP_SCRIPT);
+ int bootParam = ConfMan.getInt("boot_param");
+ handleBootParam(bootParam);
- int bootParam = ConfMan.getInt("boot_param");
- handleBootParam(bootParam);
+ // Set the player direction
+ res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
- // Set the player direction
- res.getActiveHotspot(PLAYER_ID)->setDirection(UP);
+ room.update();
+ mouse.setCursorNum(CURSOR_ARROW);
+ mouse.cursorOn();
+if (bootParam == 1) _state = GS_RESTORE_RESTART; //******DEBUG******
- room.update();
- mouse.setCursorNum(CURSOR_ARROW);
- mouse.cursorOn();
-
- while (!events.quitFlag) {
- while (!events.quitFlag && (_state == 0)) {
+ // Main game loop
+ while (!events.quitFlag && ((_state & GS_RESTART) == 0)) {
// If time for next frame, allow everything to update
if (system.getMillis() > timerVal + GAME_FRAME_DELAY) {
timerVal = system.getMillis();
nextFrame();
+
+ Sound.musicInterface_ContinuePlaying();
+ }
+
+ // Also check if time to do another village shop tick check
+ if (system.getMillis() > timerVal2 + GAME_TICK_DELAY) {
+ timerVal2 = system.getMillis();
+ tickCheck();
}
res.delayList().tick();
@@ -232,24 +259,35 @@ void Game::execute() {
_debugger->onFrame();
}
+ room.leaveRoom();
+ screen.paletteFadeOut();
+
// If Skorl catches player, show the catching animation
if ((_state & GS_CAUGHT) != 0) {
Palette palette(SKORL_CATCH_PALETTE_ID);
AnimationSequence *anim = new AnimationSequence(screen, system,
SKORL_CATCH_ANIM_ID, palette, false);
mouse.cursorOff();
+ Sound.addSound(0x33);
anim->show();
mouse.cursorOn();
}
// If the Restart/Restore dialog is needed, show it
- if ((_state & GS_RESTORE_RESTART) != 0) {
- // TODO: Restore/Restart dialog - for now, simply flag for exit
+ if ((_state & GS_RESTORE) != 0) {
+ // Show the Restore/Restart dialog
+ bool restartFlag = RestartRestoreDialog::show();
+
+ setState(0);
+
+ if (restartFlag) {
+ res.reloadData();
+ Script::execute(STARTUP_SCRIPT);
+ }
+ } else if ((_state & GS_RESTART) == 0)
+ // Exiting game
events.quitFlag = true;
- }
}
-
- room.leaveRoom();
}
void Game::handleMenuResponse(uint8 selection) {
@@ -296,6 +334,8 @@ void Game::playerChangeRoom() {
delayList.clear();
+ Sound.removeSounds();
+
RoomData *roomData = res.getRoom(roomNum);
assert(roomData);
roomData->flags |= HOTSPOTFLAG_FOUND;
@@ -361,7 +401,7 @@ void Game::displayChuteAnimation()
delete anim;
mouse.cursorOn();
- fields.setField(82, 1);
+ fields.setField(AREA_FLAG, 1);
}
void Game::displayBarrelAnimation()