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
23#ifndef SNATCHER_SAVELOAD_H
24#define SNATCHER_SAVELOAD_H
25
26#include "common/ptr.h"
27#include "common/memstream.h"
28#include "common/system.h"
29#include "snatcher/saveflags.h"
30#include "snatcher/state.h"
31
32namespace Common {
33class SeekableReadStream;
34class OutSaveFile;
35}
36
37namespace Graphics {
38struct Surface;
39}
40
41namespace Snatcher {
42
43class SnatcherEngine;
45public:
48
49 void loadSettings(Config &config);
50 void saveSettings(const Config &config);
51 void updateSaveSlotsStatus(GameState &state);
52
53 void requestLoad(int slot);
54 void requestSave(int slot, const Common::String &desc, bool scriptedSave);
55
56 void handleSaveLoad(GameState &state);
57
58 bool isSaveSlotUsed(int16 slot) const;
59 bool canSaveHere() const;
60 void enableSaving(bool enable);
61
62 void saveTempState(Script &script);
63 void restoreTempState(Script &script);
64
65public:
66 struct SaveHeader {
67 SaveHeader() : version(0), lang(0), platform(0), desc(), thumbnail(), totalPlayTime(0), saveCount(0), act(0) {
68 memset(&td, 0, sizeof(TimeDate));
69 }
70 uint32 version;
71 uint32 lang;
72 uint32 platform;
73 Common::String desc;
74 TimeDate td;
76 uint32 totalPlayTime;
77 int16 saveCount;
78 int16 act;
79 };
80
81 static Common::String getSavegameFilename(int slot, Common::String target);
82 static bool readSaveHeader(Common::SeekableReadStream *saveFile, SaveHeader &header);
83
84private:
85 void loadState(int slot, GameState &state);
86 void saveState(int slot, GameState &state, SaveFlags flags);
87 void checkSceneSpecificSaveDataNeed(const GameState &state, SaveFlags &flags);
88
89 Common::SeekableReadStream *openFileForLoading(int slot, GameState &state, SaveHeader &header);
90 Common::OutSaveFile *openFileForSaving(int slot, const Common::String &desc, GameState &state);
91
92 SnatcherEngine *_vm;
93 Common::String _desc;
94 int _pendingSaveLoad;
95 SaveFlags _pendingSaveFlags;
96 bool _tryLoadFromLauncher;
97 bool _enableSaving;
98
100};
101
102} // End of namespace Snatcher
103
104#endif // SNATCHER_SAVELOAD_H
Definition: savefile.h:54
Definition: stream.h:745
Definition: str.h:59
Definition: saveload.h:44
Definition: snatcher.h:50
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: state.h:37
Definition: state.h:94
Definition: saveload.h:66
Definition: state.h:65
Definition: system.h:111