ScummVM API documentation
window.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_STAGE_H
23#define DIRECTOR_STAGE_H
24
25#include "graphics/macgui/macwindow.h"
26
27#include "director/lingo/lingo-object.h"
28
29namespace Common {
30class Error;
31}
32
33namespace Graphics {
34class ManagedSurface;
35class MacWindow;
36class MacWindowManager;
37}
38
39namespace Director {
40
41class Channel;
42class MacArchive;
43class Window;
44struct MacShape;
45struct LingoState;
46
48 TransitionType type;
49 uint frame;
50 uint duration;
51 uint chunkSize;
52 uint area;
53
54 int steps;
55 int stepDuration;
56
57 int xStepSize;
58 int yStepSize;
59
60 int xpos, ypos;
61
62 int stripSize;
63
64 const byte *sourcePal;
65 uint16 sourcePalLength;
66 const byte *targetPal;
67 uint16 targetPalLength;
68 byte tempPal[768];
69
70 TransParams() : tempPal() {
71 type = kTransNone;
72 frame = 0;
73 duration = 250;
74 chunkSize = 1;
75 area = 0;
76 steps = 0;
77 stepDuration = 0;
78 stripSize = 0;
79
80 xStepSize = yStepSize = 0;
81 xpos = ypos = 0;
82
83 sourcePal = nullptr;
84 sourcePalLength = 0;
85 targetPal = nullptr;
86 targetPalLength = 0;
87 }
88
89 TransParams(uint16 d, uint16 a, uint16 c, TransitionType t) :
90 duration(d), area(a), chunkSize(c), type(t), tempPal() {
91 frame = 0;
92 steps = 0;
93 stepDuration = 0;
94 stripSize = 0;
95
96 xStepSize = yStepSize = 0;
97 xpos = ypos = 0;
98
99 sourcePal = nullptr;
100 sourcePalLength = 0;
101 targetPal = nullptr;
102 targetPalLength = 0;
103 }
104};
105
106class Window : public Object<Window> {
107public:
108 Window(int id, bool scrollable, bool resizable, bool editable, Graphics::MacWindowManager *wm, DirectorEngine *vm, bool isStage);
109 ~Window();
110
111 bool render(bool forceRedraw = false, Graphics::ManagedSurface *blitTo = nullptr);
112 void renderChannel(Channel *channel, const Common::Rect &rect, Graphics::ManagedSurface *blitTo = nullptr, bool invert = false);
113 void invertChannel(Channel *channel, const Common::Rect &destRect);
114
115 bool needsAppliedColor(DirectorPlotData *pd);
116 void setStageColor(uint32 stageColor, bool forceReset = false);
117 uint32 getStageColor() { return _stageColor; }
118
119 void reset();
120
121 // transitions.cpp
122 void exitTransition(TransParams &t, Graphics::ManagedSurface *nextFrame, Common::Rect clipRect);
123 void stepTransition(TransParams &t, int step);
124 void playTransition(uint frame, RenderMode mode, uint16 transDuration, uint8 transArea, uint8 transChunkSize, TransitionType transType, CastMemberID paletteId);
125 void initTransParams(TransParams &t, Common::Rect &clipRect);
126 void dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
127 void dissolvePatternsTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
128 void transMultiPass(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
129 void transZoom(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *currentFrame, Graphics::ManagedSurface *nextFrame);
130
131 // window.cpp
132 Common::Point getMousePos();
133
134 DirectorEngine *getVM() const { return _vm; }
135 Graphics::MacWindow *getMacWindow() const { return _window; }
136 Movie *getCurrentMovie() const { return _currentMovie; }
137 // Temporarily retarget the current movie when stepping an embedded movie
138 // so getCurrentMovie()-based context (go, globals, events) points at it.
139 void setCurrentMovie(Movie *movie) { _currentMovie = movie; }
140 Common::String getCurrentPath() const { return _currentPath; }
141 // Sound channels are shared by the Stage and every MIAW (Director in a Nutshell),
142 // so route every window through the Stage's manager.
143 DirectorSound *getSoundManager() const {
144 Window *stage = g_director->getStage();
145 if (stage && stage != this)
146 return stage->getSoundManager();
147 return _soundManager;
148 }
149
150 void setVisible(bool visible, bool silent = false);
151 bool setNextMovie(Common::String &movieFilenameRaw);
152
153 void ensureMovieIsLoaded();
154
155 void setWindowType(int type) { _windowType = type; updateBorderType(); }
156 int getWindowType() const { return _windowType; }
157 void setTitleVisible(bool titleVisible);
158 Graphics::ManagedSurface *getSurface();
159 void addDirtyRect(const Common::Rect &r);
160 void resizeInner(int w, int h);
161 int getId();
162 void setDirty(bool dirty);
163 void disableBorder();
164 void center(bool toCenter = true);
165 Common::Point getAbsolutePos();
166 void setTitle(const Common::String &title);
167 void move(int x, int y);
168
169 Datum getStageRect();
170 void setStageRect(Datum datum);
171 void setModal(bool modal);
172 bool getModal() { return _isModal; };
173 void setFileName(Common::String filename);
174 Common::String getFileName() { return _fileName.toString(g_director->_dirSeparator); }
175
176 void updateBorderType();
177
178 bool step();
179 bool loadNextMovie();
180 void loadNewSharedCast(Cast *previousSharedCast);
181
182 Common::Path getSharedCastPath();
183
184 LingoState *getLingoState() { return _lingoState; };
185 LingoState *getLingoPlayState() { return _lingoPlayState; };
186 uint32 frozenLingoStateCount() { return _frozenLingoStates.size(); };
187 uint32 frozenLingoRecursionCount();
188 void freezeLingoState();
189 void thawLingoState();
190 void freezeLingoPlayState();
191 bool requeueLingoPlayState();
192 LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
193 void moveLingoState(Window *target);
194
195 // Swap the window's Lingo state (current + frozen stack) with an external
196 // one, so an embedded movie runs isolated and its go()/freeze does not
197 // block the host's scripts.
198 void swapLingoState(LingoState *&state, Common::Array<LingoState *> &frozen) {
199 SWAP(_lingoState, state);
200 SWAP(_frozenLingoStates, frozen);
201 }
202
203 Common::String formatWindowInfo();
204
205 static void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
206
207 // events.cpp
208 bool processSysEvent(Common::Event &event);
209 bool processWMEvent(Graphics::WindowClick click, Common::Event &event);
210 void sendWindowEvent(LEvent event);
211
212 // tests.cpp
214 void testFontScaling();
215 void testFonts();
216 void enqueueAllMovies();
217 MovieReference getNextMovieFromQueue();
218 void runTests();
219
220 // resource.cpp
221 Common::Error loadInitialMovie();
222 void probeResources(Archive *archive);
223 void loadINIStream();
224 void loadXtrasFromPath();
225 void loadStartMovieXLibs();
226
227 // lingo/lingo-object.cpp
228 Common::String asString() override;
229 bool hasProp(const Common::String &propName) override;
230 Datum getProp(const Common::String &propName) override;
231 void setProp(const Common::String &propName, const Datum &value, bool force = false) override;
232 bool hasField(int field) override;
233 Datum getField(int field) override;
234 void setField(int field, const Datum &value) override;
235
236 Common::Path _fileName;
237
238public:
239 Graphics::MacWindow *_window;
241
242 TransParams *_puppetTransition;
243
244 MovieReference _nextMovie;
246 bool _newMovieStarted;
247 bool _newMovieFirstDraw;
248 bool _skipFrameAdvance;
249 bool _resetScreen;
250 bool _playbackPaused;
251
252private:
253 uint32 _stageColor;
254
255 DirectorEngine *_vm;
256 DirectorSound *_soundManager;
257 LingoState *_lingoState;
258 Common::Array<LingoState *> _frozenLingoStates;
259 LingoState *_lingoPlayState;
260 bool _isStage;
261 Movie *_currentMovie;
262 Common::String _currentPath;
263 Common::StringArray _movieQueue;
264 int16 _startFrame;
265
266 int _windowType;
267 bool _isModal;
268 Common::String _sharedCastFilenameHint;
269 Common::String _soundsFilenameHint;
270
271private:
272 static void drawChannelBox(Director::Movie *currentMovie, Graphics::ManagedSurface *blitTo, int selectedChannel);
273 void drawFrameCounter(Graphics::ManagedSurface *blitTo);
274
275
276};
277
278} // End of namespace Director
279
280#endif
Definition: array.h:52
Definition: error.h:81
Definition: hashmap.h:85
Definition: list.h:44
Definition: path.h:52
String toString(char separator='/') const
Definition: str.h:59
Definition: archive.h:78
Definition: cast.h:88
Definition: channel.h:40
Definition: director.h:158
Definition: sound.h:168
Definition: movie.h:88
Definition: lingo-object.h:71
Definition: window.h:106
Definition: macwindow.h:205
Definition: macwindowmanager.h:149
Definition: managed_surface.h:51
void SWAP(T &a, T &b)
Definition: util.h:467
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: types.h:424
Definition: lingo.h:131
Definition: director.h:360
Definition: lingo.h:343
Definition: director.h:107
Definition: window.h:47