ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 };
76 
77 struct InfoEntries {
78  uint32 unk1;
79  uint32 unk2;
80  uint32 flags;
81  uint32 scriptId;
83 
84  InfoEntries() : unk1(0), unk2(0), flags(0), scriptId(0) {}
85 };
86 
87 class Movie {
88 public:
89  Movie(Window *window);
90  ~Movie();
91 
92  static Common::Rect readRect(Common::ReadStreamEndian &stream);
93  static InfoEntries loadInfoEntries(Common::SeekableReadStreamEndian &stream, uint16 version);
94  static void saveInfoEntries(Common::MemoryWriteStream *writeStream, InfoEntries info);
95 
96  static void writeRect(Common::MemoryWriteStream *writeStream, Common::Rect rect);
97 
98  void loadCastLibMapping(Common::SeekableReadStreamEndian &stream);
99  bool loadArchive();
100  void setArchive(Archive *archive);
101  Archive *getArchive() const { return _movieArchive; };
102  Common::String getMacName() const { return _macName; }
103  Window *getWindow() const { return _window; }
104  DirectorEngine *getVM() const { return _vm; }
105  Cast *getCast() const { return _casts.getValOrDefault(DEFAULT_CAST_LIB, nullptr); }
106  Cast *getCast(CastMemberID memberID);
107  Cast *getSharedCast() const { return _sharedCast; }
108  const Common::HashMap<int, Cast *> *getCasts() const { return &_casts; }
109  Score *getScore() const { return _score; }
110 
111  void clearSharedCast();
112  void loadSharedCastsFrom(Common::Path &filename);
113  Archive *loadExternalCastFrom(Common::Path &filename);
114  bool loadCastLibFrom(uint16 libId, Common::Path &filename);
115 
116  CastMember *getCastMember(CastMemberID memberID);
117  CastMember *createOrReplaceCastMember(CastMemberID memberID, CastMember *cast);
118  bool eraseCastMember(CastMemberID memberID);
119  bool duplicateCastMember(CastMemberID source, CastMemberID target);
120  CastMemberID getCastMemberIDByMember(int memberID);
121  int getCastLibIDByName(const Common::String &name);
122  void setCastLibName(const Common::String &name, int castLib);
123  CastMemberID getCastMemberIDByName(const Common::String &name);
124  CastMemberID getCastMemberIDByNameAndType(const Common::String &name, int castLib, CastType type);
125  CastMemberInfo *getCastMemberInfo(CastMemberID memberID);
126  bool isValidCastMember(CastMemberID memberID, CastType type);
127  const Stxt *getStxt(CastMemberID memberID);
128 
129 
130  LingoArchive *getMainLingoArch();
131  LingoArchive *getSharedLingoArch();
132  ScriptContext *getScriptContext(ScriptType type, CastMemberID id);
133  Symbol getHandler(const Common::String &name, uint16 castLibHint = 0);
134 
135  // events.cpp
136  bool processEvent(Common::Event &event);
137 
138  // lingo/lingo-events.cpp
139  void setPrimaryEventHandler(LEvent event, const Common::String &code);
140  void resolveScriptEvent(LingoEvent &event);
141  void processEvent(LEvent event, int targetId = 0);
142  void queueInputEvent(LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
143 
144 private:
145  void loadFileInfo(Common::SeekableReadStreamEndian &stream);
146 
147  void queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
148  void queueSpriteEvent(Common::Queue<LingoEvent> &queue, LEvent event, int eventId, int spriteId);
149 
150 public:
151  Archive *_movieArchive;
152  uint16 _version;
153  Common::Platform _platform;
154  Common::Rect _movieRect;
155  uint16 _currentActiveSpriteId;
156  uint16 _currentMouseSpriteId;
157  CastMemberID _currentMouseDownCastID;
158  CastMemberID _currentMouseDownSpriteScriptID;
159  bool _currentMouseDownSpriteImmediate;
160  uint16 _currentEditableTextChannel;
161  uint32 _lastEventTime;
162  uint32 _lastRollTime;
163  uint32 _lastClickTime;
164  uint32 _lastClickTime2;
165  Common::Point _lastClickPos;
166  uint32 _lastKeyTime;
167  uint32 _lastTimerReset;
168  uint32 _stageColor;
169  Cast *_sharedCast;
170  bool _allowOutdatedLingo;
171  bool _remapPalettesWhenNeeded;
172  Common::String _createdBy;
173  Common::String _changedBy;
174  Common::String _origDirectory;
175  CastMemberID _defaultPalette;
176 
177  bool _videoPlayback;
178 
179  int _nextEventId;
180  Common::Queue<LingoEvent> _inputEventQueue;
181 
182  uint16 _key;
183  int _keyCode;
184  byte _keyFlags;
185 
186  int _selStart;
187  int _selEnd;
188 
189  int _checkBoxType;
190  int _checkBoxAccess;
191 
192  uint16 _currentHiliteChannelId;
193 
194  int _lastTimeOut;
195  int _timeOutLength;
196  bool _timeOutKeyDown;
197  bool _timeOutMouse;
198  bool _timeOutPlay;
199 
200  bool _isBeepOn;
201  Common::HashMap<LEvent, int> _lastEventId;
202 
203  Common::String _script;
204 
205  // A flag to disable the event processing in the Movie
206  // This flag will be set when the user's interaction (mouse and key events like mouseUp, keyUp)
207  // shouldn't be recorded as movie event, which may cause undesirable change in the lingo script
208  bool _inGuiMessageBox = false;
209 
210 private:
211  Window *_window;
212  DirectorEngine *_vm;
213  Lingo *_lingo;
214  Cast *_cast;
217  Score *_score;
218 
219  uint32 _flags;
220 
221  Common::String _macName;
222 
223  bool _mouseDownWasInButton;
224  Channel *_currentDraggedChannel;
225  Common::Point _draggingSpriteOffset;
226 };
227 
228 } // End of namespace Director
229 
230 #endif
Definition: cast.h:87
Definition: stream.h:854
Definition: lingo.h:81
Definition: str.h:59
Definition: lingo.h:299
Definition: channel.h:40
Definition: array.h:52
Definition: stxt.h:51
Definition: rect.h:144
Definition: path.h:52
Definition: window.h:103
Definition: movie.h:87
Definition: lingo.h:265
Definition: archive.h:36
Definition: queue.h:42
Definition: archive.h:57
Definition: hashmap.h:85
Definition: events.h:210
Definition: algorithm.h:29
Definition: score.h:63
Definition: rect.h:45
Definition: movie.h:77
Definition: stream.h:944
Definition: director.h:156
Definition: movie.h:49
Definition: memstream.h:120
Definition: castmember.h:48
Definition: lingo.h:349
Definition: types.h:409
Definition: castmember.h:150
Definition: lingo-object.h:213
Platform
Definition: platform.h:46