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 }
33 
34 namespace Director {
35 
36 class Archive;
37 class Cast;
38 struct CastMemberInfo;
39 class CastMember;
40 class DirectorEngine;
41 class Lingo;
42 struct LingoArchive;
43 struct LingoEvent;
44 class ScriptContext;
45 class Window;
46 struct Symbol;
47 
48 struct InfoEntry {
49  uint32 len;
50  byte *data;
51 
52  InfoEntry() { len = 0; data = nullptr; }
53 
54  InfoEntry(const InfoEntry &old) {
55  len = old.len;
56  data = (byte *)malloc(len);
57  memcpy(data, old.data, len);
58  }
59 
60  ~InfoEntry() {
61  free(data);
62  data = nullptr;
63  }
64 
65  InfoEntry &operator=(const InfoEntry &old) {
66  free(data);
67  len = old.len;
68  data = (byte *)malloc(len);
69  memcpy(data, old.data, len);
70  return *this;
71  }
72 
73  Common::String readString(bool pascal = true);
74 };
75 
76 struct InfoEntries {
77  uint32 unk1;
78  uint32 unk2;
79  uint32 flags;
80  uint32 scriptId;
82 
83  InfoEntries() : unk1(0), unk2(0), flags(0), scriptId(0) {}
84 };
85 
86 class Movie {
87 public:
88  Movie(Window *window);
89  ~Movie();
90 
91  static Common::Rect readRect(Common::ReadStreamEndian &stream);
92  static InfoEntries loadInfoEntries(Common::SeekableReadStreamEndian &stream, uint16 version);
93 
94  void loadCastLibMapping(Common::SeekableReadStreamEndian &stream);
95  bool loadArchive();
96  void setArchive(Archive *archive);
97  Archive *getArchive() const { return _movieArchive; };
98  Common::String getMacName() const { return _macName; }
99  Window *getWindow() const { return _window; }
100  DirectorEngine *getVM() const { return _vm; }
101  Cast *getCast() const { return _casts.getValOrDefault(DEFAULT_CAST_LIB, nullptr); }
102  Cast *getCast(CastMemberID memberID);
103  Cast *getSharedCast() const { return _sharedCast; }
104  const Common::HashMap<int, Cast *> *getCasts() const { return &_casts; }
105  Score *getScore() const { return _score; }
106 
107  void clearSharedCast();
108  void loadSharedCastsFrom(Common::Path &filename);
109  Archive *loadExternalCastFrom(Common::Path &filename);
110 
111  CastMember *getCastMember(CastMemberID memberID);
112  CastMember *createOrReplaceCastMember(CastMemberID memberID, CastMember *cast);
113  bool eraseCastMember(CastMemberID memberID);
114  bool duplicateCastMember(CastMemberID source, CastMemberID target);
115  CastMemberID getCastMemberIDByMember(int memberID);
116  int getCastLibIDByName(const Common::String &name);
117  CastMemberID getCastMemberIDByName(const Common::String &name);
118  CastMemberID getCastMemberIDByNameAndType(const Common::String &name, int castLib, CastType type);
119  CastMemberInfo *getCastMemberInfo(CastMemberID memberID);
120  bool isValidCastMember(CastMemberID memberID, CastType type);
121  const Stxt *getStxt(CastMemberID memberID);
122 
123  LingoArchive *getMainLingoArch();
124  LingoArchive *getSharedLingoArch();
125  ScriptContext *getScriptContext(ScriptType type, CastMemberID id);
126  Symbol getHandler(const Common::String &name);
127 
128  // events.cpp
129  bool processEvent(Common::Event &event);
130 
131  // lingo/lingo-events.cpp
132  void setPrimaryEventHandler(LEvent event, const Common::String &code);
133  void resolveScriptEvent(LingoEvent &event);
134  void processEvent(LEvent event, int targetId = 0);
135  void queueInputEvent(LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
136 
137 private:
138  void loadFileInfo(Common::SeekableReadStreamEndian &stream);
139 
140  void queueEvent(Common::Queue<LingoEvent> &queue, LEvent event, int targetId = 0, Common::Point pos = Common::Point(-1, -1));
141  void queueSpriteEvent(Common::Queue<LingoEvent> &queue, LEvent event, int eventId, int spriteId);
142 
143 public:
144  Archive *_movieArchive;
145  uint16 _version;
146  Common::Platform _platform;
147  Common::Rect _movieRect;
148  uint16 _currentActiveSpriteId;
149  uint16 _currentMouseSpriteId;
150  CastMemberID _currentMouseDownCastID;
151  uint16 _currentEditableTextChannel;
152  uint32 _lastEventTime;
153  uint32 _lastRollTime;
154  uint32 _lastClickTime;
155  uint32 _lastClickTime2;
156  Common::Point _lastClickPos;
157  uint32 _lastKeyTime;
158  uint32 _lastTimerReset;
159  uint32 _stageColor;
160  Cast *_sharedCast;
161  bool _allowOutdatedLingo;
162  bool _remapPalettesWhenNeeded;
163  Common::String _createdBy;
164  Common::String _changedBy;
165  Common::String _origDirectory;
166  CastMemberID _defaultPalette;
167 
168  bool _videoPlayback;
169 
170  int _nextEventId;
171  Common::Queue<LingoEvent> _inputEventQueue;
172 
173  unsigned char _key;
174  int _keyCode;
175  byte _keyFlags;
176 
177  int _selStart;
178  int _selEnd;
179 
180  int _checkBoxType;
181  int _checkBoxAccess;
182 
183  uint16 _currentHiliteChannelId;
184 
185  uint _lastTimeOut;
186  uint _timeOutLength;
187  bool _timeOutKeyDown;
188  bool _timeOutMouse;
189  bool _timeOutPlay;
190 
191  bool _isBeepOn;
192 
193  Common::String _script;
194 
195 private:
196  Window *_window;
197  DirectorEngine *_vm;
198  Lingo *_lingo;
199  Cast *_cast;
202  Score *_score;
203 
204  uint32 _flags;
205 
206  Common::String _macName;
207 
208  bool _mouseDownWasInButton;
209  Channel *_currentDraggedChannel;
210  Common::Point _draggingSpriteOffset;
211 };
212 
213 } // End of namespace Director
214 
215 #endif
Definition: cast.h:85
Definition: stream.h:854
Definition: lingo.h:81
Definition: str.h:59
Definition: lingo.h:298
Definition: channel.h:40
Definition: array.h:52
Definition: stxt.h:49
Definition: rect.h:144
Definition: path.h:52
Definition: window.h:103
Definition: movie.h:86
Definition: lingo.h:264
Definition: archive.h:35
Definition: queue.h:42
Definition: archive.h:53
Definition: hashmap.h:85
Definition: events.h:199
Definition: algorithm.h:29
Definition: score.h:63
Definition: rect.h:45
Definition: movie.h:76
Definition: stream.h:944
Definition: director.h:150
Definition: movie.h:48
Definition: castmember.h:45
Definition: lingo.h:347
Definition: types.h:414
Definition: castmember.h:126
Definition: lingo-object.h:213
Platform
Definition: platform.h:46