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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ASYLUM_SYSTEM_SAVEGAME_H
#define ASYLUM_SYSTEM_SAVEGAME_H
#include "common/savefile.h"
#include "common/serializer.h"
#include "common/util.h"
#include "asylum/shared.h"
namespace Asylum {
#define SAVEGAME_COUNT 25
class AsylumEngine;
class Savegame {
public:
Savegame(AsylumEngine *engine);
~Savegame() {};
/**
* Checks if saved games are present
*
* @return true if it succeeds, false if it fails.
*/
bool hasSavegames() const;
/**
* Loads the list of saved games.
*/
void loadList();
/**
* Loads a game
*/
void load();
/**
* Quick loads a game
*
* @return true if it succeeds, false if it fails.
*/
bool quickLoad();
/**
* Saves a game
*
* @return true if it succeeds, false if it fails.
*/
void save();
/**
* Quick saves a game
*
* @return true if it succeeds, false if it fails.
*/
bool quickSave();
/**
* Removes a savegame
*/
void remove();
/**
* Checks if a savegame is compatible
*
* @return true if it is, false otherwise.
*/
bool isCompatible();
//////////////////////////////////////////////////////////////////////////
// Static methods
//////////////////////////////////////////////////////////////////////////
/**
* Seeks to a specific place in the file
*
* @param [in,out] file If non-null, the file.
* @param offset Offset index of the info into the file
* @param description The description.
*/
static void seek(Common::InSaveFile *file, uint32 offset, const Common::String &description);
/**
* Reads data from a file.
*
* @param [in,out] file If non-null, the file.
* @param description The description.
*
* @return the value
*/
static uint32 read(Common::InSaveFile *file, const Common::String &description);
/**
* Reads data from a file.
*
* @param [in,out] file If non-null, the file.
* @param strLength Length of the string.
* @param description The description.
*
* @return the string
*/
static Common::String read(Common::InSaveFile *file, uint32 strLength, const Common::String &description);
/**
* Reads data from a file.
*
* @param [in,out] file If non-null, the file.
* @param [in,out] data If non-null, the data.
* @param size The size.
* @param count Number of.
* @param description The description.
*/
static void read(Common::InSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
/**
* Writes data to a file.
*
* @param [in,out] file If non-null, the file.
* @param val The value
* @param description The description.
*/
static void write(Common::OutSaveFile *file, uint32 val, const Common::String &description);
/**
* Writes data to a file.
*
* @param [in,out] file If non-null, the file.
* @param val The string
* @param strLength The size of the string.
* @param description The description.
*/
static void write(Common::OutSaveFile *file, const Common::String &val, uint32 strLength, const Common::String &description);
/**
* Writes data to a file.
*
* @param [in,out] file If non-null, the file.
* @param [in,out] data If non-null, the data.
* @param size The size.
* @param count Number of.
* @param description The description.
*/
static void write(Common::OutSaveFile *file, Common::Serializable *data, uint32 size, uint32 count, const Common::String &description);
//////////////////////////////////////////////////////////////////////////
// Movies
//////////////////////////////////////////////////////////////////////////
void setMovieViewed(uint32 index);
uint32 getMoviesViewed(int32 *movieList) const;
void loadMoviesViewed();
//////////////////////////////////////////////////////////////////////////
// Accessors
//////////////////////////////////////////////////////////////////////////
void setName(uint32 index, const Common::String &name);
Common::String getName(uint32 index) const;
Common::String *getName() { return &_names[_index]; }
void setIndex(uint32 index) { _index = index; }
uint32 getIndex() { return _index; }
bool hasSavegame(uint32 index) const;
ResourcePackId getScenePack() { return (ResourcePackId)(_savegameToScene[_index] + 4); }
void resetVersion();
const char *getVersion() { return _version.c_str(); }
uint32 getBuild() { return _build; }
private:
AsylumEngine *_vm;
uint32 _index;
byte _moviesViewed[196];
uint32 _savegameToScene[SAVEGAME_COUNT];
bool _savegames[SAVEGAME_COUNT];
Common::String _names[SAVEGAME_COUNT];
Common::String _version;
uint32 _build;
//////////////////////////////////////////////////////////////////////////
// Helpers
//////////////////////////////////////////////////////////////////////////
/**
* Gets a filename for a given save index
*
* @param index Zero-based index of the savegame
*
* @return The filename.
*/
Common::String getFilename(uint32 index) const;
/**
* Check if a specific savegame exists
*
* @param filename Filename of the file.
*
* @return true if savegame present, false if not.
*/
bool isSavegamePresent(const Common::String &filename) const;
//////////////////////////////////////////////////////////////////////////
// Reading & writing
//////////////////////////////////////////////////////////////////////////
/**
* Reads a savegame header.
*
* @param [in,out] file If non-null, the file.
*
* @return true if it succeeds, false if it fails.
*/
bool readHeader(Common::InSaveFile *file);
/**
* Writes a savegame header.
*
* @param [in,out] file If non-null, the file.
*/
void writeHeader(Common::OutSaveFile *file) const;
/**
* Loads savegame data
*
* @param filename Filename of the file.
*/
void loadData(const Common::String &filename);
/**
* Save savegame data.
*
* @param filename Filename of the file.
* @param name The name.
* @param chapter The chapter.
*/
void saveData(const Common::String &filename, const Common::String &name, ChapterIndex chapter);
};
} // End of namespace Asylum
#endif // ASYLUM_SYSTEM_SAVEGAME_H
|