ScummVM API documentation
movie.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_MOVIE_H
23#define DIRECTOR_MOVIE_H
24
25#define DEFAULT_CAST_LIB 1
26#define SHARED_CAST_LIB -1337
27
28namespace Common {
29struct Event;
30class ReadStreamEndian;
31class SeekableReadStreamEndian;
32class MemoryWriteStream;
33}
34
35namespace Director {
36
37class Archive;
38class Cast;
39struct CastMemberInfo;
40class CastMember;
41class DirectorEngine;
42class Lingo;
43struct LingoArchive;
44struct LingoEvent;
45class ScriptContext;
46class Window;
47struct Symbol;
48
49struct InfoEntry {
50 uint32 len;
51 byte *data;
52
53 InfoEntry() { len = 0; data = nullptr; }
54
55 InfoEntry(const InfoEntry &old) {
56 len = old.len;
57 data = (byte *)malloc(len);
58 memcpy(data, old.data, len);
59 }
60
61 ~InfoEntry() {
62 free(data);
63 data = nullptr;
64 }
65
66 InfoEntry &operator=(const InfoEntry &old) {
67 free(data);
68 len = old.len;
69 data = (byte *)malloc(len);
70 memcpy(data, old.data, len);
71 return *this;
72 }
73
74 Common::String readString(bool pascal = true);
75 void writeString(Common::String string, bool pascal = true);
76};
77
79 uint32 unk1;
80 uint32 unk2;
81 uint32 flags;
82 uint32 scriptId;
84
85 InfoEntries() : unk1(0), unk2(0), flags(0), scriptId(0) {}
86};
87
88class Movie {
89public:
90 Movie(Window *window);
91 ~Movie();
92
93 static Common::Rect readRect(Common::ReadStreamEndian &stream);
94 static InfoEntries loadInfoEntries(Common::SeekableReadStreamEndian &stream, uint16 version);
95 static void saveInfoEntries(Common::SeekableWriteStream *writeStream, InfoEntries info);
96
97 static void writeRect(Common::WriteStream *writeStream, Common::Rect rect);
98
99 void loadCastLibMapping(Common::SeekableReadStreamEndian &stream);
100 bool loadArchive();
101 void setArchive(Common::SharedPtr<Archive> archive);
102 Common::SharedPtr<Archive> getArchive() const { return _movieArchive; };
103 Common::String getMacName() const { return _macName; }
104 Window *getWindow() const { return _window; }
105 DirectorEngine *getVM() const { return _vm; }
106 Cast *getCast() const { return _casts.getValOrDefault(DEFAULT_CAST_LIB, nullptr); }
107 Cast *getCast(CastMemberID memberID);
108 Cast *getCastByLibResourceID(uint32 libresourceID);
109 Cast *getSharedCast() const { return _sharedCast; }
110 const Common::HashMap<int, Cast *> *getCasts() const { return &_casts; }
111 Score *getScore() const { return _score; }
112
113 void clearSharedCast();
114 void loadSharedCastsFrom(Common::Path &filename);
115 Common::SharedPtr<Archive> loadExternalCastFrom(Common::Path &filename);
116 bool loadCastLibFrom(uint16 libId, Common::Path &filename);
117
118 CastMember *getCastMember(CastMemberID memberID);
119 CastMember *createOrReplaceCastMember(CastMemberID memberID, CastMember *cast);
120 bool eraseCastMember(CastMemberID memberID);
121 bool duplicateCastMember(CastMemberID source, CastMemberID target);
122 CastMemberID getCastMemberIDByMember(int memberID);
123 int getCastLibIDByName(const Common::String &name);
124 void setCastLibName(const Common::String &name, int castLib);
125 CastMemberID getCastMemberIDByName(const Common::String &name);
126 CastMemberID getCastMemberIDByNameAndType(const Common::String &name, int castLib, CastType type);
127 CastMemberInfo *getCastMemberInfo(CastMemberID memberID);
128 bool isValidCastMember(CastMemberID memberID, CastType type);
129 const Stxt *getStxt(CastMemberID memberID);
130 int getMaxCastID();
131
132
133 LingoArchive *getMainLingoArch();
134 LingoArchive *getSharedLingoArch();
135 ScriptContext *getScriptContext(ScriptType type, CastMemberID id);
136 Symbol getHandler(const Common::String &name, uint16 castLibHint = 0);
137
138 // lingo/lingo-events.cpp
139 bool processSysEvent(Common::Event &event);
140 void broadcastEvent(LEvent event);
141
142 // lingo/lingo-events.cpp
143 void setPrimaryEventHandler(LEvent event, const Common::String &code);
144 void resolveScriptEvent(LingoEvent &event);
145 void processEvent(LEvent event, int targetId = 0);
146 void queueInputEvent(LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
147 bool processInputEvent(LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
148
149 Common::String formatMovieInfo();
150
151private:
152 void loadFileInfo(Common::SeekableReadStreamEndian &stream);
153
154 void queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
155 void queueSpriteEvent(Common::Queue<LingoEvent> &queue, LEvent event, int eventId, int spriteId);
156
157public:
158 Common::SharedPtr<Archive> _movieArchive;
159 uint16 _version;
160 Common::Platform _platform;
161 Common::Rect _movieRect;
162 uint16 _lastClickedSpriteId;
163 uint16 _currentHoveredSpriteId;
164 uint _currentSpriteNum;
165 CastMemberID _currentMouseDownCastID;
166 CastMemberID _currentMouseDownSpriteScriptID;
167 bool _currentMouseDownSpriteImmediate;
168 CastMemberID _currentKeyDownCastID;
169 CastMemberID _currentKeyDownSpriteScriptID;
170 bool _currentKeyDownSpriteImmediate;
171 uint16 _currentEditableTextChannel;
172 uint32 _lastEventTime;
173 uint32 _lastRollTime;
174 uint32 _lastClickTime;
175 uint32 _lastClickTime2;
176 Common::Point _lastClickPos;
177 Common::Point _lastMousePos;
178 uint32 _lastKeyTime;
179 uint32 _lastTimerReset;
180 uint32 _stageColor;
181 Cast *_sharedCast;
182 bool _allowOutdatedLingo;
183 bool _remapPalettesWhenNeeded;
184 Common::String _createdBy;
185 Common::String _changedBy;
186 Common::String _origDirectory;
187 CastMemberID _defaultPalette;
188
189 bool _videoPlayback;
190
191 int _nextEventId;
192 Common::Queue<LingoEvent> _inputEventQueue;
193
194 int _selStart;
195 int _selEnd;
196
197 int _checkBoxType;
198 int _checkBoxAccess;
199
200 uint16 _currentHiliteChannelId;
201 uint16 _lastEnteredChannelId;
202
203 int _lastTimeOut;
204 int _timeOutLength;
205 bool _timeOutKeyDown;
206 bool _timeOutMouse;
207 bool _timeOutPlay;
208
209 bool _isBeepOn;
210 Common::HashMap<LEvent, int> _lastEventId;
211
212 Common::String _script;
213
214 // A flag to disable the event processing in the Movie
215 // This flag will be set when the user's interaction (mouse and key events like mouseUp, keyUp)
216 // shouldn't be recorded as movie event, which may cause undesirable change in the lingo script
217 bool _inGuiMessageBox = false;
218
219 // Set for a movie loaded inside a cast member. It shares the host's
220 // window but never owns the stage, so loadArchive() must not resize
221 // or recolour it.
222 bool _isEmbedded = false;
223
224 // For an embedded movie, the movie that hosts it. Its scripts share the
225 // host's handler scope, so getHandler() falls back to the parent.
226 Movie *_parentMovie = nullptr;
227
228private:
229 Window *_window;
230 DirectorEngine *_vm;
231 Lingo *_lingo;
232 Cast *_cast;
235 Score *_score;
236
237 uint32 _flags;
238
239 Common::String _macName;
240
241 bool _mouseDownWasInButton;
242 Channel *_currentDraggedChannel;
243 Common::Point _draggingSpriteOffset;
244};
245
246} // End of namespace Director
247
248#endif
Definition: array.h:52
Definition: hashmap.h:85
Definition: path.h:52
Definition: queue.h:42
Definition: stream.h:854
Definition: stream.h:944
Definition: stream.h:351
Definition: ptr.h:159
Definition: str.h:59
Definition: stream.h:77
Definition: cast.h:88
Definition: castmember.h:48
Definition: channel.h:40
Definition: director.h:158
Definition: lingo.h:366
Definition: movie.h:88
Definition: score.h:66
Definition: lingo-object.h:213
Definition: stxt.h:51
Definition: window.h:106
Platform
Definition: platform.h:93
Definition: algorithm.h:29
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: types.h:424
Definition: castmember.h:172
Definition: movie.h:78
Definition: movie.h:49
Definition: lingo.h:315
Definition: lingo.h:269
Definition: lingo.h:82