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 
30 class MetaEngine;
31 
32 namespace Graphics {
33 struct Surface;
34 }
35 
57 private:
58  enum SaveType {
59  kSaveTypeUndetermined,
60  kSaveTypeRegular,
61  kSaveTypeAutosave
62  };
63 
64  void initSaveSlot(const MetaEngine *metaEngine);
65 public:
67  SaveStateDescriptor(const MetaEngine *metaEngine, int slot, const Common::U32String &d);
68  SaveStateDescriptor(const MetaEngine *metaEngine, int slot, const Common::String &d);
69 
73  void setSaveSlot(int slot) { _slot = slot; }
74 
78  int getSaveSlot() const { return _slot; }
79 
83  void setDescription(const Common::String &desc) { _description = desc.decode(); }
84  void setDescription(const Common::U32String &desc) { _description = desc; }
85 
89  const Common::U32String &getDescription() const { return _description; }
90 
96  void setDeletableFlag(bool state) { _isDeletable = state; }
97 
101  bool getDeletableFlag() const { return _isDeletable; }
102 
106  void setWriteProtectedFlag(bool state) { _isWriteProtected = state; }
107 
111  bool getWriteProtectedFlag() const { return _isWriteProtected; }
112 
116  void setLocked(bool state) {
117  _isLocked = state;
118 
119  //just in case:
120  if (state) {
121  setDeletableFlag(false);
122  setWriteProtectedFlag(true);
123  }
124  }
125 
129  bool getLocked() const { return _isLocked; }
130 
137  const Graphics::Surface *getThumbnail() const { return _thumbnail.get(); }
138 
144  void setThumbnail(Graphics::Surface *t);
145  void setThumbnail(Common::SharedPtr<Graphics::Surface> t) { _thumbnail = t; }
146 
154  void setSaveDate(int year, int month, int day);
155 
161  const Common::String &getSaveDate() const { return _saveDate; }
162 
169  void setSaveTime(int hour, int min);
170 
176  const Common::String &getSaveTime() const { return _saveTime; }
177 
184  void setPlayTime(int hours, int minutes);
185 
191  void setPlayTime(uint32 msecs);
192 
199  const Common::String &getPlayTime() const { return _playTime; }
200 
207  uint32 getPlayTimeMSecs() const { return _playTimeMSecs; }
208 
212  void setAutosave(bool autosave);
213 
217  bool isAutosave() const;
218 
222  bool hasAutosaveName() const;
223 
227  bool isValid() const;
228 private:
232  int _slot;
233 
237  Common::U32String _description;
238 
242  bool _isDeletable;
243 
247  bool _isWriteProtected;
248 
252  bool _isLocked;
253 
257  Common::String _saveDate;
258 
262  Common::String _saveTime;
263 
268  Common::String _playTime;
269 
274  uint32 _playTimeMSecs;
275 
280 
284  SaveType _saveType;
285 };
286 
289 
294  bool operator()(const SaveStateDescriptor &x, const SaveStateDescriptor &y) const {
295  return x.getSaveSlot() < y.getSaveSlot();
296  }
297 };
299 #endif
void setSaveSlot(int slot)
Definition: savestate.h:73
Definition: metaengine.h:196
Definition: str.h:59
Definition: surface.h:67
Common::Array< SaveStateDescriptor > SaveStateList
Definition: savestate.h:288
bool getLocked() const
Definition: savestate.h:129
void setDeletableFlag(bool state)
Definition: savestate.h:96
const Common::U32String & getDescription() const
Definition: savestate.h:89
uint32 getPlayTimeMSecs() const
Definition: savestate.h:207
bool getWriteProtectedFlag() const
Definition: savestate.h:111
bool getDeletableFlag() const
Definition: savestate.h:101
Definition: savestate.h:56
Definition: savestate.h:293
void setWriteProtectedFlag(bool state)
Definition: savestate.h:106
Definition: ustr.h:57
void setLocked(bool state)
Definition: savestate.h:116
Definition: formatinfo.h:28
const Common::String & getSaveTime() const
Definition: savestate.h:176
int getSaveSlot() const
Definition: savestate.h:78
const Common::String & getSaveDate() const
Definition: savestate.h:161
U32String decode(CodePage page=kUtf8) const
void setDescription(const Common::String &desc)
Definition: savestate.h:83
const Common::String & getPlayTime() const
Definition: savestate.h:199
const Graphics::Surface * getThumbnail() const
Definition: savestate.h:137