From d5d8434fd65dd201118ec54e1dd2ee2cbba653bd Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 24 Aug 2010 09:00:53 +0000 Subject: SCI: now pausing/unpausing music in replaced restore dialog dialog will not get replaced in sci32, nor in mother goose. Enable by adding "scireplacedialog" inside scummvm section of scummvm.ini file. Note: this feature is experimental svn-id: r52318 --- engines/sci/engine/kfile.cpp | 54 +++++++++++++++++++++++++---------------- engines/sci/engine/savegame.cpp | 6 ++--- engines/sci/sci.cpp | 16 ++++++++++-- 3 files changed, 50 insertions(+), 26 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index b5f741451c..cb6985adaf 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -632,6 +632,7 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { Common::String game_id = !argv[0].isNull() ? s->_segMan->getString(argv[0]) : ""; int16 savegameId = argv[1].toSint16(); + bool pausedMusic = false; debug(3, "kRestoreGame(%s,%d)", game_id.c_str(), savegameId); @@ -639,14 +640,18 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { // Direct call, either from launcher or from a patched Game::restore call if (savegameId == -1) { // we are supposed to show a dialog for the user and let him choose a saved game + g_sci->_soundCmd->pauseAll(true); // pause music const EnginePlugin *plugin = NULL; EngineMan.findGame(g_sci->getGameIdStr(), &plugin); GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore"); dialog->setSaveMode(false); savegameId = dialog->runModal(plugin, ConfMan.getActiveDomainName()); delete dialog; - if (savegameId < 0) + if (savegameId < 0) { + g_sci->_soundCmd->pauseAll(false); // unpause music return s->r_acc; + } + pausedMusic = true; } // don't adjust ID of the saved game, it's already correct } else { @@ -658,34 +663,41 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { savegameId -= SAVEGAMEID_OFFICIALRANGE_START; } + s->r_acc = NULL_REG; // signals success + Common::Array saves; listSavegames(saves); if (findSavegame(saves, savegameId) == -1) { + s->r_acc = TRUE_REG; warning("Savegame ID %d not found", savegameId); - return TRUE_REG; - } + } else { + Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager(); + Common::String filename = g_sci->getSavegameName(savegameId); + Common::SeekableReadStream *in; + if ((in = saveFileMan->openForLoading(filename))) { + // found a savegame file - Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager(); - Common::String filename = g_sci->getSavegameName(savegameId); - Common::SeekableReadStream *in; - if ((in = saveFileMan->openForLoading(filename))) { - // found a savegame file - - gamestate_restore(s, in); - delete in; - - if (g_sci->getGameId() == GID_MOTHERGOOSE256) { - // WORKAROUND: Mother Goose SCI1/SCI1.1 does some weird things for - // saving a previously restored game. - // We set the current savedgame-id directly and remove the script - // code concerning this via script patch. - s->variables[VAR_GLOBAL][0xB3].offset = SAVEGAMEID_OFFICIALRANGE_START + savegameId; + gamestate_restore(s, in); + delete in; + + if (g_sci->getGameId() == GID_MOTHERGOOSE256) { + // WORKAROUND: Mother Goose SCI1/SCI1.1 does some weird things for + // saving a previously restored game. + // We set the current savedgame-id directly and remove the script + // code concerning this via script patch. + s->variables[VAR_GLOBAL][0xB3].offset = SAVEGAMEID_OFFICIALRANGE_START + savegameId; + } + } else { + s->r_acc = TRUE_REG; + warning("Savegame #%d not found", savegameId); } - return s->r_acc; } - s->r_acc = TRUE_REG; - warning("Savegame #%d not found", savegameId); + if (!s->r_acc.isNull()) { + // no success? + if (pausedMusic) + g_sci->_soundCmd->pauseAll(false); // unpause music + } return s->r_acc; } diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 79c4d6adf5..88f5d29920 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -708,7 +708,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { sync_SavegameMetadata(ser, meta); if (fh->eos()) { - s->r_acc = make_reg(0, 1); // signal failure + s->r_acc = TRUE_REG; // signal failure return; } @@ -723,7 +723,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { showScummVMDialog("The format of this saved game is obsolete, unable to load it"); - s->r_acc = make_reg(0, 1); // signal failure + s->r_acc = TRUE_REG; // signal failure return; } @@ -734,7 +734,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { showScummVMDialog("This saved game was created with a different version of the game, unable to load it"); - s->r_acc = make_reg(0, 1); // signal failure + s->r_acc = TRUE_REG; // signal failure return; } } diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index fdd3d5e379..7f262416a0 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -347,8 +347,20 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) { const uint16 kernelCount = _kernel->getKernelNamesSize(); byte kernelIdRestore = 0; - // DISABLE NEXT LINE FOR REPLACING SIERRA GAME RESTORE DIALOG WITH SCUMMVM RESTORE - return; + // this feature is currently not supported on SCI32 + if (getSciVersion() >= SCI_VERSION_2) + return; + + switch (_gameId) { + case GID_MOTHERGOOSE256: // mother goose saves/restores directly and has no save/restore dialogs + return; + default: + break; + } + + Common::String replaceDialogOption = ConfMan.get("scireplacedialog", Common::ConfigManager::kApplicationDomain); + if (replaceDialogOption == "") + return; for (uint16 kernelNr = 0; kernelNr < kernelCount; kernelNr++) { Common::String kernelName = _kernel->getKernelName(kernelNr); -- cgit v1.2.3