ScummVM API documentation
save_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 #ifndef ZVISION_SAVE_MANAGER_H
23 #define ZVISION_SAVE_MANAGER_H
24 
25 #include "common/savefile.h"
26 #include "common/memstream.h"
27 
28 namespace Common {
29 class String;
30 }
31 
32 namespace Graphics {
33 struct Surface;
34 }
35 
36 namespace ZVision {
37 
38 class ZVision;
39 
41  byte version;
42  Common::String saveName;
43  Graphics::Surface *thumbnail;
44  int16 saveYear, saveMonth, saveDay;
45  int16 saveHour, saveMinutes;
46  uint32 playTime;
47 };
48 
49 class SaveManager {
50 public:
51  SaveManager(ZVision *engine) : _engine(engine), _tempSave(NULL), _tempThumbnail(NULL), _lastSaveTime(0) {}
52  ~SaveManager() {
53  flushSaveBuffer();
54  }
55 
56  uint32 getLastSaveTime() const {
57  return _lastSaveTime;
58  }
59 
60 private:
61  ZVision *_engine;
62  uint32 _lastSaveTime;
63  static const uint32 SAVEGAME_ID;
64 
65  enum {
66  SAVE_ORIGINAL = 0,
67  SAVE_VERSION = 2
68  };
69 
70  Common::MemoryWriteStreamDynamic *_tempThumbnail;
72 
73 public:
82  void saveGame(uint slot, const Common::String &saveName, bool useSaveBuffer);
89  Common::Error loadGame(int slot);
90 
91  Common::SeekableReadStream *getSlotFile(uint slot);
92  bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header, bool skipThumbnail = true);
93 
94  void prepareSaveBuffer();
95  void flushSaveBuffer();
96  bool scummVMSaveLoadDialog(bool isSave);
97 private:
98  void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName, bool useSaveBuffer);
99 };
100 
101 } // End of namespace ZVision
102 
103 #endif
Definition: str.h:59
Definition: surface.h:67
Definition: save_manager.h:40
Definition: savefile.h:54
Definition: error.h:84
Definition: memstream.h:194
Definition: stream.h:745
Definition: clock.h:29
Definition: algorithm.h:29
Definition: formatinfo.h:28
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: save_manager.h:49