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 invertChannel(Channel *channel, const Common::Rect &destRect);
113 
114  bool needsAppliedColor(DirectorPlotData *pd);
115  void setStageColor(uint32 stageColor, bool forceReset = false);
116  uint32 getStageColor() { return _stageColor; }
117 
118  void reset();
119 
120  // transitions.cpp
121  void exitTransition(TransParams &t, Graphics::ManagedSurface *nextFrame, Common::Rect clipRect);
122  void stepTransition(TransParams &t, int step);
123  void playTransition(uint frame, RenderMode mode, uint16 transDuration, uint8 transArea, uint8 transChunkSize, TransitionType transType, CastMemberID paletteId);
124  void initTransParams(TransParams &t, Common::Rect &clipRect);
125  void dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
126  void dissolvePatternsTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
127  void transMultiPass(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
128  void transZoom(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *currentFrame, Graphics::ManagedSurface *nextFrame);
129 
130  // window.cpp
131  Common::Point getMousePos();
132 
133  DirectorEngine *getVM() const { return _vm; }
134  Graphics::MacWindow *getMacWindow() const { return _window; }
135  Movie *getCurrentMovie() const { return _currentMovie; }
136  Common::String getCurrentPath() const { return _currentPath; }
137  DirectorSound *getSoundManager() const { return _soundManager; }
138 
139  void setVisible(bool visible, bool silent = false);
140  bool setNextMovie(Common::String &movieFilenameRaw);
141 
142  void ensureMovieIsLoaded();
143 
144  void setWindowType(int type) { _windowType = type; updateBorderType(); }
145  int getWindowType() const { return _windowType; }
146  void setTitleVisible(bool titleVisible);
147  Graphics::ManagedSurface *getSurface();
148  void addDirtyRect(const Common::Rect &r);
149  void resizeInner(int w, int h);
150  int getId();
151  void setDirty(bool dirty);
152  void disableBorder();
153  void center(bool toCenter = true);
154  Common::Point getAbsolutePos();
155  void setTitle(const Common::String &title);
156  void move(int x, int y);
157 
158  Datum getStageRect();
159  void setStageRect(Datum datum);
160  void setModal(bool modal);
161  bool getModal() { return _isModal; };
162  void setFileName(Common::String filename);
163  Common::String getFileName() { return _fileName.toString(g_director->_dirSeparator); }
164 
165  void updateBorderType();
166 
167  bool step();
168  bool loadNextMovie();
169  void loadNewSharedCast(Cast *previousSharedCast);
170 
171  Common::Path getSharedCastPath();
172 
173  LingoState *getLingoState() { return _lingoState; };
174  LingoState *getLingoPlayState() { return _lingoPlayState; };
175  uint32 frozenLingoStateCount() { return _frozenLingoStates.size(); };
176  uint32 frozenLingoRecursionCount();
177  void freezeLingoState();
178  void thawLingoState();
179  void freezeLingoPlayState();
180  bool thawLingoPlayState();
181  LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
182  void moveLingoState(Window *target);
183 
184  Common::String formatWindowInfo();
185 
186  static void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
187 
188  // events.cpp
189  bool processEvent(Common::Event &event);
190  bool processWMEvent(Graphics::WindowClick click, Common::Event &event);
191  void sendWindowEvent(LEvent event);
192 
193  // tests.cpp
194  Common::HashMap<Common::String, Movie *> *scanMovies(const Common::Path &folder);
195  void testFontScaling();
196  void testFonts();
197  void enqueueAllMovies();
198  MovieReference getNextMovieFromQueue();
199  void runTests();
200 
201  // resource.cpp
202  Common::Error loadInitialMovie();
203  void probeResources(Archive *archive);
204  void loadINIStream();
205  void loadXtrasFromPath();
206  void loadStartMovieXLibs();
207 
208  // lingo/lingo-object.cpp
209  Common::String asString() override;
210  bool hasProp(const Common::String &propName) override;
211  Datum getProp(const Common::String &propName) override;
212  void setProp(const Common::String &propName, const Datum &value, bool force = false) override;
213  bool hasField(int field) override;
214  Datum getField(int field) override;
215  void setField(int field, const Datum &value) override;
216 
217  Common::Path _fileName;
218 
219 public:
220  Graphics::MacWindow *_window;
222 
223  Common::List<Channel *> _dirtyChannels;
224  TransParams *_puppetTransition;
225 
226  MovieReference _nextMovie;
227  Common::List<MovieReference> _movieStack;
228  bool _newMovieStarted;
229  bool _skipFrameAdvance;
230 
231 private:
232  uint32 _stageColor;
233 
234  DirectorEngine *_vm;
235  DirectorSound *_soundManager;
236  LingoState *_lingoState;
237  Common::Array<LingoState *> _frozenLingoStates;
238  LingoState *_lingoPlayState;
239  bool _isStage;
240  Movie *_currentMovie;
241  Common::String _currentPath;
242  Common::StringArray _movieQueue;
243  int16 _startFrame;
244 
245  int _windowType;
246  bool _isModal;
247  Common::String _sharedCastFilenameHint;
248  Common::String _soundsFilenameHint;
249 
250 private:
251  static void drawChannelBox(Director::Movie *currentMovie, Graphics::ManagedSurface *blitTo, int selectedChannel);
252  void drawFrameCounter(Graphics::ManagedSurface *blitTo);
253 
254 
255 };
256 
257 } // End of namespace Director
258 
259 #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:203
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:164
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:419
Definition: director.h:350
Definition: lingo.h:334