[Scummvm-cvs-logs] SF.net SVN: scummvm:[53549] scummvm/trunk/engines/toon

sylvaintv at users.sourceforge.net sylvaintv at users.sourceforge.net
Sat Oct 16 23:58:34 CEST 2010


Revision: 53549
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53549&view=rev
Author:   sylvaintv
Date:     2010-10-16 21:58:33 +0000 (Sat, 16 Oct 2010)

Log Message:
-----------
TOON: Added most of the remaining Advanced Engine Features

Loading/Saving during runtime, Advanced Pausing,
Load savestate via launcher, RTL

Modified Paths:
--------------
    scummvm/trunk/engines/toon/character.cpp
    scummvm/trunk/engines/toon/character.h
    scummvm/trunk/engines/toon/detection.cpp
    scummvm/trunk/engines/toon/movie.cpp
    scummvm/trunk/engines/toon/movie.h
    scummvm/trunk/engines/toon/toon.cpp
    scummvm/trunk/engines/toon/toon.h

Modified: scummvm/trunk/engines/toon/character.cpp
===================================================================
--- scummvm/trunk/engines/toon/character.cpp	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/character.cpp	2010-10-16 21:58:33 UTC (rev 53549)
@@ -234,6 +234,11 @@
 
 }
 
+void Character::updateTimers(int32 relativeAdd) {
+	_nextIdleTime += relativeAdd;
+	_lastWalkTime += relativeAdd;
+}
+
 void Character::stopSpecialAnim() {
 	debugC(4, kDebugCharacter, "stopSpecialAnim()");
 // Strangerke - Commented (not used)

Modified: scummvm/trunk/engines/toon/character.h
===================================================================
--- scummvm/trunk/engines/toon/character.h	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/character.h	2010-10-16 21:58:33 UTC (rev 53549)
@@ -95,6 +95,7 @@
 	virtual void stopSpecialAnim();
 	virtual void updateIdle();
 	virtual int32 getRandomIdleAnim() { return 0; }
+	virtual void updateTimers(int32 relativeAdd);
 
 	int32 getFacingFromDirection(int32 dx, int32 dy);
 	static const SpecialCharacterAnimation *getSpecialAnimation(int32 characterId, int32 animationId);

Modified: scummvm/trunk/engines/toon/detection.cpp
===================================================================
--- scummvm/trunk/engines/toon/detection.cpp	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/detection.cpp	2010-10-16 21:58:33 UTC (rev 53549)
@@ -145,19 +145,24 @@
 	virtual int getMaximumSaveSlot() const;
 	virtual SaveStateList listSaves(const char *target) const;
 	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
-//	virtual void removeSaveState(const char *target, int slot) const;
+	virtual void removeSaveState(const char *target, int slot) const;
 };
 
 bool ToonMetaEngine::hasFeature(MetaEngineFeature f) const {
 	return
 	    (f == kSupportsListSaves) ||
-//	    (f == kSupportsLoadingDuringStartup) ||
+	    (f == kSupportsLoadingDuringStartup) ||
 	    (f == kSupportsDeleteSave) ||
 	    (f == kSavesSupportMetaInfo) ||
 	    (f == kSavesSupportThumbnail) ||
 	    (f == kSavesSupportCreationDate);
 }
 
+void ToonMetaEngine::removeSaveState(const char *target, int slot) const {
+	Common::String fileName = Common::String::printf("%s.%03d", target, slot);
+	g_system->getSavefileManager()->removeSavefile(fileName);
+}
+
 int ToonMetaEngine::getMaximumSaveSlot() const { return 99; }
 
 SaveStateList ToonMetaEngine::listSaves(const char *target) const {

Modified: scummvm/trunk/engines/toon/movie.cpp
===================================================================
--- scummvm/trunk/engines/toon/movie.cpp	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/movie.cpp	2010-10-16 21:58:33 UTC (rev 53549)
@@ -61,6 +61,7 @@
 
 Movie::Movie(ToonEngine *vm , ToonstruckSmackerDecoder *decoder) {
 	_vm = vm;
+	_playing = false;
 	_decoder = decoder;
 }
 
@@ -73,14 +74,16 @@
 void Movie::play(Common::String video, int32 flags) {
 	debugC(1, kDebugMovie, "play(%s, %d)", video.c_str(), flags);
 
+	_playing = true;
 	if (flags & 1)
 		_vm->getAudioManager()->setMusicVolume(0);
 	_decoder->loadFile(video.c_str(), flags);
 	playVideo();
 	_vm->flushPalette();
 	if (flags & 1)
-		_vm->getAudioManager()->setMusicVolume(100);
+		_vm->getAudioManager()->setMusicVolume(_vm->getAudioManager()->isMusicMuted() ? 0 : 255);
 	_decoder->close();
+	_playing = false;
 }
 
 bool Movie::playVideo() {

Modified: scummvm/trunk/engines/toon/movie.h
===================================================================
--- scummvm/trunk/engines/toon/movie.h	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/movie.h	2010-10-16 21:58:33 UTC (rev 53549)
@@ -45,12 +45,15 @@
 
 	void init() const;
 	void play(Common::String video, int32 flags = 0);
+	bool isPlaying() { return _playing; }
 
 protected:
 	bool playVideo();
 	ToonEngine *_vm;
 	Audio::Mixer *_mixer;
 	ToonstruckSmackerDecoder *_decoder;
+	bool _playing;
+	
 };
 
 } // End of namespace Toon

Modified: scummvm/trunk/engines/toon/toon.cpp
===================================================================
--- scummvm/trunk/engines/toon/toon.cpp	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/toon.cpp	2010-10-16 21:58:33 UTC (rev 53549)
@@ -182,10 +182,12 @@
 				_audioManager->stopCurrentVoice();
 			}
 			if (event.kbd.keycode == Common::KEYCODE_F5) {
-				saveGame(-1);
+				if(canSaveGameStateCurrently())
+					saveGame(-1, Common::String());
 			}
 			if (event.kbd.keycode == Common::KEYCODE_F6) {
-				loadGame(-1);
+				if(canLoadGameStateCurrently())
+					loadGame(-1);
 			}
 			if (event.kbd.ascii == 't') {
 				_showConversationText = !_showConversationText;
@@ -203,7 +205,7 @@
 			if (event.kbd.flags & Common::KBD_ALT) {
 				int32 slotNum = event.kbd.ascii - '0';
 				if (slotNum >= 0 && slotNum <= 9) {
-					if (saveGame(slotNum)) {
+					if (saveGame(slotNum, Common::String())) {
 						// ok
 						char buf[256];
 						snprintf(buf, 256, "Saved game in slot #%d ", slotNum);
@@ -692,15 +694,24 @@
 	initGraphics(640, 400, true);
 	init();
 
-	// play producer intro
-	getMoviePlayer()->play("MISC/VIELOGOM.SMK", 0x10);
-
-	// show mainmenu
+	// do we need to load directly a game?
 	bool loadedGame = false;
-	if (!showMainmenu(loadedGame)) {
-		return Common::kNoError;
+	int32 slot = ConfMan.getInt("save_slot");
+	if (slot > -1) {
+		loadedGame = loadGame(slot);
 	}
 
+	if (!loadedGame) {
+
+		// play producer intro
+		getMoviePlayer()->play("MISC/VIELOGOM.SMK", 0x10);
+
+		// show mainmenu
+		if (!showMainmenu(loadedGame)) {
+			return Common::kNoError;
+		}
+	}
+
 	//loadScene(17);
 	//loadScene(37);
 	if (!loadedGame) {
@@ -2730,11 +2741,49 @@
 	}
 }
 
+void ToonEngine::pauseEngineIntern(bool pause) {
+	
+	Engine::pauseEngineIntern(pause);
+
+	static int32 pauseStart = 0;
+	if (pause) {
+		pauseStart = _system->getMillis();
+
+	} else {
+		_oldTimer = _system->getMillis();
+		_oldTimer2 = _oldTimer;
+
+		int32 diff = _oldTimer - pauseStart;
+
+		// we have to add the difference between the start and the current time
+		// to all "timer based" values.
+		for (int32 i = 0; i < _gameState->_locations[_gameState->_currentScene]._numSceneAnimations; i++) {
+			_sceneAnimationScripts[i]._lastTimer += diff;
+		}
+		for (int32 i = 0; i < 8; i++) {
+			if (_characters[i]) {
+				_characters[i]->updateTimers(diff);
+			}
+		}
+
+		_gameState->_timerTimeout[0] += diff;
+		_gameState->_timerTimeout[1] += diff;
+	}
+}
+
+bool ToonEngine::canSaveGameStateCurrently() {
+	return !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying();
+}
+
+bool ToonEngine::canLoadGameStateCurrently() {
+	return !_gameState->_inInventory && !_gameState->_inConversation && !_gameState->_inCutaway && !_gameState->_mouseHidden && !_moviePlayer->isPlaying();
+}
+
 Common::String ToonEngine::getSavegameName(int nr) {
 	return _targetName + Common::String::printf(".%03d", nr);
 }
 
-bool ToonEngine::saveGame(int32 slot) {
+bool ToonEngine::saveGame(int32 slot, Common::String saveGameDesc) {
 	const EnginePlugin *plugin = NULL;
 	int16 savegameId;
 	Common::String savegameDescription;
@@ -2748,7 +2797,11 @@
 		delete dialog;
 	} else {
 		savegameId = slot;
-		savegameDescription = Common::String::printf("Quick save #%d", slot);
+		if (!saveGameDesc.empty()) {
+			savegameDescription = saveGameDesc;
+		} else {
+			savegameDescription = Common::String::printf("Quick save #%d", slot);
+		}
 	}
 
 	if (savegameId < 0)

Modified: scummvm/trunk/engines/toon/toon.h
===================================================================
--- scummvm/trunk/engines/toon/toon.h	2010-10-16 21:05:59 UTC (rev 53548)
+++ scummvm/trunk/engines/toon/toon.h	2010-10-16 21:58:33 UTC (rev 53549)
@@ -30,6 +30,7 @@
 #include "engines/engine.h"
 #include "graphics/surface.h"
 #include "common/random.h"
+#include "common/error.h"
 #include "toon/resource.h"
 #include "toon/script.h"
 #include "toon/script_func.h"
@@ -169,7 +170,7 @@
 	Character *getCharacterById(int32 charId);
 	Common::String getSavegameName(int nr);
 	bool loadGame(int32 slot);
-	bool saveGame(int32 slot);
+	bool saveGame(int32 slot, Common::String saveGameDesc);
 	void fadeIn(int32 numFrames) ;
 	void fadeOut(int32 numFrames) ;
 	void initCharacter(int32 characterId, int32 animScriptId, int32 animToPlayId, int32 sceneAnimationId);
@@ -197,6 +198,10 @@
 	void waitForScriptStep();
 	void doMagnifierEffect();
 
+	bool canSaveGameStateCurrently();
+	bool canLoadGameStateCurrently();
+	void pauseEngineIntern(bool pause);
+
 	Resources *resources() {
 		return _resources;
 	}
@@ -305,6 +310,22 @@
 		return _shouldQuit;
 	}
 
+	Common::Error saveGameState(int slot, const char *desc) {
+		
+		return (saveGame(slot, desc) ? Common::kWritingFailed : Common::kNoError);
+	}
+
+	Common::Error loadGameState(int slot) {
+		return (loadGame(slot) ? Common::kReadingFailed : Common::kNoError);
+	}
+
+	bool hasFeature(EngineFeature f) const {
+		return
+			(f == kSupportsRTL) ||
+			(f == kSupportsLoadingDuringRuntime) ||
+			(f == kSupportsSavingDuringRuntime);
+	}
+
 protected:
 	OSystem *_system;
 	int32 _tickLength;


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