ScummVM API documentation
cif.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 NANCY_CIF_H
23 #define NANCY_CIF_H
24 
25 #include "common/archive.h"
26 #include "common/rect.h"
27 #include "common/hashmap.h"
28 
29 namespace Common {
30 class SeekableReadStream;
31 class Serializer;
32 }
33 
34 namespace Nancy {
35 
36 struct CifInfo {
37  enum ResType : byte {
38  kResTypeAny,
39  // Type 1 seems to be obsolete
40  kResTypeImage = 2,
41  kResTypeScript = 3,
42  kResTypeEmpty = 4
43  };
44 
45  enum ResCompression {
46  kResCompressionNone = 1,
47  kResCompression = 2
48  };
49 
50  Common::Path name;
51  ResType type = kResTypeEmpty; // ResType
52  ResCompression comp = kResCompressionNone; // ResCompression
53  uint16 width = 0, pitch = 0, height = 0;
54  byte depth = 0; // Bit depth
55  uint32 compressedSize = 0, size = 0;
56  Common::Rect src, dest; // Used when drawing conversation cels
57 
58  uint32 dataOffset;
59 };
60 
61 // Wrapper for a single file. Exclusively used for scene IFFs, though it can contain anything.
62 class CifFile {
63 private:
64 friend class ResourceManager;
65  CifFile() : _stream(nullptr) {}
66 public:
67  CifFile(Common::SeekableReadStream *stream, const Common::Path &name);
68  ~CifFile();
69 
70  Common::SeekableReadStream *createReadStream() const;
71 
72 private:
73  bool sync(Common::Serializer &ser);
74  Common::SeekableReadStream *createReadStreamRaw() const;
75 
77  CifInfo _info;
78 };
79 
80 // Container type comprising of multiple CIF files. Contrary to its name it contains no tree structure.
81 class CifTree : public Common::Archive {
82 protected:
83 friend class ResourceManager;
84  CifTree() : _stream(nullptr) {}
85  CifTree(Common::SeekableReadStream *stream, const Common::Path &name);
86  virtual ~CifTree();
87 
88 public:
89  // Used for extracting additional image data for conversation cels (nancy2 and up)
90  const CifInfo &getCifInfo(const Common::Path &name) const;
91 
92  // Archive interface
93  bool hasFile(const Common::Path &path) const override;
94  int listMembers(Common::ArchiveMemberList &list) const override;
95 
96  const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
97  Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
98 
99  Common::Path getName() const { return _name; }
100 
101  static CifTree *makeCifTreeArchive(const Common::String &name, const Common::String &ext);
102 
103 private:
104  bool sync(Common::Serializer &ser);
105  Common::SeekableReadStream *createReadStreamRaw(const Common::Path &path) const;
106 
107  Common::Path _name;
110  Common::Array<CifInfo> _writeFileMap;
111 };
112 
113 // Ciftree that only provides a file if a certain ConfMan flag is true. Used for handling game patches
114 class PatchTree : public CifTree {
115 public:
116  PatchTree(Common::SeekableReadStream *stream, const Common::Path &name) : CifTree(stream, name) {}
117  virtual ~PatchTree() {}
118 
119  bool hasFile(const Common::Path &path) const override;
120 
122 };
123 
124 } // End of namespace Nancy
125 
126 #endif // NANCY_CIF_H
Definition: str.h:59
Definition: cif.h:62
Definition: array.h:52
Definition: list.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: cif.h:114
Definition: stream.h:745
Definition: serializer.h:79
Definition: archive.h:141
Definition: hashmap.h:85
Definition: cif.h:81
Definition: algorithm.h:29
Definition: resource.h:36
Definition: cif.h:36
Definition: actionmanager.h:32