ScummVM API documentation
savestate.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 ENGINES_SAVESTATE_H
23#define ENGINES_SAVESTATE_H
24
25#include "common/array.h"
26#include "common/str.h"
27#include "common/ustr.h"
28#include "common/ptr.h"
29
30class MetaEngine;
31
32namespace Graphics {
33struct Surface;
34}
35
57private:
58 enum SaveType {
59 kSaveTypeUndetermined,
60 kSaveTypeRegular,
61 kSaveTypeAutosave
62 };
63
64 void initSaveSlot(const MetaEngine *metaEngine);
65public:
67 SaveStateDescriptor(const MetaEngine *metaEngine, int slot);
68 SaveStateDescriptor(const MetaEngine *metaEngine, int slot, const Common::String &d);
69 SaveStateDescriptor(const MetaEngine *metaEngine, int slot, const Common::U32String &d);
70
74 void setSaveSlot(int slot) { _slot = slot; }
75
79 int getSaveSlot() const { return _slot; }
80
84 void setDescription(const Common::String &desc) { _description = desc; }
85 void setDescription(const Common::U32String &desc) { _description = desc.encode(); }
86
90 const Common::String &getDescription() const { return _description; }
91
97 void setDeletableFlag(bool state) { _isDeletable = state; }
98
102 bool getDeletableFlag() const { return _isDeletable; }
103
107 void setWriteProtectedFlag(bool state) { _isWriteProtected = state; }
108
112 bool getWriteProtectedFlag() const { return _isWriteProtected; }
113
117 void setLocked(bool state) {
118 _isLocked = state;
119
120 //just in case:
121 if (state) {
122 setDeletableFlag(false);
124 }
125 }
126
130 bool getLocked() const { return _isLocked; }
131
138 const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); }
139
146 void setThumbnail(Common::SharedPtr<Graphics::Surface> t) { _thumbnail = t; }
147
155 void setSaveDate(int year, int month, int day);
156
162 const Common::String &getSaveDate() const { return _saveDate; }
163
170 void setSaveTime(int hour, int min);
171
177 const Common::String &getSaveTime() const { return _saveTime; }
178
185 void setPlayTime(int hours, int minutes);
186
192 void setPlayTime(uint32 msecs);
193
200 const Common::String &getPlayTime() const { return _playTime; }
201
208 uint32 getPlayTimeMSecs() const { return _playTimeMSecs; }
209
213 void setAutosave(bool autosave);
214
218 bool isAutosave() const;
219
223 bool hasAutosaveName() const;
224
228 bool isValid() const;
229private:
233 int _slot;
234
238 Common::String _description;
239
243 bool _isDeletable;
244
248 bool _isWriteProtected;
249
253 bool _isLocked;
254
258 Common::String _saveDate;
259
263 Common::String _saveTime;
264
269 Common::String _playTime;
270
275 uint32 _playTimeMSecs;
276
281
285 SaveType _saveType;
286};
287
290
295 bool operator()(const SaveStateDescriptor &x, const SaveStateDescriptor &y) const {
296 return x.getSaveSlot() < y.getSaveSlot();
297 }
298};
300#endif
PointerType get() const
Definition: ptr.h:229
Definition: str.h:59
Definition: ustr.h:57
String encode(CodePage page=kUtf8) const
Definition: metaengine.h:202
Definition: savestate.h:56
bool getDeletableFlag() const
Definition: savestate.h:102
void setSaveTime(int hour, int min)
bool getLocked() const
Definition: savestate.h:130
uint32 getPlayTimeMSecs() const
Definition: savestate.h:208
void setLocked(bool state)
Definition: savestate.h:117
const Common::String & getPlayTime() const
Definition: savestate.h:200
bool isValid() const
void setAutosave(bool autosave)
void setSaveDate(int year, int month, int day)
const Graphics::Surface * getThumbnail() const
Definition: savestate.h:138
const Common::String & getSaveTime() const
Definition: savestate.h:177
void setPlayTime(uint32 msecs)
int getSaveSlot() const
Definition: savestate.h:79
const Common::String & getSaveDate() const
Definition: savestate.h:162
bool isAutosave() const
void setThumbnail(Graphics::Surface *t)
bool hasAutosaveName() const
void setDescription(const Common::String &desc)
Definition: savestate.h:84
void setSaveSlot(int slot)
Definition: savestate.h:74
const Common::String & getDescription() const
Definition: savestate.h:90
void setDeletableFlag(bool state)
Definition: savestate.h:97
void setPlayTime(int hours, int minutes)
bool getWriteProtectedFlag() const
Definition: savestate.h:112
void setWriteProtectedFlag(bool state)
Definition: savestate.h:107
Common::Array< SaveStateDescriptor > SaveStateList
Definition: savestate.h:289
Definition: formatinfo.h:28
Definition: surface.h:67
Definition: savestate.h:294