ScummVM API documentation
resourceManager.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 RESOURCE_MANAGER_H
23#define RESOURCE_MANAGER_H
24
25#include "common/archive.h"
26#include "common/file.h"
27#include "common/hash-str.h"
28#include "common/hashmap.h"
29#include "common/ptr.h"
30#include "common/scummsys.h"
31#include "common/str.h"
32
33namespace Graphics {
34struct Surface;
35struct PixelFormat;
36} // namespace Graphics
37
38namespace AGDS {
39
41private:
42 class GrpFile;
43 class ArchiveMember : public Common::ArchiveMember {
44 GrpFile *_parent;
45 Common::String _name;
46 uint32 _offset;
47 uint32 _size;
48
49 public:
50 ArchiveMember(GrpFile *parent, const Common::String &name, uint32 offset, uint32 size) : _parent(parent), _name(name), _offset(offset), _size(size) {
51 }
52 Common::SeekableReadStream *createReadStream() const override;
53 Common::String getName() const override {
54 return getFileName();
55 }
56 Common::Path getPathInArchive() const override {
57 return Common::Path{_name};
58 }
59 Common::String getFileName() const override {
60 return _name;
61 }
62 Common::SeekableReadStream *createReadStreamForAltStream(Common::AltStreamType altStreamType) const override {
63 return nullptr;
64 }
65 };
67
68 class GrpFile : public Common::Archive {
69 Common::File _file;
70 bool _encrypted;
71
73 MembersType _members;
74
75 public:
76 bool load(const Common::Path &path);
77
78 Common::SeekableReadStream &getArchiveStream() {
79 return _file;
80 }
81
82 bool hasFile(const Common::Path &name) const override;
83 int listMembers(Common::ArchiveMemberList &list) const override;
84 const Common::ArchiveMemberPtr getMember(const Common::Path &name) const override;
85 Common::SeekableReadStream *createReadStreamForMember(const Common::Path &name) const override;
86 };
87
88 static void decrypt(uint8 *data, unsigned size);
89
90 int _version;
91
92public:
93 ResourceManager(int version);
95
96 static bool IsBMP(Common::SeekableReadStream &stream);
97
98 bool addPath(const Common::Path &grpFilename);
99
100 Common::SeekableReadStream *getResource(const Common::String &name) const;
101 Graphics::Surface *loadPicture(const Common::String &name, const Graphics::PixelFormat &format);
102
103 Common::String loadText(Common::SeekableReadStream &stream) const;
104 Common::String loadText(const Common::String &name) const;
105};
106
107Common::String readString(Common::ReadStream &stream, uint size = 32);
108void writeString(Common::WriteStream &stream, const Common::String &string, uint size = 32);
109
110} // End of namespace AGDS
111
112#endif /* AGDS_RESOURCE_MANAGER_H */
Definition: resourceManager.h:40
Definition: archive.h:141
Definition: archive.h:68
Definition: file.h:47
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:385
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: formatinfo.h:28
Definition: pixelformat.h:138
Definition: surface.h:67