aboutsummaryrefslogtreecommitdiff
path: root/engines/hopkins/detection.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2012-10-28 14:51:17 +1100
committerPaul Gilbert2012-10-28 14:51:17 +1100
commitb005f9dad0322a2c4ec46b471fa070444d1a2245 (patch)
tree305c9a3f2f737253f62ff1c27de5299fce6ae15c /engines/hopkins/detection.cpp
parent40748dabc7298575a11ee9e3b8b1102bd5d96214 (diff)
downloadscummvm-rg350-b005f9dad0322a2c4ec46b471fa070444d1a2245.tar.gz
scummvm-rg350-b005f9dad0322a2c4ec46b471fa070444d1a2245.tar.bz2
scummvm-rg350-b005f9dad0322a2c4ec46b471fa070444d1a2245.zip
HOPKINS: Work on hooking save/loading into the ScummVM framework
Diffstat (limited to 'engines/hopkins/detection.cpp')
-rw-r--r--engines/hopkins/detection.cpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/engines/hopkins/detection.cpp b/engines/hopkins/detection.cpp
index 0be4337862..8724802552 100644
--- a/engines/hopkins/detection.cpp
+++ b/engines/hopkins/detection.cpp
@@ -33,6 +33,8 @@
#include "hopkins/hopkins.h"
+#define MAX_SAVES 99
+
namespace Hopkins {
struct HopkinsGameDescription {
@@ -113,29 +115,65 @@ SaveStateList HopkinsMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String saveDesc;
- Common::String pattern = "hopkins.0??";
+ Common::String pattern = Common::String::format("%s.0??", target);
filenames = saveFileMan->listSavefiles(pattern);
- sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order
+
+ Hopkins::hopkinsSavegameHeader header;
SaveStateList saveList;
- // TODO
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ const char *ext = strrchr(file->c_str(), '.');
+ int slot = ext ? atoi(ext + 1) : -1;
+
+ if (slot >= 0 && slot < MAX_SAVES) {
+ Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+
+ if (in) {
+ if (Hopkins::SaveLoadManager::readSavegameHeader(in, header)) {
+ saveList.push_back(SaveStateDescriptor(slot, header.saveName));
+
+ header.thumbnail->free();
+ delete header.thumbnail;
+ }
+
+ delete in;
+ }
+ }
+ }
return saveList;
}
int HopkinsMetaEngine::getMaximumSaveSlot() const {
- return 99;
+ return MAX_SAVES;
}
void HopkinsMetaEngine::removeSaveState(const char *target, int slot) const {
- Common::String filename = "todo";
-
+ Common::String filename = Common::String::format("%s.%03d", target, slot);
g_system->getSavefileManager()->removeSavefile(filename);
}
SaveStateDescriptor HopkinsMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
- // TODO
+ Common::String filename = Common::String::format("%s.%03d", target, slot);
+ Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
+
+ if (f) {
+ Hopkins::hopkinsSavegameHeader header;
+ Hopkins::SaveLoadManager::readSavegameHeader(f, header);
+ delete f;
+
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, header.saveName);
+ desc.setThumbnail(header.thumbnail);
+ desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
+ desc.setSaveTime(header.saveHour, header.saveMinutes);
+ desc.setPlayTime(header.totalFrames * GAME_FRAME_TIME);
+
+ return desc;
+ }
+
return SaveStateDescriptor();
}