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