ScummVM API documentation
savegame.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
22#ifndef ASYLUM_SYSTEM_SAVEGAME_H
23#define ASYLUM_SYSTEM_SAVEGAME_H
24
25#include "common/savefile.h"
26#include "common/serializer.h"
27#include "common/util.h"
28
29#include "asylum/shared.h"
30
31namespace Asylum {
32
33#define SAVEGAME_COUNT 25
34
35class AsylumEngine;
36
37class Savegame {
38public:
39 Savegame(AsylumEngine *engine);
40 ~Savegame() {};
41
47 bool hasSavegames() const;
48
52 void loadList();
53
57 void load();
58
64 bool quickLoad();
65
71 void save();
72
78 bool quickSave();
79
83 void remove();
84
91
93 // Static methods
95
102 static void seek(Common::InSaveFile *file, uint32 offset, const Common::String &description);
103
112 static uint32 read(Common::InSaveFile *file, const Common::String &description);
113
123 static Common::String read(Common::InSaveFile *file, uint32 strLength, const Common::String &description);
124
134 static void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
135
143 static void write(Common::OutSaveFile *file, uint32 val, const Common::String &description);
144
153 static void write(Common::OutSaveFile *file, const Common::String &val, uint32 strLength, const Common::String &description);
154
164 static void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
165
167 // Movies
169 void setMovieViewed(uint32 index);
170 uint32 getMoviesViewed(int32 *movieList) const;
171 void loadMoviesViewed();
172
174 // Accessors
176 void setName(uint32 index, const Common::String &name);
177 Common::String getName(uint32 index) const;
178
179 Common::String *getName() { return &_names[_index]; }
180 void setIndex(uint32 index) { _index = index; }
181 uint32 getIndex() { return _index; }
182
183 bool hasSavegame(uint32 index) const;
184 ResourcePackId getScenePack() { return (ResourcePackId)(_savegameToScene[_index] + 4); }
185
186 void resetVersion();
187 const char *getVersion() { return _version.c_str(); }
188 uint32 getBuild() { return _build; }
189
190private:
191 AsylumEngine *_vm;
192
193 uint32 _index;
194 byte _moviesViewed[196];
195 uint32 _savegameToScene[SAVEGAME_COUNT];
196 bool _savegames[SAVEGAME_COUNT];
197 Common::String _names[SAVEGAME_COUNT];
198 Common::String _version;
199 uint32 _build;
200
202 // Helpers
204
205
213 Common::String getFilename(uint32 index) const;
214
222 bool isSavegamePresent(const Common::String &filename) const;
223
225 // Reading & writing
227
235 bool readHeader(Common::InSaveFile *file);
236
242 void writeHeader(Common::OutSaveFile *file) const;
243
249 void loadData(const Common::String &filename);
250
258 void saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter);
259};
260
261} // End of namespace Asylum
262
263#endif // ASYLUM_SYSTEM_SAVEGAME_H
Definition: asylum.h:73
Definition: savegame.h:37
static uint32 read(Common::InSaveFile *file, const Common::String &description)
static void write(Common::OutSaveFile *file, uint32 val, const Common::String &description)
static void write(Common::OutSaveFile *file, const Common::String &val, uint32 strLength, const Common::String &description)
static void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description)
static void seek(Common::InSaveFile *file, uint32 offset, const Common::String &description)
bool hasSavegames() const
static void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description)
static Common::String read(Common::InSaveFile *file, uint32 strLength, const Common::String &description)
Definition: savefile.h:54
Definition: stream.h:745
Definition: serializer.h:352
Definition: str.h:59