ScummVM API documentation
score.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_SCORE_H
23 #define DIRECTOR_SCORE_H
24 
25 #include "director/cursor.h"
26 
27 namespace Graphics {
28  struct Surface;
29  class ManagedSurface;
30  class Font;
31  class MacWindow;
32  struct ZoomBox;
33 }
34 
35 namespace Common {
36  class ReadStreamEndian;
37  class MemoryReadStreamEndian;
38  class SeekableReadStreamEndian;
39  class SeekableWriteStream;
40 }
41 
42 namespace Director {
43 
44 class Window;
45 class Archive;
46 class DirectorEngine;
47 class DirectorSound;
48 class Frame;
49 class Movie;
50 struct Resource;
51 class Cursor;
52 class Channel;
53 class Sprite;
54 class CastMember;
55 class AudioDecoder;
56 
57 struct Label {
58  Common::String comment;
59  Common::String name;
60  uint16 number;
61  Label(Common::String name1, uint16 number1, Common::String comment1) { name = name1; number = number1; comment = comment1;}
62 };
63 
64 class Score {
65 public:
66  Score(Movie *movie);
67  ~Score();
68 
69  Movie *getMovie() const { return _movie; }
70 
71  void loadFrames(Common::SeekableReadStreamEndian &stream, uint16 version);
72  bool loadFrame(int frame, bool loadCast);
73  bool readOneFrame();
74  void updateFrame(Frame *frame);
75  Frame *getFrameData(int frameNum);
76 
77  void writeVWSCResource(Common::SeekableWriteStream *writeStream, uint32 offset);
78  uint32 getVWSCResourceSize();
79 
80  void loadLabels(Common::SeekableReadStreamEndian &stream);
81  void loadActions(Common::SeekableReadStreamEndian &stream);
82  void loadSampleSounds(uint type);
83 
84  static int compareLabels(const void *a, const void *b);
85  uint16 getLabel(Common::String &label);
86  Common::String *getLabelList();
87  Common::String *getFrameLabel(uint id);
88  void setStartToLabel(Common::String &label);
89  void gotoLoop();
90  void gotoNext();
91  void gotoPrevious();
92  void startPlay();
93  void step();
94  void stopPlay();
95  void setDelay(uint32 ticks);
96 
97  void setCurrentFrame(uint16 frameId);
98  uint16 getCurrentFrameNum() { return _curFrameNumber; }
99  int getNextFrame() { return _nextFrame; }
100  uint16 getFramesNum() { return _numFrames; }
101 
102  void setPuppetTempo(int16 puppetTempo);
103 
104  CastMemberID getCurrentPalette();
105 
106  Channel *getChannelById(uint16 id);
107  Sprite *getSpriteById(uint16 id);
108  Sprite *getOriginalSpriteById(uint16 id);
109 
110  void setSpriteCasts();
111 
112  int getPreviousLabelNumber(int referenceFrame);
113  int getCurrentLabelNumber();
114  int getNextLabelNumber(int referenceFrame);
115 
116  uint16 getSpriteIDOfActiveWidget();
117  uint16 getSpriteIDFromPos(Common::Point pos);
118  uint16 getMouseSpriteIDFromPos(Common::Point pos);
119  uint16 getActiveSpriteIDFromPos(Common::Point pos);
120  bool checkSpriteRollOver(uint16 spriteId, Common::Point pos);
121  uint16 getRollOverSpriteIDFromPos(Common::Point pos);
122  Common::List<Channel *> getSpriteIntersections(const Common::Rect &r);
123  uint16 getSpriteIdByMemberId(CastMemberID id);
124  bool refreshPointersForCastMemberID(CastMemberID id);
125  bool refreshPointersForCastLib(uint16 castLib);
126 
127  bool renderTransition(uint16 frameId, RenderMode mode);
128  void renderFrame(uint16 frameId, RenderMode mode = kRenderModeNormal);
129  void incrementFilmLoops();
130  void updateSprites(RenderMode mode = kRenderModeNormal, bool withClean = false);
131  bool renderPrePaletteCycle(RenderMode mode = kRenderModeNormal);
132  void setLastPalette();
133  bool isPaletteColorCycling();
134  void renderPaletteCycle(RenderMode mode = kRenderModeNormal);
135  void renderCursor(Common::Point pos, bool forceUpdate = false);
136  void updateWidgets(bool hasVideoPlayback);
137 
138  void invalidateRectsForMember(CastMember *member);
139 
140  void playSoundChannel(bool puppetOnly);
141 
142  Common::String formatChannelInfo();
143  bool processFrozenPlayScript();
144 
145 private:
146  bool isWaitingForNextFrame();
147  void updateCurrentFrame();
148  void updateNextFrameTime();
149  void update();
150  void playQueuedSound();
151 
152  void screenShot();
153  bool checkShotSimilarity(const Graphics::Surface *surface1, const Graphics::Surface *surface2);
154 
155  bool processImmediateFrameScript(Common::String s, int id);
156  bool processFrozenScripts(bool recursion = false, int count = 0);
157 
158  void writeFrame(Common::SeekableWriteStream *writeStream, Frame frame, uint32 channelSize, uint32 mainChannelSize);
159 
160  void seekToMemberInList(int frame);
161 
162 public:
163  Common::Array<Channel *> _channels;
166  Common::HashMap<uint16, bool> _immediateActions;
167 
168  Common::Array<Frame *> _scoreCache;
169 
170  // On demand frames loading
171  uint32 _version;
172  Frame *_currentFrame;
173  uint32 _curFrameNumber;
174  uint32 _numFrames;
175  uint8 _currentTempo;
176  CastMemberID _currentPaletteId;
177 
178  // header D4+
179  uint32 _framesStreamSize;
180  int32 _frame1Offset;
181  int32 _numOfFrames;
182  uint16 _framesVersion;
183  uint16 _spriteRecordSize;
184  uint16 _numChannels;
185  int16 _numChannelsDisplayed; // D7+, no-op in earlier versions
186  // 20 bytes in total
187 
188  uint _firstFramePosition;
189  uint _indexStart = 0;
190  uint _frameDataOffset = 0;
191  Common::MemoryReadStreamEndian *_framesStream;
192 
193  byte _currentFrameRate;
194  byte _puppetTempo;
195 
196  bool _puppetPalette;
197  int _paletteTransitionIndex;
198  byte _paletteSnapshotBuffer[768];
199 
200  PlayState _playState;
201  uint32 _nextFrameTime;
202  uint32 _nextFrameDelay;
203  int _lastTempo;
204  int _waitForChannel;
205  int _waitForVideoChannel;
206  bool _waitForClick;
207  bool _waitForClickCursor;
208  bool _cursorDirty;
209  bool _activeFade;
210  bool _exitFrameCalled;
211  bool _stopPlayCalled;
212  Cursor _defaultCursor;
213  CursorRef _currentCursor;
214  bool _skipTransition;
215 
216 private:
217  DirectorEngine *_vm;
218  Lingo *_lingo;
219  Movie *_movie;
220  Window *_window;
221 
222  uint16 _nextFrame;
223  int _currentLabel;
224  DirectorSound *_soundManager;
225 
226  int _previousBuildBotBuild = -1;
227 };
228 
229 } // End of namespace Director
230 
231 #endif
Definition: cursor.h:73
Definition: str.h:59
Definition: surface.h:67
Definition: channel.h:40
Definition: array.h:52
Definition: list.h:44
Definition: rect.h:524
Definition: window.h:103
Definition: movie.h:88
Definition: archive.h:36
Definition: memstream.h:103
Definition: cursor.h:41
Definition: sound.h:164
Definition: atari-cursor.h:35
Definition: algorithm.h:29
Definition: sprite.h:56
Definition: formatinfo.h:28
Definition: score.h:64
Definition: rect.h:144
Definition: array.h:561
Definition: stream.h:351
Definition: stream.h:944
Definition: director.h:156
Definition: frame.h:170
Definition: score.h:57
Definition: castmember.h:48
Definition: lingo.h:349
Definition: types.h:411