diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp index 6be0ca302c8..7a943223a42 100644 --- a/engines/tony/detection.cpp +++ b/engines/tony/detection.cpp @@ -27,6 +27,7 @@ #include "common/system.h" #include "tony/tony.h" +#include "tony/game.h" namespace Tony { @@ -71,10 +72,16 @@ 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; + virtual int getMaximumSaveSlot() const; + virtual void removeSaveState(const char *target, int slot) const; }; bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const { - return false; + return + (f == kSupportsListSaves) || +// (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave); } bool Tony::TonyEngine::hasFeature(EngineFeature f) const { @@ -90,6 +97,43 @@ bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGame return gd != 0; } +SaveStateList TonyMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = "tony.0??"; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..) + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + // Obtain the last 3 digits of the filename, since they correspond to the save slot + int slotNum = atoi(file->c_str() + file->size() - 3); + + if (slotNum >= 0 && slotNum <= 999) { + byte thumbnailData[160 * 120 * 2]; + Tony::RMString saveName; + byte difficulty; + + if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slotNum, thumbnailData, saveName, difficulty)) { + // Add the save name to the savegame list + saveList.push_back(SaveStateDescriptor(slotNum, (const char *)saveName)); + } + } + } + + return saveList; +} + +int TonyMetaEngine::getMaximumSaveSlot() const { return 99; } + +void TonyMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String filename = Tony::TonyEngine::GetSaveStateFileName(slot); + + g_system->getSavefileManager()->removeSavefile(filename); +} + #if PLUGIN_ENABLED_DYNAMIC(TONY) REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine); #else diff --git a/engines/tony/game.h b/engines/tony/game.h index 83972e0f171..22df40c6d8f 100644 --- a/engines/tony/game.h +++ b/engines/tony/game.h @@ -263,6 +263,9 @@ public: // Polling per l'option screen void DoFrame(CORO_PARAM, RMInput *m_input); + // Retrieves a savegame's thumbnail, description, and difficulty level + static bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); + protected: // Inizializza tutto per il nuovo stato @@ -274,8 +277,6 @@ protected: void RefreshAll(CORO_PARAM); void RefreshThumbnails(void); - // Carica lo screenshot per il salvataggio - bool LoadThumbnailFromSaveState(int numState, byte *lpDestBuf, RMString &name, byte &diff); }; } // End of namespace Tony diff --git a/engines/tony/tony.h b/engines/tony/tony.h index c1ad6756c26..c106a0856b9 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -198,7 +198,7 @@ public: void AutoSave(CORO_PARAM); void SaveState(int n, const char *name); void LoadState(CORO_PARAM, int n); - Common::String GetSaveStateFileName(int n); + static Common::String GetSaveStateFileName(int n); // Prende il thumbnail void GrabThumbnail(void);