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 
29 namespace Common {
30 class Error;
31 }
32 
33 namespace Graphics {
34 class ManagedSurface;
35 class MacWindow;
36 class MacWindowManager;
37 }
38 
39 namespace Director {
40 
41 class Channel;
42 class MacArchive;
43 class Window;
44 struct MacShape;
45 struct LingoState;
46 
47 struct TransParams {
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 
106 class Window : public Object<Window> {
107 public:
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  Common::String getCurrentPath() const { return _currentPath; }
138  DirectorSound *getSoundManager() const { return _soundManager; }
139 
140  void setVisible(bool visible, bool silent = false);
141  bool setNextMovie(Common::String &movieFilenameRaw);
142 
143  void ensureMovieIsLoaded();
144 
145  void setWindowType(int type) { _windowType = type; updateBorderType(); }
146  int getWindowType() const { return _windowType; }
147  void setTitleVisible(bool titleVisible);
148  Graphics::ManagedSurface *getSurface();
149  void addDirtyRect(const Common::Rect &r);
150  void resizeInner(int w, int h);
151  int getId();
152  void setDirty(bool dirty);
153  void disableBorder();
154  void center(bool toCenter = true);
155  Common::Point getAbsolutePos();
156  void setTitle(const Common::String &title);
157  void move(int x, int y);
158 
159  Datum getStageRect();
160  void setStageRect(Datum datum);
161  void setModal(bool modal);
162  bool getModal() { return _isModal; };
163  void setFileName(Common::String filename);
164  Common::String getFileName() { return _fileName.toString(g_director->_dirSeparator); }
165 
166  void updateBorderType();
167 
168  bool step();
169  bool loadNextMovie();
170  void loadNewSharedCast(Cast *previousSharedCast);
171 
172  Common::Path getSharedCastPath();
173 
174  LingoState *getLingoState() { return _lingoState; };
175  LingoState *getLingoPlayState() { return _lingoPlayState; };
176  uint32 frozenLingoStateCount() { return _frozenLingoStates.size(); };
177  uint32 frozenLingoRecursionCount();
178  void freezeLingoState();
179  void thawLingoState();
180  void freezeLingoPlayState();
181  bool requeueLingoPlayState();
182  LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
183  void moveLingoState(Window *target);
184 
185  Common::String formatWindowInfo();
186 
187  static void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
188 
189  // events.cpp
190  bool processSysEvent(Common::Event &event);
191  bool processWMEvent(Graphics::WindowClick click, Common::Event &event);
192  void sendWindowEvent(LEvent event);
193 
194  // tests.cpp
195  Common::HashMap<Common::String, Movie *> *scanMovies(const Common::Path &folder);
196  void testFontScaling();
197  void testFonts();
198  void enqueueAllMovies();
199  MovieReference getNextMovieFromQueue();
200  void runTests();
201 
202  // resource.cpp
203  Common::Error loadInitialMovie();
204  void probeResources(Archive *archive);
205  void loadINIStream();
206  void loadXtrasFromPath();
207  void loadStartMovieXLibs();
208 
209  // lingo/lingo-object.cpp
210  Common::String asString() override;
211  bool hasProp(const Common::String &propName) override;
212  Datum getProp(const Common::String &propName) override;
213  void setProp(const Common::String &propName, const Datum &value, bool force = false) override;
214  bool hasField(int field) override;
215  Datum getField(int field) override;
216  void setField(int field, const Datum &value) override;
217 
218  Common::Path _fileName;
219 
220 public:
221  Graphics::MacWindow *_window;
223 
224  TransParams *_puppetTransition;
225 
226  MovieReference _nextMovie;
227  Common::List<MovieReference> _movieStack;
228  bool _newMovieStarted;
229  bool _newMovieFirstDraw;
230  bool _skipFrameAdvance;
231  bool _resetScreen;
232 
233 private:
234  uint32 _stageColor;
235 
236  DirectorEngine *_vm;
237  DirectorSound *_soundManager;
238  LingoState *_lingoState;
239  Common::Array<LingoState *> _frozenLingoStates;
240  LingoState *_lingoPlayState;
241  bool _isStage;
242  Movie *_currentMovie;
243  Common::String _currentPath;
244  Common::StringArray _movieQueue;
245  int16 _startFrame;
246 
247  int _windowType;
248  bool _isModal;
249  Common::String _sharedCastFilenameHint;
250  Common::String _soundsFilenameHint;
251 
252 private:
253  static void drawChannelBox(Director::Movie *currentMovie, Graphics::ManagedSurface *blitTo, int selectedChannel);
254  void drawFrameCounter(Graphics::ManagedSurface *blitTo);
255 
256 
257 };
258 
259 } // End of namespace Director
260 
261 #endif
Definition: managed_surface.h:51
Definition: director.h:106
Definition: cast.h:87
Definition: str.h:59
Definition: window.h:47
Definition: channel.h:40
Definition: error.h:81
Definition: array.h:52
Definition: macwindow.h:205
Definition: list.h:44
Definition: rect.h:524
Definition: path.h:52
Definition: window.h:106
Definition: movie.h:88
Definition: archive.h:36
Definition: macwindowmanager.h:147
Definition: archive.h:75
Definition: sound.h:168
Definition: lingo-object.h:71
Definition: hashmap.h:85
Definition: events.h:210
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:144
Definition: lingo.h:130
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
Definition: director.h:157
Definition: types.h:423
Definition: director.h:350
Definition: lingo.h:335