aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/detection.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2019-07-20 14:22:22 +0200
committerEugene Sandulenko2019-09-03 17:17:25 +0200
commit43438a632c6feeab71f125f8a0c8fe2da18811dd (patch)
tree53899706708a80d90fec8d496d47a8aaf6403d9e /engines/hdb/detection.cpp
parentbd26cda952e2f36d3138c7d8a6143a9a60597d80 (diff)
downloadscummvm-rg350-43438a632c6feeab71f125f8a0c8fe2da18811dd.tar.gz
scummvm-rg350-43438a632c6feeab71f125f8a0c8fe2da18811dd.tar.bz2
scummvm-rg350-43438a632c6feeab71f125f8a0c8fe2da18811dd.zip
HDB: Support loading from the launcher
Diffstat (limited to 'engines/hdb/detection.cpp')
-rw-r--r--engines/hdb/detection.cpp57
1 files changed, 54 insertions, 3 deletions
diff --git a/engines/hdb/detection.cpp b/engines/hdb/detection.cpp
index b8bf22e1c8..e236a6c60f 100644
--- a/engines/hdb/detection.cpp
+++ b/engines/hdb/detection.cpp
@@ -108,21 +108,72 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual int getMaximumSaveSlot() const;
+ virtual SaveStateList listSaves(const char *target) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
bool HDBMetaEngine::hasFeature(MetaEngineFeature f) const {
return
- (f == kSupportsLoadingDuringStartup);
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsListSaves) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportPlayTime);
}
bool HDB::HDBGame::hasFeature(Engine::EngineFeature f) const {
- warning("FIXME: quitGame() exits the application, instead of RTL");
- return (f == kSupportsRTL);
+ return (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
}
int HDBMetaEngine::getMaximumSaveSlot() const { return 9; }
+SaveStateList HDBMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String pattern = target;
+ pattern += ".###";
+
+ filenames = saveFileMan->listSavefiles(pattern);
+
+ SaveStateList saveList;
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 2 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 2);
+
+ if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
+ Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
+ if (in) {
+ SaveStateDescriptor desc;
+ char mapName[32];
+ Graphics::Surface *thumbnail;
+
+ if (!Graphics::loadThumbnail(*in, thumbnail)) {
+ warning("Error loading thumbnail for %s", file->c_str());
+ }
+ desc.setThumbnail(thumbnail);
+
+ uint32 timeSeconds = in->readUint32LE();;
+ in->read(mapName, 32);
+
+ warning("mapName: %s playtime: %d", mapName, timeSeconds);
+
+ desc.setSaveSlot(slotNum);
+ desc.setPlayTime(timeSeconds * 1000);
+ desc.setDescription(mapName);
+
+ saveList.push_back(desc);
+ }
+ }
+ }
+
+ // Sort saves based on slot number.
+ Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
+ return saveList;
+}
+
bool HDBMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
if (desc) {
*engine = new HDB::HDBGame(syst, desc);