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  struct Rect;
30  class SeekableReadStreamEndian;
31 }
32 
33 namespace LingoDec {
34  class ChunkResolver;
35  struct ScriptContext;
36 }
37 
38 namespace Director {
39 
40 class Archive;
41 struct CastMemberInfo;
42 class CastMember;
43 class DirectorEngine;
44 class Lingo;
45 struct LingoArchive;
46 struct Resource;
47 class Stxt;
48 class RTE0;
49 class RTE1;
50 class RTE2;
51 class BitmapCastMember;
52 class FilmLoopCastMember;
53 class ScriptCastMember;
54 class ShapeCastMember;
55 class TextCastMember;
56 class PaletteCastMember;
57 class SoundCastMember;
58 
59 typedef Common::HashMap<byte, byte> CharMap;
60 typedef Common::HashMap<uint16, uint16> FontSizeMap;
62  Common::String toFont;
63  bool remapChars;
64  FontSizeMap sizeMap;
65 
66  FontXPlatformInfo() : remapChars(false) {}
67 };
69 
70 struct FontMapEntry {
71  uint16 toFont;
72  bool remapChars;
73  FontSizeMap sizeMap;
74 
75  FontMapEntry() : toFont(0), remapChars(false) {}
76 };
78 
79 #define NUMTILEPATTERNS 8
81  CastMemberID bitmapId;
82  Common::Rect rect;
83 };
84 
85 class Cast {
86 public:
87  Cast(Movie *movie, uint16 castLibID, bool isShared = false, bool isExternal = false, uint16 libResourceId = 1024);
88  ~Cast();
89 
90  void loadArchive();
91  void setArchive(Archive *archive);
92  Archive *getArchive() const { return _castArchive; };
93  Common::String getMacName() const { return _macName; }
94 
95  bool loadConfig();
96  void loadCast();
97  void loadCastDataVWCR(Common::SeekableReadStreamEndian &stream);
98  void loadCastData(Common::SeekableReadStreamEndian &stream, uint16 id, Resource *res);
99  void loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id);
100  void loadCastLibInfo(Common::SeekableReadStreamEndian &stream, uint16 id);
101  void loadLingoContext(Common::SeekableReadStreamEndian &stream);
102  void loadExternalSound(Common::SeekableReadStreamEndian &stream);
103  void loadSord(Common::SeekableReadStreamEndian &stream);
104 
105  int getCastSize();
106  int getCastMaxID();
107  int getNextUnusedID();
108  Common::Rect getCastMemberInitialRect(int castId);
109  void setCastMemberModified(int castId);
110  CastMember *setCastMember(int castId, CastMember *cast);
111  bool duplicateCastMember(CastMember *source, CastMemberInfo *info, int targetId);
112  bool eraseCastMember(int castId);
113  CastMember *getCastMember(int castId, bool load = true);
114  CastMember *getCastMemberByNameAndType(const Common::String &name, CastType type);
115  CastMember *getCastMemberByScriptId(int scriptId);
116  CastMemberInfo *getCastMemberInfo(int castId);
117  const Stxt *getStxt(int castId);
118  Common::String getLinkedPath(int castId);
119  Common::String getVideoPath(int castId);
120  Common::SeekableReadStreamEndian *getResource(uint32 tag, uint16 id);
121  void rebuildCastNameCache();
122 
123  // release all castmember's widget, should be called when we are changing movie.
124  // 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)
125  void releaseCastMemberWidget();
126 
127  void dumpScript(const char *script, ScriptType type, uint16 id);
128 
129  Common::CodePage getFileEncoding();
130  Common::U32String decodeString(const Common::String &str);
131 
132  Common::String formatCastSummary(int castId);
133  PaletteV4 loadPalette(Common::SeekableReadStreamEndian &stream, int id);
134 
135 private:
136  void loadScriptV2(Common::SeekableReadStreamEndian &stream, uint16 id);
137  void loadFontMap(Common::SeekableReadStreamEndian &stream);
138  void loadFontMapV4(Common::SeekableReadStreamEndian &stream);
139  void loadFXmp(Common::SeekableReadStreamEndian &stream);
140  bool readFXmpLine(Common::SeekableReadStreamEndian &stream);
141  void loadVWTL(Common::SeekableReadStreamEndian &stream);
142 
143 public:
144  Archive *_castArchive;
145  uint16 _version;
146  Common::Platform _platform;
147  uint16 _castLibID;
148  uint16 _libResourceId;
149  bool _isExternal;
150 
151  CharMap _macCharsToWin;
152  CharMap _winCharsToMac;
153  FontXPlatformMap _fontXPlatformMap;
154  FontMap _fontMap;
155 
156  bool _isProtected;
157 
163  uint16 _castIDoffset;
164  uint16 _castArrayStart;
165  uint16 _castArrayEnd;
166 
167  Common::Rect _movieRect;
168  uint16 _stageColor;
169  CastMemberID _defaultPalette;
170  int16 _frameRate;
171  TilePatternEntry _tiles[kNumBuiltinTiles];
172 
173  LingoArchive *_lingoArchive;
174 
175  LingoDec::ScriptContext *_lingodec = nullptr;
176  LingoDec::ChunkResolver *_chunkResolver = nullptr;
177 
178 private:
179  DirectorEngine *_vm;
180  Lingo *_lingo;
181  Movie *_movie;
182 
183  bool _isShared;
184  bool _loadMutex;
185  Common::Array<CastMember *> _loadQueue;
186 
187  Common::String _macName;
188 
191  Common::HashMap<uint16, int> _castsScriptIds;
192 };
193 
194 } // End of namespace Director
195 
196 #endif
Definition: cast.h:85
Definition: str.h:59
Definition: lingo.h:298
Definition: array.h:52
Definition: stxt.h:49
Definition: rect.h:144
Definition: cast.h:33
Definition: movie.h:86
Definition: archive.h:35
Definition: cast.h:61
Definition: archive.h:53
Definition: director.h:118
Definition: ustr.h:57
Definition: cast.h:80
Definition: algorithm.h:29
Definition: resolver.h:15
Definition: archive.h:39
Definition: context.h:26
Definition: stream.h:944
Definition: director.h:150
Definition: cast.h:70
Definition: castmember.h:45
Definition: lingo.h:347
Definition: types.h:414
Definition: castmember.h:126
Platform
Definition: platform.h:46