ScummVM API documentation
saveconverter.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 * This file is dual-licensed.
22 * In addition to the GPLv3 license mentioned above, this code is also
23 * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24 * full text of the license.
25 *
26 */
27
28#ifndef GOB_SAVE_SAVECONVERTER_H
29#define GOB_SAVE_SAVECONVERTER_H
30
31#include "common/stream.h"
32
33namespace Gob {
34
35class GobEngine;
36class SavePartInfo;
37class SavePartVars;
38class SavePartMem;
39class SavePartSprite;
40class SaveWriter;
41
44public:
45 SaveConverter(GobEngine *vm, const Common::String &fileName);
46 ~SaveConverter() override;
47
49 virtual void clear();
51 virtual void setFileName(const Common::String &fileName);
52
54 virtual int isOldSave(Common::InSaveFile **save = 0) const = 0;
56 virtual char *getDescription(Common::SeekableReadStream &save) const = 0;
58 virtual bool load() = 0;
59
61 char *getDescription(const Common::String &fileName);
63 char *getDescription() const;
64
65 // Stream
66 bool err() const override;
67 void clearErr() override;
68 // ReadStream
69 bool eos() const override;
70 uint32 read(void *dataPtr, uint32 dataSize) override;
71 // SeekableReadStream
72 int64 pos() const override;
73 int64 size() const override;
74 bool seek(int64 offset, int whence = SEEK_SET) override;
75
76protected:
77 GobEngine *_vm;
78
79 Common::String _fileName;
80
81 byte *_data;
83
84 Common::InSaveFile *openSave() const;
85
87 virtual void displayWarning() const;
88
89 virtual uint32 getActualSize(Common::InSaveFile **save = 0) const;
90
92 uint32 descLength, bool hasSizes = true) const;
94 uint32 count, bool endian) const;
96 uint32 count, bool endian) const;
98 uint32 width, uint32 height, bool palette) const;
99
100 bool createStream(SaveWriter &writer);
101
103 static bool swapDataEndian(byte *data, const byte *sizes, uint32 count);
104
105private:
106 byte *readData(Common::SeekableReadStream &stream,
107 uint32 count, bool endian) const;
108};
109
112public:
113 SaveConverter_Notes(GobEngine *vm, uint32 notesSize, const Common::String &fileName = "");
114 ~SaveConverter_Notes() override;
115
116 int isOldSave(Common::InSaveFile **save = 0) const override;
117 char *getDescription(Common::SeekableReadStream &save) const override;
118
119 bool load() override;
120
121private:
122 uint32 _size;
123
124 bool loadFail(SavePartVars *vars, Common::InSaveFile *save);
125};
126
129public:
130 SaveConverter_v2(GobEngine *vm, const Common::String &fileName = "");
131 ~SaveConverter_v2() override;
132
133 int isOldSave(Common::InSaveFile **save = 0) const override;
134 char *getDescription(Common::SeekableReadStream &save) const override;
135
136 bool load() override;
137
138private:
139 static const uint32 kSlotCount = 15;
140 static const uint32 kSlotNameLength = 40;
141
142 bool loadFail(SavePartInfo *info, SavePartVars *vars,
143 Common::InSaveFile *save);
144};
145
148public:
149 SaveConverter_v3(GobEngine *vm, const Common::String &fileName = "");
150 ~SaveConverter_v3() override;
151
152 int isOldSave(Common::InSaveFile **save = 0) const override;
153 char *getDescription(Common::SeekableReadStream &save) const override;
154
155 bool load() override;
156
157private:
158 static const uint32 kSlotCount = 30;
159 static const uint32 kSlotNameLength = 40;
160
161 bool loadFail(SavePartInfo *info, SavePartVars *vars,
162 SavePartSprite *sprite, Common::InSaveFile *save);
163
164 void getScreenShotProps(int type,
165 bool &used, uint32 &width, uint32 &height);
166};
167
170public:
171 SaveConverter_v4(GobEngine *vm, const Common::String &fileName = "");
172 ~SaveConverter_v4() override;
173
174 int isOldSave(Common::InSaveFile **save = 0) const override;
175 char *getDescription(Common::SeekableReadStream &save) const override;
176
177 bool load() override;
178
179private:
180 static const uint32 kSlotCount = 60;
181 static const uint32 kSlotNameLength = 40;
182
183 bool loadFail(SavePartInfo *info, SavePartVars *vars,
184 SavePartMem *props, Common::InSaveFile *save);
185};
186
187} // End of namespace Gob
188
189#endif // GOB_SAVE_SAVECONVERTER_H
Definition: stream.h:745
Definition: str.h:59
Definition: gob.h:166
Definition: saveconverter.h:111
bool load() override
char * getDescription(Common::SeekableReadStream &save) const override
int isOldSave(Common::InSaveFile **save=0) const override
Definition: saveconverter.h:128
char * getDescription(Common::SeekableReadStream &save) const override
int isOldSave(Common::InSaveFile **save=0) const override
bool load() override
Definition: saveconverter.h:147
int isOldSave(Common::InSaveFile **save=0) const override
char * getDescription(Common::SeekableReadStream &save) const override
bool load() override
Definition: saveconverter.h:169
int isOldSave(Common::InSaveFile **save=0) const override
char * getDescription(Common::SeekableReadStream &save) const override
bool load() override
Definition: saveconverter.h:43
int64 pos() const override
virtual char * getDescription(Common::SeekableReadStream &save) const =0
virtual bool load()=0
bool seek(int64 offset, int whence=SEEK_SET) override
virtual void setFileName(const Common::String &fileName)
bool eos() const override
int64 size() const override
char * getDescription(const Common::String &fileName)
virtual int isOldSave(Common::InSaveFile **save=0) const =0
uint32 read(void *dataPtr, uint32 dataSize) override
static bool swapDataEndian(byte *data, const byte *sizes, uint32 count)
bool err() const override
void clearErr() override
virtual void displayWarning() const
virtual void clear()
char * getDescription() const
Definition: savefile.h:200
Definition: savefile.h:108
Definition: savefile.h:162
Definition: savefile.h:130
Definition: savefile.h:340