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