-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetaengine.cpp
More file actions
90 lines (77 loc) · 3.06 KB
/
Copy pathmetaengine.cpp
File metadata and controls
90 lines (77 loc) · 3.06 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
87
88
89
90
/* ScummVM - ACK Meta Engine
*
* Implements the meta engine interface for the ACK engine.
* Handles save state listing, deletion, and extra metadata.
* Integrated into ScummVM.
*/
#include "engines/ack/ack.h"
#include "engines/ack/detection.h"
#include "engines/advancedDetector.h"
#include "common/system.h"
#include "common/savefile.h"
#include "common/translation.h"
namespace Ack {
class AckMetaEngine : public AdvancedMetaEngine {
public:
const char *getName() const override {
return "ack";
}
bool hasFeature(MetaEngineFeature f) const override {
// Support listing saves, loading during startup, delete, meta info, thumbnail and creation date.
return (f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
(f == kSavesSupportPlayTime);
}
Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override {
const AckGameDescription *gd = reinterpret_cast<const AckGameDescription *>(desc);
*engine = new AckEngine(syst, gd);
return Common::kNoError;
}
SaveStateList listSaves(const char *target) const override {
Common::SaveFileManager *saveFileMan = g_system->getSaveFileManager();
Common::StringArray filenames;
Common::String saveDesc;
Common::String pattern = Common::String::format("%s.??", target);
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
int slotNum = atoi(file->c_str() + file->size() - 2);
if (slotNum >= 0 && slotNum <= 99) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
saveDesc = in->readString();
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
}
}
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
int getMaximumSaveSlot() const override {
return 99;
}
void removeSaveState(const char *target, int slot) const override {
Common::String filename = Common::String::format("%s.%02d", target, slot);
g_system->getSaveFileManager()->removeSavefile(filename);
}
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override {
Common::String filename = Common::String::format("%s.%02d", target, slot);
Common::InSaveFile *in = g_system->getSaveFileManager()->openForLoading(filename);
if (!in)
return SaveStateDescriptor();
SaveStateDescriptor desc(slot, "");
desc.setDescription(in->readString());
int day = in->readSint16LE();
int month = in->readSint16LE();
int year = in->readSint16LE();
desc.setSaveDate(year, month, day);
int hour = in->readSint16LE();
int minutes = in->readSint16LE();
desc.setSaveTime(hour, minutes);
if (in->readByte() == 1) {
int thumbWidth = in->readUint16LE();