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 
28 namespace Common {
29 struct Event;
30 class ReadStreamEndian;
31 class SeekableReadStreamEndian;
32 class MemoryWriteStream;
33 }
34 
35 namespace Director {
36 
37 class Archive;
38 class Cast;
39 struct CastMemberInfo;
40 class CastMember;
41 class DirectorEngine;
42 class Lingo;
43 struct LingoArchive;
44 struct LingoEvent;
45 class ScriptContext;
46 class Window;
47 struct Symbol;
48 
49 struct 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 
78 struct InfoEntries {
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 
88 class Movie {
89 public:
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(Archive *archive);
102  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(int 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  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 
131 
132  LingoArchive *getMainLingoArch();
133  LingoArchive *getSharedLingoArch();
134  ScriptContext *getScriptContext(ScriptType type, CastMemberID id);
135  Symbol getHandler(const Common::String &name, uint16 castLibHint = 0);
136 
137  // lingo/lingo-events.cpp
138  bool processEvent(Common::Event &event);
139  void broadcastEvent(LEvent event);
140 
141  // lingo/lingo-events.cpp
142  void setPrimaryEventHandler(LEvent event, const Common::String &code);
143  void resolveScriptEvent(LingoEvent &event);
144  void processEvent(LEvent event, int targetId = 0);
145  void queueInputEvent(LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
146 
147 private:
148  void loadFileInfo(Common::SeekableReadStreamEndian &stream);
149 
150  void queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
151  void queueSpriteEvent(Common::Queue<LingoEvent> &queue, LEvent event, int eventId, int spriteId);
152 
153 public:
154  Archive *_movieArchive;
155  uint16 _version;
156  Common::Platform _platform;
157  Common::Rect _movieRect;
158  uint16 _lastClickedSpriteId;
159  uint16 _currentHoveredSpriteId;
160  uint _currentSpriteNum;
161  CastMemberID _currentMouseDownCastID;
162  CastMemberID _currentMouseDownSpriteScriptID;
163  bool _currentMouseDownSpriteImmediate;
164  uint16 _currentEditableTextChannel;
165  uint32 _lastEventTime;
166  uint32 _lastRollTime;
167  uint32 _lastClickTime;
168  uint32 _lastClickTime2;
169  Common::Point _lastClickPos;
170  uint32 _lastKeyTime;
171  uint32 _lastTimerReset;
172  uint32 _stageColor;
173  Cast *_sharedCast;
174  bool _allowOutdatedLingo;
175  bool _remapPalettesWhenNeeded;
176  Common::String _createdBy;
177  Common::String _changedBy;
178  Common::String _origDirectory;
179  CastMemberID _defaultPalette;
180 
181  bool _videoPlayback;
182 
183  int _nextEventId;
184  Common::Queue<LingoEvent> _inputEventQueue;
185 
186  uint16 _key;
187  int _keyCode;
188  byte _keyFlags;
189 
190  int _selStart;
191  int _selEnd;
192 
193  int _checkBoxType;
194  int _checkBoxAccess;
195 
196  uint16 _currentHiliteChannelId;
197  uint16 _lastEnteredChannelId;
198 
199  int _lastTimeOut;
200  int _timeOutLength;
201  bool _timeOutKeyDown;
202  bool _timeOutMouse;
203  bool _timeOutPlay;
204 
205  bool _isBeepOn;
206  Common::HashMap<LEvent, int> _lastEventId;
207 
208  Common::String _script;
209 
210  // A flag to disable the event processing in the Movie
211  // This flag will be set when the user's interaction (mouse and key events like mouseUp, keyUp)
212  // shouldn't be recorded as movie event, which may cause undesirable change in the lingo script
213  bool _inGuiMessageBox = false;
214 
215 private:
216  Window *_window;
217  DirectorEngine *_vm;
218  Lingo *_lingo;
219  Cast *_cast;
222  Score *_score;
223 
224  uint32 _flags;
225 
226  Common::String _macName;
227 
228  bool _mouseDownWasInButton;
229  Channel *_currentDraggedChannel;
230  Common::Point _draggingSpriteOffset;
231 };
232 
233 } // End of namespace Director
234 
235 #endif
Definition: cast.h:87
Definition: stream.h:854
Definition: lingo.h:81
Definition: str.h:59
Definition: lingo.h:306
Definition: channel.h:40
Definition: stream.h:77
Definition: array.h:52
Definition: stxt.h:51
Definition: rect.h:524
Definition: path.h:52
Definition: window.h:106
Definition: movie.h:88
Definition: lingo.h:266
Definition: archive.h:36
Definition: queue.h:42
Definition: archive.h:75
Definition: hashmap.h:85
Definition: events.h:210
Definition: algorithm.h:29
Definition: score.h:66
Definition: rect.h:144
Definition: movie.h:78
Definition: stream.h:351
Definition: stream.h:944
Definition: director.h:157
Definition: movie.h:49
Definition: castmember.h:48
Definition: lingo.h:356
Definition: types.h:419
Definition: castmember.h:163
Definition: lingo-object.h:213
Platform
Definition: platform.h:93