diff options
Diffstat (limited to 'engines/mohawk/detection.cpp')
-rw-r--r-- | engines/mohawk/detection.cpp | 115 |
1 files changed, 97 insertions, 18 deletions
diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp index 926c296257..246d3ec3c1 100644 --- a/engines/mohawk/detection.cpp +++ b/engines/mohawk/detection.cpp @@ -26,6 +26,7 @@ #include "common/savefile.h" #include "common/system.h" #include "common/textconsole.h" +#include "common/translation.h" #include "mohawk/livingbooks.h" @@ -35,10 +36,12 @@ #ifdef ENABLE_MYST #include "mohawk/myst.h" +#include "mohawk/myst_state.h" #endif #ifdef ENABLE_RIVEN #include "mohawk/riven.h" +#include "mohawk/riven_saveload.h" #endif namespace Mohawk { @@ -52,7 +55,7 @@ struct MohawkGameDescription { }; const char* MohawkEngine::getGameId() const { - return _gameDescription->desc.gameid; + return _gameDescription->desc.gameId; } uint32 MohawkEngine::getFeatures() const { @@ -159,10 +162,24 @@ static const char *directoryGlobs[] = { 0 }; +static const ADExtraGuiOptionsMap optionsList[] = { + { + GAMEOPTION_PLAY_MYST_FLYBY, + { + _s("Play the Myst fly by movie"), + _s("The Myst fly by movie was not played by the original engine."), + "playmystflyby", + false + } + }, + + AD_EXTRA_GUI_OPTIONS_TERMINATOR +}; + class MohawkMetaEngine : public AdvancedMetaEngine { public: - MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames) { - _singleid = "mohawk"; + MohawkMetaEngine() : AdvancedMetaEngine(Mohawk::gameDescriptions, sizeof(Mohawk::MohawkGameDescription), mohawkGames, optionsList) { + _singleId = "mohawk"; _maxScanDepth = 2; _directoryGlobs = directoryGlobs; } @@ -182,45 +199,107 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; virtual SaveStateList listSaves(const char *target) const; + SaveStateList listSavesForPrefix(const char *prefix, const char *extension) const; virtual int getMaximumSaveSlot() const { return 999; } virtual void removeSaveState(const char *target, int slot) const; + virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; }; bool MohawkMetaEngine::hasFeature(MetaEngineFeature f) const { return (f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup) - || (f == kSupportsDeleteSave); + || (f == kSupportsDeleteSave) + || (f == kSavesSupportMetaInfo) + || (f == kSavesSupportThumbnail) + || (f == kSavesSupportCreationDate) + || (f == kSavesSupportPlayTime); +} + +SaveStateList MohawkMetaEngine::listSavesForPrefix(const char *prefix, const char *extension) const { + Common::String pattern = Common::String::format("%s-###.%s", prefix, extension); + Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern); + size_t prefixLen = strlen(prefix); + + SaveStateList saveList; + for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { + // Extract the slot number from the filename + char slot[4]; + slot[0] = (*filename)[prefixLen + 1]; + slot[1] = (*filename)[prefixLen + 2]; + slot[2] = (*filename)[prefixLen + 3]; + slot[3] = '\0'; + + int slotNum = atoi(slot); + + saveList.push_back(SaveStateDescriptor(slotNum, "")); + } + + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); + + return saveList; } SaveStateList MohawkMetaEngine::listSaves(const char *target) const { - Common::StringArray filenames; SaveStateList saveList; // Loading games is only supported in Myst/Riven currently. +#ifdef ENABLE_MYST if (strstr(target, "myst")) { - filenames = g_system->getSavefileManager()->listSavefiles("*.mys"); - - for (uint32 i = 0; i < filenames.size(); i++) - saveList.push_back(SaveStateDescriptor(i, filenames[i])); - } else if (strstr(target, "riven")) { - filenames = g_system->getSavefileManager()->listSavefiles("*.rvn"); + saveList = listSavesForPrefix("myst", "mys"); - for (uint32 i = 0; i < filenames.size(); i++) - saveList.push_back(SaveStateDescriptor(i, filenames[i])); + for (SaveStateList::iterator save = saveList.begin(); save != saveList.end(); ++save) { + // Read the description from the save + int slot = save->getSaveSlot(); + Common::String description = Mohawk::MystGameState::querySaveDescription(slot); + save->setDescription(description); + } } +#endif +#ifdef ENABLE_RIVEN + if (strstr(target, "riven")) { + saveList = listSavesForPrefix("riven", "rvn"); + + for (SaveStateList::iterator save = saveList.begin(); save != saveList.end(); ++save) { + // Read the description from the save + int slot = save->getSaveSlot(); + Common::String description = Mohawk::RivenSaveLoad::querySaveDescription(slot); + save->setDescription(description); + } + } +#endif return saveList; } void MohawkMetaEngine::removeSaveState(const char *target, int slot) const { + // Removing saved games is only supported in Myst/Riven currently. +#ifdef ENABLE_MYST if (strstr(target, "myst")) { - Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("*.mys"); - g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str()); - } else if (strstr(target, "riven")) { - Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles("*.rvn"); - g_system->getSavefileManager()->removeSavefile(filenames[slot].c_str()); + Mohawk::MystGameState::deleteSave(slot); + } +#endif +#ifdef ENABLE_RIVEN + if (strstr(target, "riven")) { + Mohawk::RivenSaveLoad::deleteSave(slot); + } +#endif +} + +SaveStateDescriptor MohawkMetaEngine::querySaveMetaInfos(const char *target, int slot) const { +#ifdef ENABLE_MYST + if (strstr(target, "myst")) { + return Mohawk::MystGameState::querySaveMetaInfos(slot); + } +#endif +#ifdef ENABLE_RIVEN + if (strstr(target, "riven")) { + return Mohawk::RivenSaveLoad::querySaveMetaInfos(slot); + } else +#endif + { + return SaveStateDescriptor(); } } |