ScummVM API documentation
resource_intern.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 SCI_RESOURCE_RESOURCE_INTERN_H
23 #define SCI_RESOURCE_RESOURCE_INTERN_H
24 
25 #include "sci/resource/resource.h"
26 
27 namespace Common {
28 class MacResManager;
29 }
30 
31 namespace Sci {
32 
45 };
46 
47 
49 protected:
50  const ResSourceType _sourceType;
51  const Common::Path _name;
52 
53 public:
54  bool _scanned;
55  const Common::FSNode * const _resourceFile;
56  const int _volumeNumber;
57 
58 protected:
59  ResourceSource(ResSourceType type, const Common::Path &name, int volNum = 0, const Common::FSNode *resFile = 0);
60 public:
61  virtual ~ResourceSource();
62 
63  ResSourceType getSourceType() const { return _sourceType; }
64  const Common::Path &getLocationName() const { return _name; }
65 
66  // Auxiliary method, used by loadResource implementations.
67  Common::SeekableReadStream *getVolumeFile(ResourceManager *resMan, Resource *res);
68 
72  virtual ResourceSource *findVolume(ResourceSource *map, int volNum) {
73  return NULL;
74  }
75 
79  virtual void scanSource(ResourceManager *resMan) {}
80 
84  virtual void loadResource(ResourceManager *resMan, Resource *res);
85 
86  // FIXME: This audio specific method is a hack. After all, why should a
87  // ResourceSource or a Resource (which uses this method) have audio
88  // specific methods? But for now we keep this, as it eases transition.
89  virtual uint32 getAudioCompressionType() const { return 0; }
90 };
91 
93 public:
95 
96  void scanSource(ResourceManager *resMan) override;
97 };
98 
100 public:
102 
103  void loadResource(ResourceManager *resMan, Resource *res) override;
104 };
105 
107 protected:
108  ResourceSource * const _associatedMap;
109 
110 public:
111  VolumeResourceSource(const Common::Path &name, ResourceSource *map, int volNum, ResSourceType type = kSourceVolume)
112  : ResourceSource(type, name, volNum), _associatedMap(map) {
113  }
114 
115  VolumeResourceSource(const Common::Path &name, ResourceSource *map, int volNum, const Common::FSNode *resFile)
116  : ResourceSource(kSourceVolume, name, volNum, resFile), _associatedMap(map) {
117  }
118 
119  ResourceSource *findVolume(ResourceSource *map, int volNum) override {
120  if (_associatedMap == map && _volumeNumber == volNum)
121  return this;
122  return NULL;
123  }
124 };
125 
127 public:
128  ExtMapResourceSource(const Common::Path &name, int volNum, const Common::FSNode *resFile = 0)
129  : ResourceSource(kSourceExtMap, name, volNum, resFile) {
130  }
131 
132  void scanSource(ResourceManager *resMan) override;
133 };
134 
136 public:
137  uint16 _mapNumber;
138  IntMapResourceSource(const Common::Path &name, int volNum, int mapNum)
139  : ResourceSource(kSourceIntMap, name, volNum), _mapNumber(mapNum) {
140  }
141 
142  void scanSource(ResourceManager *resMan) override;
143 };
144 
146 protected:
148  uint32 offset;
149  uint32 size;
150  };
151 
152  uint32 _audioCompressionType;
154 
155 public:
156  AudioVolumeResourceSource(ResourceManager *resMan, const Common::Path &name, ResourceSource *map, int volNum);
157 
158  void loadResource(ResourceManager *resMan, Resource *res) override;
159 
160  uint32 getAudioCompressionType() const override;
161 
162  bool relocateMapOffset(uint32 &offset, uint32 &size) const {
163  if (_audioCompressionType == 0) {
164  return true;
165  }
166 
167  if (!_compressedOffsets.contains(offset)) {
168  return false;
169  }
170 
171  const CompressedTableEntry &entry = _compressedOffsets.getVal(offset);
172  offset = entry.offset;
173  size = entry.size;
174  return true;
175  }
176 };
177 
179 public:
180  ExtAudioMapResourceSource(const Common::Path &name, int volNum)
181  : ResourceSource(kSourceExtAudioMap, name, volNum) {
182  }
183 
184  void scanSource(ResourceManager *resMan) override;
185 };
186 
188 public:
190 
191  void loadResource(ResourceManager *resMan, Resource *res) override;
192 };
193 
198 public:
199  MacResourceForkResourceSource(const Common::Path &name, int volNum);
200  ~MacResourceForkResourceSource() override;
201 
202  void scanSource(ResourceManager *resMan) override;
203 
204  void loadResource(ResourceManager *resMan, Resource *res) override;
205 
206 protected:
207  Common::MacResManager *_macResMan;
208 
209  bool isCompressableResource(ResourceType type) const;
210  void decompressResource(Common::SeekableReadStream *stream, Resource *resource) const;
211 };
212 
213 #ifdef ENABLE_SCI32
214 
218 class ChunkResourceSource : public ResourceSource {
219 public:
220  ChunkResourceSource(const Common::Path &name, uint16 number);
221 
222  void scanSource(ResourceManager *resMan) override;
223  void loadResource(ResourceManager *resMan, Resource *res) override;
224 
225  uint16 getNumber() const { return _number; }
226 
227 protected:
228  uint16 _number;
229 
230  struct ResourceEntry {
231  uint32 offset;
232  uint32 length;
233  };
234 
236 };
237 
238 #endif
239 
240 } // End of namespace Sci
241 
242 #endif // SCI_RESOURCE_RESOURCE_INTERN_H
Definition: macresman.h:125
SCI1.1 and later audio resource maps.
Definition: resource_intern.h:38
Non-audio resource maps.
Definition: resource_intern.h:37
Val & getVal(const Key &key)
Definition: hashmap.h:631
Built-in resource patcher.
Definition: resource_intern.h:44
virtual ResourceSource * findVolume(ResourceSource *map, int volNum)
Definition: resource_intern.h:72
Definition: path.h:52
Definition: resource_intern.h:92
Definition: stream.h:745
ResourceSource * findVolume(ResourceSource *map, int volNum) override
Definition: resource_intern.h:119
ResSourceType
Definition: resource_intern.h:33
Directories containing game resources/patches.
Definition: resource_intern.h:34
Definition: resource_intern.h:106
Definition: resource.h:327
Definition: resource_intern.h:178
Definition: resource_intern.h:99
External WAVE files, patched in as sound resources.
Definition: resource_intern.h:41
Definition: resource_intern.h:197
Definition: resource_intern.h:135
Definition: hashmap.h:85
Definition: resource_intern.h:126
Mac SCI1.1 and later resource forks.
Definition: resource_intern.h:42
Definition: algorithm.h:29
Definition: fs.h:69
Definition: resource.h:256
Definition: console.h:28
virtual void scanSource(ResourceManager *resMan)
Definition: resource_intern.h:79
bool contains(const Key &key) const
Definition: hashmap.h:592
Definition: resource_intern.h:145
Definition: resource_intern.h:187
Game resources (resource.* or ressci.*)
Definition: resource_intern.h:36
External resource patches.
Definition: resource_intern.h:35
Definition: resource_intern.h:48
Script chunk resources (*.chk)
Definition: resource_intern.h:43
Audio resources - resource.sfx / resource.aud.
Definition: resource_intern.h:39
SCI1 audio resource maps.
Definition: resource_intern.h:40
Definition: resource_intern.h:147