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
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 #ifndef ENGINES_SAVESTATE_H
24 #define ENGINES_SAVESTATE_H
25 
26 #include "common/array.h"
27 #include "common/str.h"
28 #include "common/ustr.h"
29 #include "common/ptr.h"
30 
31 namespace Graphics {
32 struct Surface;
33 }
34 
56 private:
57  enum SaveType {
58  kSaveTypeUndetermined,
59  kSaveTypeRegular,
60  kSaveTypeAutosave
61  };
62 public:
64  SaveStateDescriptor(int s, const Common::U32String &d);
65  SaveStateDescriptor(int s, const Common::String &d);
66 
70  void setSaveSlot(int slot) { _slot = slot; }
71 
75  int getSaveSlot() const { return _slot; }
76 
80  void setDescription(const Common::String &desc) { _description = desc.decode(); }
81  void setDescription(const Common::U32String &desc) { _description = desc; }
82 
86  const Common::U32String &getDescription() const { return _description; }
87 
93  void setDeletableFlag(bool state) { _isDeletable = state; }
94 
98  bool getDeletableFlag() const { return _isDeletable; }
99 
103  void setWriteProtectedFlag(bool state) { _isWriteProtected = state; }
104 
108  bool getWriteProtectedFlag() const { return _isWriteProtected; }
109 
113  void setLocked(bool state) {
114  _isLocked = state;
115 
116  //just in case:
117  if (state) {
118  setDeletableFlag(false);
119  setWriteProtectedFlag(true);
120  }
121  }
122 
126  bool getLocked() const { return _isLocked; }
127 
134  const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); }
135 
141  void setThumbnail(Graphics::Surface *t);
142  void setThumbnail(Common::SharedPtr<Graphics::Surface> t) { _thumbnail = t; }
143 
151  void setSaveDate(int year, int month, int day);
152 
158  const Common::String &getSaveDate() const { return _saveDate; }
159 
166  void setSaveTime(int hour, int min);
167 
173  const Common::String &getSaveTime() const { return _saveTime; }
174 
181  void setPlayTime(int hours, int minutes);
182 
188  void setPlayTime(uint32 msecs);
189 
196  const Common::String &getPlayTime() const { return _playTime; }
197 
204  uint32 getPlayTimeMSecs() const { return _playTimeMSecs; }
205 
209  void setAutosave(bool autosave);
210 
214  bool isAutosave() const;
215 private:
219  int _slot;
220 
224  Common::U32String _description;
225 
229  bool _isDeletable;
230 
234  bool _isWriteProtected;
235 
239  bool _isLocked;
240 
244  Common::String _saveDate;
245 
249  Common::String _saveTime;
250 
255  Common::String _playTime;
256 
261  uint32 _playTimeMSecs;
262 
266  Common::SharedPtr<Graphics::Surface> _thumbnail;
267 
271  SaveType _saveType;
272 };
273 
275 typedef Common::Array<SaveStateDescriptor> SaveStateList;
276 
281  bool operator()(const SaveStateDescriptor &x, const SaveStateDescriptor &y) const {
282  return x.getSaveSlot() < y.getSaveSlot();
283  }
284 };
286 #endif
void setSaveSlot(int slot)
Definition: savestate.h:70
Common::Array< SaveStateDescriptor > SaveStateList
Definition: savestate.h:275
bool getLocked() const
Definition: savestate.h:126
void setDeletableFlag(bool state)
Definition: savestate.h:93
const Common::U32String & getDescription() const
Definition: savestate.h:86
uint32 getPlayTimeMSecs() const
Definition: savestate.h:204
bool getWriteProtectedFlag() const
Definition: savestate.h:108
bool getDeletableFlag() const
Definition: savestate.h:98
Definition: savestate.h:55
Definition: savestate.h:280
void setWriteProtectedFlag(bool state)
Definition: savestate.h:103
void setLocked(bool state)
Definition: savestate.h:113
Definition: metaengine.h:48
const Common::String & getSaveTime() const
Definition: savestate.h:173
int getSaveSlot() const
Definition: savestate.h:75
const Common::String & getSaveDate() const
Definition: savestate.h:158
void setDescription(const Common::String &desc)
Definition: savestate.h:80
const Common::String & getPlayTime() const
Definition: savestate.h:196
const Graphics::Surface * getThumbnail() const
Definition: savestate.h:134