diff options
author | Sylvain Dupont | 2010-10-16 21:58:33 +0000 |
---|---|---|
committer | Sylvain Dupont | 2010-10-16 21:58:33 +0000 |
commit | 40d38fcc0d8c63036132a7aab643a7405ef5f43f (patch) | |
tree | 3b4b79c363a60d3d6aeadbb28634749cbdd8f2ea | |
parent | bc5f10a55c0c19d3d90d2c9f4ed9909787718126 (diff) | |
download | scummvm-rg350-40d38fcc0d8c63036132a7aab643a7405ef5f43f.tar.gz scummvm-rg350-40d38fcc0d8c63036132a7aab643a7405ef5f43f.tar.bz2 scummvm-rg350-40d38fcc0d8c63036132a7aab643a7405ef5f43f.zip |
TOON: Added most of the remaining Advanced Engine Features
Loading/Saving during runtime, Advanced Pausing,
Load savestate via launcher, RTL
svn-id: r53549
-rw-r--r-- | engines/toon/character.cpp | 5 | ||||
-rw-r--r-- | engines/toon/character.h | 1 | ||||
-rw-r--r-- | engines/toon/detection.cpp | 9 | ||||
-rw-r--r-- | engines/toon/movie.cpp | 5 | ||||
-rw-r--r-- | engines/toon/movie.h | 3 | ||||
-rw-r--r-- | engines/toon/toon.cpp | 75 | ||||
-rw-r--r-- | engines/toon/toon.h | 23 |
7 files changed, 106 insertions, 15 deletions
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 81e175d663..378cd11a9f 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -234,6 +234,11 @@ void Character::playStandingAnim() { } +void Character::updateTimers(int32 relativeAdd) { + _nextIdleTime += relativeAdd; + _lastWalkTime += relativeAdd; +} + void Character::stopSpecialAnim() { debugC(4, kDebugCharacter, "stopSpecialAnim()"); // Strangerke - Commented (not used) diff --git a/engines/toon/character.h b/engines/toon/character.h index 997a401403..c6cb3011f2 100644 --- a/engines/toon/character.h +++ b/engines/toon/character.h @@ -95,6 +95,7 @@ public: 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); diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp index a0017f2571..e9649b1560 100644 --- a/engines/toon/detection.cpp +++ b/engines/toon/detection.cpp @@ -145,19 +145,24 @@ public: 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 { diff --git a/engines/toon/movie.cpp b/engines/toon/movie.cpp index 87a3e878b5..91ea98a91f 100644 --- a/engines/toon/movie.cpp +++ b/engines/toon/movie.cpp @@ -61,6 +61,7 @@ ToonstruckSmackerDecoder::ToonstruckSmackerDecoder(Audio::Mixer *mixer, Audio::M Movie::Movie(ToonEngine *vm , ToonstruckSmackerDecoder *decoder) { _vm = vm; + _playing = false; _decoder = decoder; } @@ -73,14 +74,16 @@ void Movie::init() const { 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() { diff --git a/engines/toon/movie.h b/engines/toon/movie.h index 8e1acc4a77..4d5efb3343 100644 --- a/engines/toon/movie.h +++ b/engines/toon/movie.h @@ -45,12 +45,15 @@ public: 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 diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index e11b29cd6e..78e526c205 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -182,10 +182,12 @@ void ToonEngine::parseInput() { _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 @@ void ToonEngine::parseInput() { 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,13 +694,22 @@ Common::Error ToonEngine::run() { 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); @@ -2730,11 +2741,49 @@ void ToonEngine::drawConversationLine() { } } +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 @@ bool ToonEngine::saveGame(int32 slot) { 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) diff --git a/engines/toon/toon.h b/engines/toon/toon.h index a274f03711..76425b09ca 100644 --- a/engines/toon/toon.h +++ b/engines/toon/toon.h @@ -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 @@ public: 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 @@ public: void waitForScriptStep(); void doMagnifierEffect(); + bool canSaveGameStateCurrently(); + bool canLoadGameStateCurrently(); + void pauseEngineIntern(bool pause); + Resources *resources() { return _resources; } @@ -305,6 +310,22 @@ public: 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; |