ScummVM API documentation
cast.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 DIRECTOR_CAST_H
23 #define DIRECTOR_CAST_H
24 
25 #include "common/hash-str.h"
26 
27 namespace Common {
28  class ReadStreamEndian;
29  class MemoryWriteStream;
30  struct Rect;
31  class SeekableReadStreamEndian;
32 }
33 
34 namespace LingoDec {
35  class ChunkResolver;
36  struct ScriptContext;
37 }
38 
39 namespace Director {
40 
41 class Archive;
42 struct CastMemberInfo;
43 class CastMember;
44 class DirectorEngine;
45 class Lingo;
46 struct LingoArchive;
47 struct Resource;
48 class Stxt;
49 class RTE0;
50 class RTE1;
51 class RTE2;
52 class BitmapCastMember;
53 class FilmLoopCastMember;
54 class ScriptCastMember;
55 class ShapeCastMember;
56 class TextCastMember;
57 class PaletteCastMember;
58 class SoundCastMember;
59 struct ConfigChunk;
60 
61 typedef Common::HashMap<byte, byte> CharMap;
62 typedef Common::HashMap<uint16, uint16> FontSizeMap;
64  Common::String toFont;
65  bool remapChars;
66  FontSizeMap sizeMap;
67 
68  FontXPlatformInfo() : remapChars(false) {}
69 };
71 
72 struct FontMapEntry {
73  uint16 toFont;
74  bool remapChars;
75  FontSizeMap sizeMap;
76 
77  FontMapEntry() : toFont(0), remapChars(false) {}
78 };
80 
81 #define NUMTILEPATTERNS 8
83  CastMemberID bitmapId;
84  Common::Rect rect;
85 };
86 
87 class Cast {
88 public:
89  Cast(Movie *movie, uint16 castLibID, bool isShared = false, bool isExternal = false, uint16 libResourceId = 1024);
90  ~Cast();
91 
92  void loadArchive();
93  void setArchive(Archive *archive);
94  Archive *getArchive() const { return _castArchive; };
95  Common::String getMacName() const { return _macName; }
96  Common::String getCastName() const { return _castName; }
97  void setCastName(const Common::String &name) { _castName = name; }
98 
99  bool loadConfig();
100  void loadCast();
101  void loadCastDataVWCR(Common::SeekableReadStreamEndian &stream);
102  void loadCastData(Common::SeekableReadStreamEndian &stream, uint16 id, Resource *res);
103  void loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id);
104  void loadCastLibInfo(Common::SeekableReadStreamEndian &stream, uint16 id);
105  void loadLingoContext(Common::SeekableReadStreamEndian &stream);
106  void loadExternalSound(Common::SeekableReadStreamEndian &stream);
107  void loadSord(Common::SeekableReadStreamEndian &stream);
108  bool importFileInto(int castId, const Common::Path &path);
109 
110  void saveConfig(Common::SeekableWriteStream *writeStream, uint32 offset);
111  void saveCastData(Common::SeekableWriteStream *writeStream, Resource *res);
112  void saveCastData();
113  void writeCastInfo(Common::SeekableWriteStream *writeStream, uint32 castId);
114  uint32 getCastInfoSize(uint32 castId);
115  uint32 getCastInfoStringLength(uint32 stringIndex, CastMemberInfo *ci);
116 
117  uint32 getConfigSize();
118 
119  int getCastSize();
120  int getCastMaxID();
121  int getNextUnusedID();
122  Common::Rect getCastMemberInitialRect(int castId);
123  void setCastMemberModified(int castId);
124  CastMember *setCastMember(int castId, CastMember *cast);
125  bool duplicateCastMember(CastMember *source, CastMemberInfo *info, int targetId);
126  bool eraseCastMember(int castId);
127  CastMember *getCastMember(int castId, bool load = true);
128  CastMember *getCastMemberByNameAndType(const Common::String &name, CastType type);
129  CastMember *getCastMemberByScriptId(int scriptId);
130  int getCastIdByScriptId(uint32 scriptId) const;
131  CastMemberInfo *getCastMemberInfo(int castId);
132  const Stxt *getStxt(int castId);
133  Common::String getLinkedPath(int castId);
134  Common::String getVideoPath(int castId);
135  Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id);
136  void rebuildCastNameCache();
137 
138  // release all castmember's widget, should be called when we are changing movie.
139  // because widget is handled by channel, thus we should clear all of those run-time info when we are switching the movie. (because we will create new widgets for cast)
140  void releaseCastMemberWidget();
141 
142  void dumpScript(const char *script, ScriptType type, uint16 id);
143 
144  Common::CodePage getFileEncoding();
145  Common::U32String decodeString(const Common::String &str);
146 
147  Common::String formatCastSummary(int castId);
148  PaletteV4 loadPalette(Common::SeekableReadStreamEndian &stream, int id);
149 
150 private:
151  void loadScriptV2(Common::SeekableReadStreamEndian &stream, uint16 id);
152  void loadFontMap(Common::SeekableReadStreamEndian &stream);
153  void loadFontMapV4(Common::SeekableReadStreamEndian &stream);
154  void loadFXmp(Common::SeekableReadStreamEndian &stream);
155  bool readFXmpLine(Common::SeekableReadStreamEndian &stream);
156  void loadVWTL(Common::SeekableReadStreamEndian &stream);
157 
158  uint32 computeChecksum();
159 
160 public:
161  Archive *_castArchive;
162  Common::Platform _platform;
163  uint16 _castLibID;
164  uint16 _libResourceId;
165  bool _isExternal;
166 
167  CharMap _macCharsToWin;
168  CharMap _winCharsToMac;
169  FontXPlatformMap _fontXPlatformMap;
170  FontMap _fontMap;
171 
172  bool _isProtected;
173 
179  uint16 _castIDoffset;
180 
181  Common::Rect _movieRect;
182  TilePatternEntry _tiles[kNumBuiltinTiles];
183 
184  LingoArchive *_lingoArchive;
185 
186  LingoDec::ScriptContext *_lingodec = nullptr;
187  LingoDec::ChunkResolver *_chunkResolver = nullptr;
188 
189  /* Config Data to be saved */
190  /* 0 */ uint16 _len;
191  /* 2 */ uint16 _fileVersion;
192  /* 4, 6, 8, 10 */ Common::Rect _checkRect;
193  /* 12 */ uint16 _castArrayStart;
194  /* 14 */ uint16 _castArrayEnd;
195  /* 16 */ byte _readRate;
196  /* 17 */ byte _lightswitch;
197 
198  // Director 6 and below
199  /* 18 */ int16 _unk1; // Mentioned in ProjectorRays as preD7field11
200 
201  // Director 7 and above
202  // Currently not supporting Director 7
203  // /* 18 */ int8 D7stageColorG;
204  // /* 19 */ int8 D7stageColorB;
205 
206  /* 20 */ uint16 _commentFont;
207  /* 22 */ uint16 _commentSize;
208  /* 24 */ uint16 _commentStyle;
209 
210  // Director 6 and below
211  /* 26 */ uint16 _stageColor;
212  // Director 7 and above
213  // Currently not supporting Director 7
214  // /* 26 */ uint8 D7stageColorIsRGB;
215  // /* 27 */ uint8 D7stageColorR;
216 
217  /* 28 */ uint16 _bitdepth;
218  /* 30 */ uint8 _field17;
219  /* 31 */ uint8 _field18;
220  /* 32 */ int32 _field19;
221  /* 36 */ int16 _version;
222  /* 38 */ int16 _movieDepth;
223  /* 40 */ int32 _field22;
224  /* 44 */ int32 _field23;
225  /* 48 */ int32 _field24;
226  /* 52 */ int8 _field25;
227  /* 53 */ uint8 _field26;
228  /* 54 */ int16 _frameRate;
229  /* 56 */ int16 _platformID;
230  /* 58 */ int16 _protection;
231  /* 60 */ int32 _field29;
232  /* 64 */ uint32 _checksum;
233  /* 68 */ uint16 _field30; // Marked as remnants in ProjectorRays
234  /* 70 */ uint16 _defPaletteNum = 0; // _defaultPalette before D5, unused later
235  /* 72 */ uint32 _chunkBaseNum = 0;
236  /* 76 */ CastMemberID _defaultPalette;
237 
238  /****** D6.0-D8.5 *******/
239  /* 80 */ int8 _netUnk1 = 0;
240  /* 81 */ int8 _netUnk2 = 0;
241  /* 82 */ int16 _netPreloadNumFrames = 0;
242 
243  /****** post D9-D10 *******/
244  /* 84 */ uint32 _windowFlags = 0;
245  /* 88 */ CastMemberID _windowIconId;
246  /* 92 */ CastMemberID _windowMaskId;
247  /* 96 */ CastMemberID _windowDragRegionMaskId;
248 
249  /* 100 */ // End of config
250 
251 private:
252  DirectorEngine *_vm;
253  Lingo *_lingo;
254  Movie *_movie;
255 
256  bool _isShared;
257  bool _loadMutex;
258  Common::Array<CastMember *> _loadQueue;
259 
260  Common::String _macName;
261  Common::String _castName;
262 
265  Common::HashMap<uint16, int> _castsScriptIds;
266 
267 };
268 
269 } // End of namespace Director
270 
271 #endif
Definition: cast.h:87
Definition: str.h:59
Definition: lingo.h:306
Definition: array.h:52
Definition: stxt.h:51
Definition: rect.h:524
Definition: path.h:52
Definition: cast.h:34
Definition: movie.h:88
Definition: archive.h:36
Definition: cast.h:63
Definition: archive.h:75
Definition: director.h:125
Definition: ustr.h:57
Definition: cast.h:82
Definition: algorithm.h:29
Definition: resolver.h:15
Definition: archive.h:40
Definition: stream.h:351
Definition: context.h:26
Definition: stream.h:944
Definition: director.h:157
Definition: cast.h:72
Definition: castmember.h:48
Definition: lingo.h:356
Definition: types.h:419
Definition: castmember.h:163
Platform
Definition: platform.h:93