ScummVM API documentation
resource.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 #include "common/scummsys.h"
23 #include "common/endian.h"
24 #include "common/hashmap.h"
25 #include "common/file.h"
26 #include "common/str.h"
27 
28 #ifndef COMPOSER_RESOURCE_H
29 #define COMPOSER_RESOURCE_H
30 
31 namespace Composer {
32 
33 struct Animation;
34 
35 #define ID_LBRC MKTAG('L','B','R','C') // Main FourCC
36 
37 #define ID_ACEL MKTAG('A','C','E','L') // Keyboard Accelerator (v1)
38 #define ID_AMBI MKTAG('A','M','B','I') // Ambient (v1 sprite button)
39 #define ID_ANIM MKTAG('A','N','I','M') // Animation
40 #define ID_BMAP MKTAG('B','M','A','P') // Bitmap
41 #define ID_BUTN MKTAG('B','U','T','N') // Button
42 #define ID_CTBL MKTAG('C','T','B','L') // Color Table
43 #define ID_EVNT MKTAG('E','V','N','T') // Event
44 #define ID_PIPE MKTAG('P','I','P','E') // Pipe
45 #define ID_RAND MKTAG('R','A','N','D') // Random Object
46 #define ID_SCRP MKTAG('S','C','R','P') // Script
47 #define ID_VARI MKTAG('V','A','R','I') // Variables
48 #define ID_WAVE MKTAG('W','A','V','E') // Wave
49 
50 #define ID_FRME MKTAG('F','R','M','E') // Frame
51 
52 class Archive {
53 public:
54  Archive();
55  virtual ~Archive();
56 
57  bool openFile(const Common::Path &fileName);
58  virtual bool openStream(Common::SeekableReadStream *stream) = 0;
59  void close();
60 
61  bool isOpen() const { return _stream != 0; }
62 
63  bool hasResource(uint32 tag, uint16 id) const;
64  bool hasResource(uint32 tag, const Common::String &resName) const;
65  Common::SeekableReadStream *getResource(uint32 tag, uint16 id);
66  uint32 getResourceFlags(uint32 tag, uint16 id) const;
67  uint32 getOffset(uint32 tag, uint16 id) const;
68  uint16 findResourceID(uint32 tag, const Common::String &resName) const;
69  Common::String getName(uint32 tag, uint16 id) const;
70 
71  Common::Array<uint32> getResourceTypeList() const;
72  Common::Array<uint16> getResourceIDList(uint32 type) const;
73 
74 protected:
76 
77  struct Resource {
78  uint32 offset;
79  uint32 size;
80  Common::String name;
81  uint32 flags;
82  };
83 
86  TypeMap _types;
87 };
88 
89 class ComposerArchive : public Archive {
90 public:
91  ComposerArchive() : Archive() {}
92  ~ComposerArchive() override {}
93 
94  bool openStream(Common::SeekableReadStream *stream) override;
95 };
96 
98  uint32 size;
99  uint32 offset;
100 };
101 
102 struct PipeResource {
104 };
105 
106 class Pipe {
107 public:
108  Pipe(Common::SeekableReadStream *stream, uint16 id);
109  virtual ~Pipe();
110  virtual void nextFrame();
111 
112  Animation *_anim;
113 
114  bool hasResource(uint32 tag, uint16 id) const;
115  Common::SeekableReadStream *getResource(uint32 tag, uint16 id, bool buffering);
116 
117  virtual const Common::Array<uint16> *getScripts() { return NULL; }
118  uint16 getPipeId() const { return _pipeId; }
119  virtual uint32 getOffset() const { return _offset; }
120  virtual void setOffset(uint32 offset) { while (_offset < offset) nextFrame(); }
122  DelMap _bufferedResources;
123 
124 protected:
126 
129  TypeMap _types;
130  uint16 _pipeId;
131 
132  uint32 _offset;
133 };
134 
135 class OldPipe : public Pipe {
136 public:
137  OldPipe(Common::SeekableReadStream *stream, uint16 pipeId);
138  void nextFrame() override;
139 
140  const Common::Array<uint16> *getScripts() override { return &_scripts; }
141  uint32 getOffset() const override { return _currFrame; }
142  void setOffset(uint32 offset) override { while (_currFrame < offset) nextFrame(); }
143 
144 protected:
145  uint32 _currFrame, _numFrames;
146  Common::Array<uint16> _scripts;
147 };
148 
149 } // End of namespace Composer
150 
151 #endif
Definition: str.h:59
Definition: graphics.h:50
Definition: path.h:52
Definition: stream.h:745
Definition: resource.h:77
Definition: resource.h:97
Definition: resource.h:52
Definition: hashmap.h:85
Definition: resource.h:106
Definition: resource.h:102
Definition: composer.h:52
Definition: resource.h:89
Definition: resource.h:135