[Scummvm-cvs-logs] SF.net SVN: scummvm: [28548] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Aug 12 13:15:06 CEST 2007


Revision: 28548
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28548&view=rev
Author:   dreammaster
Date:     2007-08-12 04:15:06 -0700 (Sun, 12 Aug 2007)

Log Message:
-----------
Skeleton code added for restart/restore screen

Modified Paths:
--------------
    scummvm/trunk/engines/lure/game.cpp
    scummvm/trunk/engines/lure/game.h
    scummvm/trunk/engines/lure/lure.h

Modified: scummvm/trunk/engines/lure/game.cpp
===================================================================
--- scummvm/trunk/engines/lure/game.cpp	2007-08-12 11:14:23 UTC (rev 28547)
+++ scummvm/trunk/engines/lure/game.cpp	2007-08-12 11:15:06 UTC (rev 28548)
@@ -24,12 +24,13 @@
  */
 
 #include "lure/game.h"
-#include "lure/strings.h"
+#include "lure/animseq.h"
+#include "lure/fights.h"
+#include "lure/res_struct.h"
 #include "lure/room.h"
 #include "lure/scripts.h"
-#include "lure/res_struct.h"
-#include "lure/animseq.h"
-#include "lure/fights.h"
+#include "lure/sound.h"
+#include "lure/strings.h"
 
 #include "common/config-manager.h"
 
@@ -45,6 +46,7 @@
 	int_game = this;
 	_debugger = new Debugger();
 	_slowSpeedFlag = true;
+	_preloadFlag = true;
 	_soundFlag = true;
 }
 
@@ -52,7 +54,7 @@
 	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 @@
 	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 @@
 	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,33 +127,43 @@
 	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();
 
 			while (events.pollEvent()) {
@@ -232,24 +259,35 @@
 				_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 @@
 
 	delayList.clear();
 
+	Sound.removeSounds();
+
 	RoomData *roomData = res.getRoom(roomNum);
 	assert(roomData);
 	roomData->flags |= HOTSPOTFLAG_FOUND;
@@ -361,7 +401,7 @@
 	delete anim;
 
 	mouse.cursorOn();
-	fields.setField(82, 1);
+	fields.setField(AREA_FLAG, 1);
 }
 
 void Game::displayBarrelAnimation()

Modified: scummvm/trunk/engines/lure/game.h
===================================================================
--- scummvm/trunk/engines/lure/game.h	2007-08-12 11:14:23 UTC (rev 28547)
+++ scummvm/trunk/engines/lure/game.h	2007-08-12 11:15:06 UTC (rev 28548)
@@ -39,7 +39,9 @@
 
 namespace Lure {
 
-enum GameState {GS_RESTORE_RESTART = 1, GS_CAUGHT = 2, GS_EXIT = 3};
+enum GameState {GS_ERROR = 1, GS_TICK = 2, GS_TOCK = 4, GS_PROT = 8, GS_RESTART = 0x10,
+	GS_CAUGHT = 0x20, GS_RESTORE = 0x40, GS_FLOPPY = 0x80,
+	GS_RESTORE_RESTART = 0x50};
 
 class Game {
 private:
@@ -48,6 +50,7 @@
 	uint8 _state;
 	uint16 _tellCommands[MAX_TELL_COMMANDS * 3 + 1];
 	int _numTellCommands;
+	bool _preloadFlag;
 
 	void handleMenuResponse(uint8 selection);
 	void handleClick();
@@ -60,16 +63,19 @@
 	void displayChuteAnimation();
 	void displayBarrelAnimation();
 	void handleBootParam(int value);
+	int restartRestoreScreen();
 public:
 	Game();
 	virtual ~Game();
 
 	static Game &getReference();
 
-	void tick(bool fastSpeed = false);
+	void tick();
+	void tickCheck();
 	void nextFrame();
 	void execute();
 	void setState(uint8 flags) { _state = flags; }
+	bool &preloadFlag() { return _preloadFlag; }
 
 	// Menu item support methods
 	void doDebugMenu();

Modified: scummvm/trunk/engines/lure/lure.h
===================================================================
--- scummvm/trunk/engines/lure/lure.h	2007-08-12 11:14:23 UTC (rev 28547)
+++ scummvm/trunk/engines/lure/lure.h	2007-08-12 11:15:06 UTC (rev 28548)
@@ -71,6 +71,7 @@
 	uint32 features() { return _features; }
 	uint8 game() { return _game; }
 	Disk &disk() { return *_disk; }
+	Common::Language getLanguage() { return _language; }
 
 	bool loadGame(uint8 slotNumber);
 	bool saveGame(uint8 slotNumber, Common::String &caption);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list