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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * This file is based on WME Lite. 25 * http://dead-code.org/redir.php?target=wmelite 26 * Copyright (c) 2011 Jan Nedoma 27 */ 28 29 #ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H 30 #define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H 31 32 33 #include "engines/wintermute/dctypes.h" 34 #include "engines/wintermute/math/rect32.h" 35 #include "engines/savestate.h" 36 #include "common/stream.h" 37 #include "common/str.h" 38 #include "common/system.h" 39 #include "common/rect.h" 40 41 #ifdef ENABLE_WME3D 42 namespace Math { 43 44 class Angle; 45 template<int rows, int cols> class Matrix; 46 typedef Matrix<4, 4> Matrix4; 47 typedef Matrix<3, 1> Vector3d; 48 49 } // namespace Math 50 #endif 51 52 namespace Wintermute { 53 54 class Vector2; 55 class BaseGame; 56 class BasePersistenceManager { 57 public: 58 char *_savedDescription; 59 Common::String _savePrefix; 60 Common::String _savedName; 61 bool saveFile(const Common::String &filename); 62 uint32 getDWORD(); 63 void putDWORD(uint32 val); 64 char *getString(); 65 Common::String getStringObj(); 66 void putString(const char *val); 67 float getFloat(); 68 void putFloat(float val); 69 double getDouble(); 70 void putDouble(double val); 71 void cleanup(); 72 void getSaveStateDesc(int slot, SaveStateDescriptor &desc); 73 void deleteSaveSlot(int slot); 74 uint32 getMaxUsedSlot(); 75 bool getSaveExists(int slot); 76 bool initLoad(const Common::String &filename); 77 bool initSave(const Common::String &desc); 78 bool getBytes(byte *buffer, uint32 size); 79 bool putBytes(byte *buffer, uint32 size); 80 uint32 _offset; 81 getIsSaving()82 bool getIsSaving() { return _saving; } getSavedTimestamp()83 TimeDate getSavedTimestamp() { return _savedTimestamp; } 84 85 uint32 _richBufferSize; 86 byte *_richBuffer; 87 88 bool transferPtr(const char *name, void *val); 89 bool transferSint32(const char *name, int32 *val); 90 bool transferUint32(const char *name, uint32 *val); 91 bool transferFloat(const char *name, float *val); 92 bool transferDouble(const char *name, double *val); 93 bool transferBool(const char *name, bool *val); 94 bool transferByte(const char *name, byte *val); 95 bool transferRect32(const char *name, Rect32 *val); 96 bool transferPoint32(const char *name, Point32 *val); 97 bool transferConstChar(const char *name, const char **val); 98 bool transferCharPtr(const char *name, char **val); 99 bool transferString(const char *name, Common::String *val); 100 bool transferVector2(const char *name, Vector2 *val); 101 #ifdef ENABLE_WME3D 102 bool transferVector3d(const char *name, Math::Vector3d *val); 103 bool transferMatrix4(const char *name, Math::Matrix4 *val); 104 bool transferAngle(const char *name, Math::Angle *val); 105 #endif 106 BasePersistenceManager(const Common::String &savePrefix = "", bool deleteSingleton = false); 107 virtual ~BasePersistenceManager(); 108 bool checkVersion(byte verMajor, byte verMinor, byte verBuild); 109 110 uint32 _thumbnailDataSize; 111 byte *_thumbnailData; 112 uint32 _scummVMThumbSize; 113 byte *_scummVMThumbnailData; 114 Common::String getFilenameForSlot(int slot) const; 115 private: 116 bool _deleteSingleton; 117 bool readHeader(const Common::String &filename); 118 TimeDate getTimeDate(); 119 bool putTimeDate(const TimeDate &t); 120 Common::WriteStream *_saveStream; 121 Common::SeekableReadStream *_loadStream; 122 TimeDate _savedTimestamp; 123 uint32 _savedPlayTime; 124 byte _savedVerMajor; 125 byte _savedVerMinor; 126 byte _savedVerBuild; 127 byte _savedExtMajor; 128 byte _savedExtMinor; 129 bool _saving; 130 // Separate from Base, as this class can do SOME operations without a _gameRef. 131 BaseGame *_gameRef; 132 }; 133 134 } // End of namespace Wintermute 135 136 #endif 137