ScummVM API documentation
savefile.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 BLADERUNNER_SAVEFILE_H
23#define BLADERUNNER_SAVEFILE_H
24
25#include "common/array.h"
26#include "common/memstream.h"
27#include "common/savefile.h"
28#include "common/types.h"
29
30#include "graphics/surface.h"
31
32#include "engines/savestate.h"
33
34namespace Common {
35class OutSaveFile;
36class String;
37struct Rect;
38}
39
40namespace BladeRunner {
41
42class Vector2;
43class Vector3;
44class BoundingBox;
45
46
48 uint8 _version;
49 Common::String _name;
50 int _year;
51 int _month;
52 int _day;
53 int _hour;
54 int _minute;
55 uint32 _playTime;
56 Graphics::Surface *_thumbnail;
57};
58
60private:
61 static const uint32 kTag = MKTAG('B', 'R', 'S', 'V');
62 // kVersion: 3 as of Feb 5th 2020 (UTC) - ScummVM development version 2.2.0git
63 // kVersion: 4 as of Apr 17th 2021 - Added full-size thumbnails
64 static const uint32 kVersion = 4;
65
66public:
67 // kVersion
68 // ----------
69 // 2:: max of 32 characters for the saved game name
70 // 3:: max of 41 characters for the saved game name (this matches the original game's setting)
71 static const uint32 kNameLengthV2 = 32;
72 static const uint32 kNameLength = 41;
73 static const uint32 kThumbnailSize = 9600; // 80x60x16bpp
74
75 static SaveStateList list(const MetaEngine *metaEngine, const Common::String &target);
76 static SaveStateDescriptor queryMetaInfos(const MetaEngine *metaEngine, const Common::String &target, int slot);
77
78 static Common::InSaveFile *openForLoading(const Common::String &target, int slot);
79 static Common::OutSaveFile *openForSaving(const Common::String &target, int slot);
80
81 static bool remove(const Common::String &target, int slot);
82
83 static bool readHeader(Common::SeekableReadStream &in, SaveFileHeader &header, bool skipThumbnail = true);
84 static bool writeHeader(Common::WriteStream &out, SaveFileHeader &header);
85
86};
87
89private:
91
92public:
94
95 uint32 write(const void *dataPtr, uint32 dataSize) override { return _s.write(dataPtr, dataSize); }
96 bool flush() override { return _s.flush(); }
97 int64 pos() const override { return _s.pos(); }
98
99 void debug(char *p);
100
101 void padBytes(int count);
102
103 void writeInt(int32 v); // this writes a 4 byte int (uses writeUint32LE)
104 void writeFloat(float v);
105 void writeBool(bool v);
106 void writeStringSz(const Common::String &s, uint sz);
107 void writeVector2(const Vector2 &v);
108 void writeVector3(const Vector3 &v);
109 void writeRect(const Common::Rect &v);
110 void writeBoundingBox(const BoundingBox &v, bool serialized);
111};
112
114private:
116
117public:
119
120 bool eos() const override { return _s.eos(); }
121 uint32 read(void *dataPtr, uint32 dataSize) override { return _s.read(dataPtr, dataSize); }
122 int64 pos() const override { return _s.pos(); }
123 int64 size() const override { return _s.size(); }
124 bool seek(int64 offset, int whence = SEEK_SET) override { return _s.seek(offset, whence); }
125
126 int32 readInt();
127 float readFloat();
128 bool readBool();
129 Common::String readStringSz(uint sz);
130 Vector2 readVector2();
131 Vector3 readVector3();
132 Common::Rect readRect();
133 BoundingBox readBoundingBox(bool serialized);
134};
135
136} // End of namespace BladeRunner
137
138#endif
Definition: boundingbox.h:31
Definition: savefile.h:59
Definition: savefile.h:113
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: savefile.h:121
int64 pos() const override
Definition: savefile.h:122
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: savefile.h:124
int64 size() const override
Definition: savefile.h:123
bool eos() const override
Definition: savefile.h:120
Definition: savefile.h:88
bool flush() override
Definition: savefile.h:96
int64 pos() const override
Definition: savefile.h:97
uint32 write(const void *dataPtr, uint32 dataSize) override
Definition: savefile.h:95
Definition: vector.h:29
Definition: vector.h:47
Definition: savefile.h:54
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: metaengine.h:202
Definition: savestate.h:56
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: algorithm.h:29
Definition: savefile.h:47
Definition: rect.h:536
Definition: surface.h:67