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