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 MEDIASTATION_MOVIE_H
23 #define MEDIASTATION_MOVIE_H
24 
25 #include "common/array.h"
26 
27 #include "mediastation/actor.h"
28 #include "mediastation/audio.h"
29 #include "mediastation/datafile.h"
30 #include "mediastation/bitmap.h"
31 #include "mediastation/mediascript/scriptconstants.h"
32 
33 namespace MediaStation {
34 
35 enum MovieBlitType {
36  kInvalidMovieBlit = 0,
37  kUncompressedMovieBlit = 1,
38  kUncompressedDeltaMovieBlit = 2,
39  kCompressedDeltaMovieBlit = 3,
40 };
41 
42 class MovieFrameImage : public PixMapImage {
43 public:
44  MovieFrameImage(Chunk &chunk, uint index, uint keyframeEndInMilliseconds, const ImageInfo &imageInfo);
45 
46  uint _index = 0;
47  uint _keyframeEndInMilliseconds = 0;
48 };
49 
50 enum MovieSectionType {
51  kMovieRootSection = 0x06a8,
52  kMovieImageDataSection = 0x06a9,
53  kMovieFrameDataSection = 0x06aa,
54  kMovieChunkMarkerSection = 0x06ab
55 };
56 
57 struct MovieFrame {
58  MovieFrame(Chunk &chunk);
59  uint unk3 = 0;
60  uint unk4 = 0;
61  uint layerId = 0;
62  uint startInMilliseconds = 0;
63  uint endInMilliseconds = 0;
64  Common::Point leftTop;
65  Common::Point diffBetweenKeyframeAndFrame;
66  MovieBlitType blitType = kInvalidMovieBlit;
67  int16 zIndex = 0;
68  uint keyframeIndex = 0;
69  bool keepAfterEnd = false;
70  uint index = 0;
71  MovieFrameImage *image = nullptr;
72  MovieFrameImage *keyframeImage = nullptr;
73 };
74 
75 class StreamMovieActor;
76 
77 // Represents an individually controllable layer of a stream movie that is its own spatial entity
78 // and can be in a different stage than its parent stream movie, but which references the parent's
79 // frames at all times. Only frames with a layer ID matching a proxy's layer ID will be drawn when
80 // that proxy is drawn. For example, this is used in the last section of the Dalmatians hide-and-seek
81 // minigame to show a "light" layer that only appears when the player shines a flashlight on an area,
82 // while a "dark" layer seamlessly displays otherwise.
84 friend class StreamMovieActor;
85 
86 public:
87  StreamMovieProxy(Chunk &chunk, StreamMovieActor *parent);
88  virtual void draw(DisplayContext &displayContext) override;
89  virtual bool isVisible() const override;
90 
91  uint _layerId = 0;
92  uint _scriptId = 0;
93 
94 private:
95  StreamMovieActor *_parent = nullptr;
96 };
97 
98 // This is called `RT_stmvFrames` in the original.
100 public:
101  StreamMovieActorFrames(StreamMovieActor *parent) : ChannelClient(), _parent(parent) {}
103 
104  virtual void readChunk(Chunk &chunk) override;
105 
108 
109 private:
110  StreamMovieActor *_parent = nullptr;
111 
112  void readImageData(Chunk &chunk);
113  void readFrameData(Chunk &chunk);
114 };
115 
116 // This is called `RT_stmvSound` in the original.
118 public:
119  StreamMovieActorSound(StreamMovieActor *parent) : ChannelClient(), _audioSequence(this), _parent(parent) {}
121  virtual void readChunk(Chunk &chunk) override;
122  virtual void soundPlayStateChanged(SoundPlayState state, SoundStopReason why) override;
123 
124  AudioSequence &getAudioSequence() { return _audioSequence; }
125 
126 private:
127  AudioSequence _audioSequence;
128  StreamMovieActor *_parent = nullptr;
129 };
130 
132 friend class StreamMovieActorFrames;
133 friend class StreamMovieActorSound;
134 
135 public:
137  virtual ~StreamMovieActor() override;
138 
139  virtual void readChunk(Chunk &chunk) override;
140  virtual void loadIsComplete() override;
141  virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
142  virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
143 
144  virtual PreDisplaySyncState preDisplaySync() override;
145  virtual void onEvent(const ActorEvent &event) override;
146  virtual void timerEvent(const TimerEvent &event) override;
147 
148  virtual void draw(DisplayContext &displayContext) override;
149  void drawLayer(DisplayContext &displayContext, uint layerId);
150  virtual void invalidateLocalBounds() override;
151  bool isLayerInSeparateZPlane(uint layerId);
152 
153 private:
154  ImtStreamFeed *_streamFeed = nullptr;
155  uint _fullTime = 0;
156  uint _chunkCount = 0;
157  double _frameRate = 0;
158  uint _disableScreenAutoUpdateToken = 0;
159 
160  bool _shouldCache = false;
161  bool _isPlaying = false;
162  bool _hasStill = false;
163 
164  StreamMovieActorFrames *_streamFrames = nullptr;
165  StreamMovieActorSound *_streamSound = nullptr;
166 
167  Common::Array<MovieFrame *> _framesNotYetShown;
170 
171  // Script method implementations.
172  void timePlay();
173  void timeStop(bool isMovieEnd);
174 
175  void setVisibility(bool visibility);
176  void updateFrameState();
177  void invalidateRect(const Common::Rect &rect);
178  void decompressIntoAuxImage(MovieFrame *frame);
179 
180  void parseMovieHeader(Chunk &chunk);
181  void parseMovieChunkMarker(Chunk &chunk);
182 
183  Common::Rect getFrameBoundingBox(MovieFrame *frame);
184  StreamMovieProxy *proxyOfId(uint layerId);
185  StreamMovieProxy *proxyOfScriptId(uint scriptId);
186  static int compareFramesByZIndex(const MovieFrame *a, const MovieFrame *b);
187 };
188 
189 } // End of namespace MediaStation
190 
191 #endif
Definition: movie.h:131
Definition: actor.h:252
Definition: actor.h:34
Definition: array.h:52
Definition: audio.h:50
Definition: datafile.h:196
Definition: datafile.h:99
Definition: datafile.h:160
Definition: rect.h:524
Definition: graphics.h:101
Definition: events.h:103
Definition: events.h:94
Definition: bitmap.h:41
Definition: audio.h:56
Definition: bitmap.h:52
Definition: rect.h:144
Definition: array.h:559
Definition: movie.h:83
Definition: movie.h:57
Definition: events.h:151
Definition: movie.h:42
Definition: scriptvalue.h:35