ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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, bool withClean = false);
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  bool processFrozenPlayScript();
137 
138 private:
139  bool isWaitingForNextFrame();
140  void updateCurrentFrame();
141  void updateNextFrameTime();
142  void update();
143  void playQueuedSound();
144 
145  void screenShot();
146  bool checkShotSimilarity(const Graphics::Surface *surface1, const Graphics::Surface *surface2);
147 
148  bool processImmediateFrameScript(Common::String s, int id);
149  bool processFrozenScripts(bool recursion = false, int count = 0);
150 
151 public:
152  Common::Array<Channel *> _channels;
155  Common::HashMap<uint16, bool> _immediateActions;
156 
157  Common::Array<Frame *> _scoreCache;
158 
159  // On demand frames loading
160  uint32 _version;
161  Frame *_currentFrame;
162  uint32 _curFrameNumber;
163  uint32 _numFrames;
164  uint32 _framesVersion;
165  uint32 _numChannels;
166  uint8 _currentTempo;
167  CastMemberID _currentPaletteId;
168 
169  uint _firstFramePosition;
170  uint _framesStreamSize;
171  Common::MemoryReadStreamEndian *_framesStream;
172 
173  byte _currentFrameRate;
174  byte _puppetTempo;
175 
176  bool _puppetPalette;
177  int _paletteTransitionIndex;
178  byte _paletteSnapshotBuffer[768];
179 
180  PlayState _playState;
181  uint32 _nextFrameTime;
182  uint32 _nextFrameDelay;
183  int _lastTempo;
184  int _waitForChannel;
185  int _waitForVideoChannel;
186  bool _waitForClick;
187  bool _waitForClickCursor;
188  bool _cursorDirty;
189  bool _activeFade;
190  bool _exitFrameCalled;
191  bool _stopPlayCalled;
192  Cursor _defaultCursor;
193  CursorRef _currentCursor;
194  bool _skipTransition;
195 
196  int _numChannelsDisplayed;
197 
198 private:
199  DirectorEngine *_vm;
200  Lingo *_lingo;
201  Movie *_movie;
202  Window *_window;
203 
204  uint16 _nextFrame;
205  int _currentLabel;
206  DirectorSound *_soundManager;
207 
208  int _previousBuildBotBuild = -1;
209 };
210 
211 } // End of namespace Director
212 
213 #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:156
Definition: frame.h:151
Definition: score.h:56
Definition: castmember.h:45
Definition: lingo.h:348
Definition: types.h:408