ScummVM API documentation
archive.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 MYST3_ARCHIVE_H
23 #define MYST3_ARCHIVE_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 
28 #include "math/vector3d.h"
29 
30 namespace Myst3 {
31 
32 class ArchiveVisitor;
33 class ResourceDescription;
34 
35 typedef Common::Array<ResourceDescription> ResourceDescriptionArray;
36 
37 class Archive {
38 public:
39  enum ResourceType {
40  kCubeFace = 0,
41  kWaterEffectMask = 1,
42  kLavaEffectMask = 2,
43  kMagneticEffectMask = 3,
44  kShieldEffectMask = 4,
45  kSpotItem = 5,
46  kFrame = 6,
47  kRawData = 7,
48  kMovie = 8,
49  kStillMovie = 10,
50  kText = 11,
51  kTextMetadata = 12,
52  kNumMetadata = 13,
53  kLocalizedSpotItem = 69,
54  kLocalizedFrame = 70,
55  kMultitrackMovie = 72,
56  kDialogMovie = 74
57  };
58 
60  uint32 offset;
61  uint32 size;
62  byte face;
63  ResourceType type;
64  Common::Array<uint32> metadata;
65 
66  DirectorySubEntry() : offset(0), size(0), face(0), type(kCubeFace) {}
67  };
68 
69  struct DirectoryEntry {
70  Common::String roomName;
71  uint32 index;
73 
74  DirectoryEntry() : index(0) {}
75  };
76 
77  ResourceDescription getDescription(const Common::String &room, uint32 index, uint16 face,
78  ResourceType type);
79  ResourceDescriptionArray listFilesMatching(const Common::String &room, uint32 index, uint16 face,
80  ResourceType type);
81 
82  Common::SeekableReadStream *dumpToMemory(uint32 offset, uint32 size);
83  uint32 copyTo(uint32 offset, uint32 size, Common::WriteStream &out);
84  void visit(ArchiveVisitor &visitor);
85 
86  bool open(const char *fileName, const char *room);
87  void close();
88 
89  const Common::String &getRoomName() const { return _roomName; }
90  uint32 getDirectorySize() const { return _directorySize; }
91 
92 private:
93  Common::String _roomName;
94  Common::File _file;
95  uint32 _directorySize;
97 
98  void decryptHeader(Common::SeekableReadStream &inStream, Common::WriteStream &outStream);
99  void readDirectory();
100  DirectorySubEntry readSubEntry(Common::ReadStream &stream);
101  DirectoryEntry readEntry(Common::ReadStream &stream);
102  const DirectoryEntry *getEntry(const Common::String &room, uint32 index) const;
103 };
104 
106 public:
107  struct SpotItemData {
108  uint32 u;
109  uint32 v;
110  };
111 
112  struct VideoData {
113  Math::Vector3d v1;
114  Math::Vector3d v2;
115  int32 u;
116  int32 v;
117  int32 width;
118  int32 height;
119  };
120 
122  ResourceDescription(Archive *archive, const Archive::DirectorySubEntry &subentry);
123 
124  bool isValid() const { return _archive && _subentry; }
125 
126  Common::SeekableReadStream *getData() const;
127  uint16 getFace() const { return _subentry->face; }
128  Archive::ResourceType getType() const { return _subentry->type; }
129  SpotItemData getSpotItemData() const;
130  VideoData getVideoData() const;
131  uint32 getMiscData(uint index) const;
132  Common::String getTextData(uint index) const;
133 
134 private:
135  Archive *_archive;
136  const Archive::DirectorySubEntry *_subentry;
137 };
138 
140 public:
141  virtual ~ArchiveVisitor();
142 
143  virtual void visitArchive(Archive &archive) {}
144  virtual void visitDirectoryEntry(Archive::DirectoryEntry &directoryEntry) {}
145  virtual void visitDirectorySubEntry(Archive::DirectorySubEntry &directorySubEntry) {}
146 };
147 
148 } // End of namespace Myst3
149 
150 #endif
Definition: str.h:59
Definition: archive.h:37
Definition: stream.h:77
Definition: array.h:52
Definition: ambient.h:27
Definition: archive.h:139
Definition: stream.h:745
Definition: archive.h:112
Definition: file.h:47
Definition: archive.h:69
Definition: archive.h:59
Definition: stream.h:385
Definition: archive.h:105