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:
120  virtual void readChunk(Chunk &chunk) override;
121 
122  AudioSequence _audioSequence;
123 };
124 
126 friend class StreamMovieActorFrames;
127 friend class StreamMovieActorSound;
128 
129 public:
131  virtual ~StreamMovieActor() override;
132 
133  virtual void readChunk(Chunk &chunk) override;
134  virtual void loadIsComplete() override;
135  virtual void readParameter(Chunk &chunk, ActorHeaderSectionType paramType) override;
136  virtual ScriptValue callMethod(BuiltInMethod methodId, Common::Array<ScriptValue> &args) override;
137  virtual void process() override;
138 
139  virtual void draw(DisplayContext &displayContext) override;
140  void drawLayer(DisplayContext &displayContext, uint layerId);
141  virtual void invalidateLocalBounds() override;
142  bool isLayerInSeparateZPlane(uint layerId);
143 
144 private:
145  ImtStreamFeed *_streamFeed = nullptr;
146  uint _fullTime = 0;
147  uint _chunkCount = 0;
148  double _frameRate = 0;
149 
150  bool _shouldCache = false;
151  bool _isPlaying = false;
152  bool _hasStill = false;
153 
154  StreamMovieActorFrames *_streamFrames = nullptr;
155  StreamMovieActorSound *_streamSound = nullptr;
156 
157  Common::Array<MovieFrame *> _framesNotYetShown;
160 
161  // Script method implementations.
162  void timePlay();
163  void timeStop();
164 
165  void setVisibility(bool visibility);
166  void updateFrameState();
167  void invalidateRect(const Common::Rect &rect);
168  void decompressIntoAuxImage(MovieFrame *frame);
169 
170  void parseMovieHeader(Chunk &chunk);
171  void parseMovieChunkMarker(Chunk &chunk);
172 
173  Common::Rect getFrameBoundingBox(MovieFrame *frame);
174  StreamMovieProxy *proxyOfId(uint layerId);
175  StreamMovieProxy *proxyOfScriptId(uint scriptId);
176  static int compareFramesByZIndex(const MovieFrame *a, const MovieFrame *b);
177 };
178 
179 } // End of namespace MediaStation
180 
181 #endif
Definition: movie.h:125
Definition: actor.h:229
Definition: actor.h:33
Definition: array.h:52
Definition: datafile.h:199
Definition: datafile.h:102
Definition: datafile.h:163
Definition: rect.h:524
Definition: graphics.h:100
Definition: bitmap.h:41
Definition: audio.h:33
Definition: bitmap.h:52
Definition: rect.h:144
Definition: array.h:559
Definition: movie.h:83
Definition: movie.h:57
Definition: movie.h:42
Definition: scriptvalue.h:35