ScummVM API documentation
savehandler.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 * This file is dual-licensed.
22 * In addition to the GPLv3 license mentioned above, this code is also
23 * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24 * full text of the license.
25 *
26 */
27
28#ifndef GOB_SAVE_SAVEHANDLER_H
29#define GOB_SAVE_SAVEHANDLER_H
30
31#include "common/savefile.h"
32#include "common/array.h"
33
34#include "engines/gob/video.h" // for SurfacePtr
35
36namespace Gob {
37
38class GobEngine;
39class SavePartInfo;
40class SavePartVars;
41class SavePartSprite;
42class SaveConverter;
43
45class SlotFile {
46public:
52 SlotFile(GobEngine *vm, uint32 slotCount, const Common::String &base);
53 virtual ~SlotFile();
54
56 virtual int getSlot(int32 offset) const = 0;
58 virtual int getSlotRemainder(int32 offset) const = 0;
59
60protected:
61 GobEngine *_vm;
62 Common::String _base;
63
64 uint32 _slotCount;
65};
66
68class SlotFileIndexed : public SlotFile {
69public:
70 SlotFileIndexed(GobEngine *vm, uint32 slotCount, const Common::String &base,
71 const Common::String &extStub);
72 ~SlotFileIndexed() override;
73
75 Common::String build(int slot) const;
76
78 virtual uint32 getSlotMax() const;
79
81 virtual int32 tallyUpFiles(uint32 slotSize, uint32 indexSize) const;
82
84 virtual void buildIndex(byte *buffer, SavePartInfo &info,
85 SaveConverter *converter = 0, bool setLongest = false) const;
86
87 virtual bool exists(int slot) const;
88 virtual Common::InSaveFile *openRead(int slot) const;
89 virtual Common::OutSaveFile *openWrite(int slot) const;
90
91protected:
92 Common::String _ext;
93};
94
96class SlotFileStatic : public SlotFile {
97public:
98 SlotFileStatic(GobEngine *vm, const Common::String &base, const Common::String &ext);
99 ~SlotFileStatic() override;
100
101 int getSlot(int32 offset) const override;
102 int getSlotRemainder(int32 offset) const override;
103
106
107 virtual bool exists() const;
108 virtual Common::InSaveFile *openRead() const;
109 virtual Common::OutSaveFile *openWrite() const;
110
111protected:
112 Common::String _ext;
113};
114
117public:
119 virtual ~SaveHandler();
120
122 virtual int32 getSize() = 0;
124 virtual bool load(int16 dataVar, int32 size, int32 offset) = 0;
126 virtual bool save(int16 dataVar, int32 size, int32 offset) = 0;
127
128 virtual bool loadToRaw(byte *ptr, int32 size, int32 offset);
129 virtual bool saveFromRaw(const byte *ptr, int32 size, int32 offset);
130
132 virtual bool deleteFile();
133
134 static uint32 getVarSize(GobEngine *vm);
135
136protected:
137 GobEngine *_vm;
138};
139
142public:
144 ~TempSpriteHandler() override;
145
146 int32 getSize() override;
147 bool load(int16 dataVar, int32 index_as_size, int32 offset) override;
148 bool save(int16 dataVar, int32 index_as_size, int32 offset) override;
149
150 bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
151 bool saveFromRaw(const byte *ptr, int32 size, int32 offset) override;
152
153 bool create(uint32 width, uint32 height, bool trueColor);
154 bool createFromSprite(int32 index_as_size, int32 offset);
155
156protected:
157 SavePartSprite *_sprite;
158
160 static bool isDummy(int32 size);
162 static bool isSprite(int32 size);
164 static int getIndex(int32 size);
166 static bool usesPalette(int32 size);
167
168 SurfacePtr createSprite(int32 index_as_size, int32 offset);
169};
170
172class NotesHandler : public SaveHandler {
173public:
174 NotesHandler(uint32 notesSize, GobEngine *vm, const Common::String &target);
175 ~NotesHandler() override;
176
177 int32 getSize() override;
178 bool load(int16 dataVar, int32 size, int32 offset) override;
179 bool save(int16 dataVar, int32 size, int32 offset) override;
180
181private:
182 class File : public SlotFileStatic {
183 public:
184 File(GobEngine *vm, const Common::String &base);
185 ~File() override;
186 };
187
188 uint32 _notesSize;
189 File *_file;
190 SavePartVars *_notes;
191};
192
195public:
197 ~FakeFileHandler() override;
198
199 int32 getSize() override;
200 bool load(int16 dataVar, int32 size, int32 offset) override;
201 bool save(int16 dataVar, int32 size, int32 offset) override;
202 bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
203 bool saveFromRaw(const byte *ptr, int32 size, int32 offset) override;
204
205 bool deleteFile() override;
206
207private:
209};
210
211} // End of namespace Gob
212
213#endif // GOB_SAVE_SAVEHANDLER_H
Definition: savefile.h:54
Definition: stream.h:745
Definition: str.h:59
Definition: savehandler.h:194
bool deleteFile() override
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
int32 getSize() override
Definition: gob.h:166
Definition: savehandler.h:172
bool load(int16 dataVar, int32 size, int32 offset) override
int32 getSize() override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveconverter.h:43
Definition: savehandler.h:116
virtual bool load(int16 dataVar, int32 size, int32 offset)=0
virtual bool deleteFile()
virtual int32 getSize()=0
virtual bool save(int16 dataVar, int32 size, int32 offset)=0
Definition: savefile.h:200
Definition: savefile.h:162
Definition: savefile.h:130
Definition: savehandler.h:45
virtual int getSlotRemainder(int32 offset) const =0
virtual int getSlot(int32 offset) const =0
SlotFile(GobEngine *vm, uint32 slotCount, const Common::String &base)
Definition: savehandler.h:68
virtual uint32 getSlotMax() const
Common::String build(int slot) const
virtual void buildIndex(byte *buffer, SavePartInfo &info, SaveConverter *converter=0, bool setLongest=false) const
virtual int32 tallyUpFiles(uint32 slotSize, uint32 indexSize) const
Definition: savehandler.h:96
int getSlotRemainder(int32 offset) const override
Common::String build() const
int getSlot(int32 offset) const override
Definition: savehandler.h:141
static bool usesPalette(int32 size)
static bool isSprite(int32 size)
static bool isDummy(int32 size)
int32 getSize() override
static int getIndex(int32 size)
bool load(int16 dataVar, int32 index_as_size, int32 offset) override
bool save(int16 dataVar, int32 index_as_size, int32 offset) override