-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetaengine.cpp
More file actions
86 lines (69 loc) · 2.74 KB
/
Copy pathmetaengine.cpp
File metadata and controls
86 lines (69 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "ack/ack.h"
#include "ack/detection.h"
#include "engines/advancedDetector.h"
#include "common/savefile.h"
#include "common/system.h"
#include "graphics/surface.h"
#include "graphics/thumbnail.h"
namespace ACK {
class ACKMetaEngine : public AdvancedMetaEngine {
public:
const char *getName() const override {
return "ack";
}
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override {
*engine = new ACKEngine(syst);
return Common::kNoError;
}
bool hasFeature(MetaEngineFeature f) const override {
return
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsSavingDuringRuntime) ||
(f == kSupportsDeleteSave);
}
int getMaximumSaveSlot() const override {
return 99;
}
SaveStateList listSaves(const char *target) const override {
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) {
Common::String filename = *file;
Common::InSaveFile *in = saveFileMan->openForLoading(filename);
if (in) {
Common::String saveName;
saveName = filename;
saveList.push_back(SaveStateDescriptor(atoi(filename.c_str() + filename.size() - 3), saveName));
delete in;
}
}
return saveList;
}
void removeSaveState(const char *target, int slot) const override {
Common::String filename = Common::String::format("%s.%03d", target, slot);
g_system->getSaveFileManager()->removeSavefile(filename);
}
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override {
Common::String filename = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *in = g_system->getSaveFileManager()->openForLoading(filename);
if (in) {
SaveStateDescriptor desc(slot, filename);
desc.setDeletableFlag(true);
desc.setWriteProtectedFlag(false);
delete in;
return desc;
}
return SaveStateDescriptor();
}
};
} // End of namespace ACK
#if PLUGIN_ENABLED_DYNAMIC(ACK)
REGISTER_PLUGIN_DYNAMIC(ACK, PLUGIN_TYPE_ENGINE, ACK::ACKMetaEngine);
#else
REGISTER_PLUGIN_STATIC(ACK, PLUGIN_TYPE_ENGINE, ACK::ACKMetaEngine);
#endif