ScummVM API documentation
saveload.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 SHERLOCK_SAVELOAD_H
23 #define SHERLOCK_SAVELOAD_H
24 
25 #include "common/scummsys.h"
26 #include "common/savefile.h"
27 #include "common/serializer.h"
28 #include "common/str-array.h"
29 #include "engines/savestate.h"
30 #include "graphics/surface.h"
31 
32 namespace Sherlock {
33 
34 #define MAX_SAVEGAME_SLOTS 99
35 #define ONSCREEN_FILES_COUNT 5
36 
37 enum {
38  CURRENT_SAVEGAME_VERSION = 6,
39  MINIMUM_SAVEGAME_VERSION = 4
40 };
41 
42 enum SaveMode { SAVEMODE_NONE = 0, SAVEMODE_LOAD = 1, SAVEMODE_SAVE = 2 };
43 
44 extern const char *const EMPTY_SAVEGAME_SLOT;
45 
47  uint8 _version;
48  Common::String _saveName;
49  Graphics::Surface *_thumbnail;
50  int _year, _month, _day;
51  int _hour, _minute;
52  int _totalFrames;
53 };
54 
55 class SherlockEngine;
56 
58 
59 class SaveManager {
60 protected:
61  SherlockEngine *_vm;
62  Common::String _target;
63  Graphics::Surface *_saveThumb;
64 
68  void createSavegameList();
69 
73  void synchronize(Serializer &s);
74 public:
75  Common::StringArray _savegames;
76  int _savegameIndex;
77  bool _justLoaded;
78 public:
79  static SaveManager *init(SherlockEngine *vm, const Common::String &target);
80  SaveManager(SherlockEngine *vm, const Common::String &target);
81  virtual ~SaveManager();
82 
86  void createThumbnail();
87 
91  static SaveStateList getSavegameList(const MetaEngine *metaEngine, const Common::String &target);
92 
97  Common::String generateSaveName(int slot);
98 
102  void writeSavegameHeader(Common::OutSaveFile *out, SherlockSavegameHeader &header);
103 
107  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, SherlockSavegameHeader &header, bool skipThumbnail = true);
108 
112  int getHighlightedButton() const;
113 
117  void highlightButtons(int btnIndex);
118 
122  void loadGame(int slot);
123 
127  void saveGame(int slot, const Common::String &name);
128 
132  bool isSlotEmpty(int slot) const;
133 };
134 
135 } // End of namespace Sherlock
136 
137 #endif
Definition: metaengine.h:200
Definition: str.h:59
Definition: surface.h:66
Definition: savefile.h:54
Definition: animation.h:29
Definition: saveload.h:46
Definition: stream.h:745
Definition: saveload.h:59
Definition: serializer.h:79
Definition: sherlock.h:76
bool createThumbnail(Graphics::Surface &thumb)
bool skipThumbnail(Common::SeekableReadStream &in)