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 "director/lingo/lingo-object.h"
26 
27 namespace Common {
28 class Error;
29 }
30 
31 namespace Graphics {
32 class ManagedSurface;
33 class MacWindow;
34 class MacWindowManager;
35 }
36 
37 namespace Director {
38 
39 class Channel;
40 class MacArchive;
41 struct MacShape;
42 struct LingoState;
43 
44 struct TransParams {
45  TransitionType type;
46  uint frame;
47  uint duration;
48  uint chunkSize;
49  uint area;
50 
51  int steps;
52  int stepDuration;
53 
54  int xStepSize;
55  int yStepSize;
56 
57  int xpos, ypos;
58 
59  int stripSize;
60 
61  const byte *sourcePal;
62  uint16 sourcePalLength;
63  const byte *targetPal;
64  uint16 targetPalLength;
65  byte tempPal[768];
66 
67  TransParams() : tempPal() {
68  type = kTransNone;
69  frame = 0;
70  duration = 250;
71  chunkSize = 1;
72  area = 0;
73  steps = 0;
74  stepDuration = 0;
75  stripSize = 0;
76 
77  xStepSize = yStepSize = 0;
78  xpos = ypos = 0;
79 
80  sourcePal = nullptr;
81  sourcePalLength = 0;
82  targetPal = nullptr;
83  targetPalLength = 0;
84  }
85 
86  TransParams(uint16 d, uint16 a, uint16 c, TransitionType t) :
87  duration(d), area(a), chunkSize(c), type(t), tempPal() {
88  frame = 0;
89  steps = 0;
90  stepDuration = 0;
91  stripSize = 0;
92 
93  xStepSize = yStepSize = 0;
94  xpos = ypos = 0;
95 
96  sourcePal = nullptr;
97  sourcePalLength = 0;
98  targetPal = nullptr;
99  targetPalLength = 0;
100  }
101 };
102 
103 class Window : public Graphics::MacWindow, public Object<Window> {
104 public:
105  Window(int id, bool scrollable, bool resizable, bool editable, Graphics::MacWindowManager *wm, DirectorEngine *vm, bool isStage);
106  ~Window();
107 
108  void decRefCount() override;
109  bool render(bool forceRedraw = false, Graphics::ManagedSurface *blitTo = nullptr);
110  void invertChannel(Channel *channel, const Common::Rect &destRect);
111 
112  bool needsAppliedColor(DirectorPlotData *pd);
113  void setStageColor(uint32 stageColor, bool forceReset = false);
114  uint32 getStageColor() { return _stageColor; }
115 
116  void reset();
117 
118  // transitions.cpp
119  void exitTransition(TransParams &t, Graphics::ManagedSurface *nextFrame, Common::Rect clipRect);
120  void stepTransition(TransParams &t, int step);
121  void playTransition(uint frame, RenderMode mode, uint16 transDuration, uint8 transArea, uint8 transChunkSize, TransitionType transType, CastMemberID paletteId);
122  void initTransParams(TransParams &t, Common::Rect &clipRect);
123  void dissolveTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
124  void dissolvePatternsTrans(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
125  void transMultiPass(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *tmpSurface);
126  void transZoom(TransParams &t, Common::Rect &clipRect, Graphics::ManagedSurface *currentFrame, Graphics::ManagedSurface *nextFrame);
127 
128  // window.cpp
129  Common::Point getMousePos();
130 
131  DirectorEngine *getVM() const { return _vm; }
132  Archive *getMainArchive() const { return _mainArchive; }
133  Movie *getCurrentMovie() const { return _currentMovie; }
134  Common::String getCurrentPath() const { return _currentPath; }
135  DirectorSound *getSoundManager() const { return _soundManager; }
136 
137  void setVisible(bool visible, bool silent = false) override;
138  bool setNextMovie(Common::String &movieFilenameRaw);
139 
140  void ensureMovieIsLoaded();
141 
142  void setWindowType(int type) { _windowType = type; updateBorderType(); }
143  int getWindowType() const { return _windowType; }
144  void setTitleVisible(bool titleVisible) override;
145  Datum getStageRect();
146  bool setStageRect(Datum datum);
147  void setModal(bool modal);
148  bool getModal() { return _isModal; };
149  void setFileName(Common::String filename);
150  Common::String getFileName() { return _fileName.toString(g_director->_dirSeparator); }
151 
152  void updateBorderType();
153 
154  bool step();
155  bool loadNextMovie();
156  void loadNewSharedCast(Cast *previousSharedCast);
157 
158  Common::Path getSharedCastPath();
159 
160  LingoState *getLingoState() { return _lingoState; };
161  LingoState *getLingoPlayState() { return _lingoPlayState; };
162  uint32 frozenLingoStateCount() { return _frozenLingoStates.size(); };
163  uint32 frozenLingoRecursionCount();
164  void freezeLingoState();
165  void thawLingoState();
166  void freezeLingoPlayState();
167  bool thawLingoPlayState();
168  LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
169 
170  // events.cpp
171  bool processEvent(Common::Event &event) override;
172 
173  // tests.cpp
174  Common::HashMap<Common::String, Movie *> *scanMovies(const Common::Path &folder);
175  void testFontScaling();
176  void testFonts();
177  void enqueueAllMovies();
178  MovieReference getNextMovieFromQueue();
179  void runTests();
180 
181  // resource.cpp
182  Common::Error loadInitialMovie();
183  void probeResources(Archive *archive);
184  void loadINIStream();
185  void loadStartMovieXLibs();
186 
187  // lingo/lingo-object.cpp
188  Common::String asString() override;
189  bool hasProp(const Common::String &propName) override;
190  Datum getProp(const Common::String &propName) override;
191  bool setProp(const Common::String &propName, const Datum &value, bool force = false) override;
192  bool hasField(int field) override;
193  Datum getField(int field) override;
194  bool setField(int field, const Datum &value) override;
195 
196  Common::Path _fileName;
197 
198 public:
199  Common::List<Channel *> _dirtyChannels;
200  TransParams *_puppetTransition;
201 
202  MovieReference _nextMovie;
203  Common::List<MovieReference> _movieStack;
204  bool _newMovieStarted;
205 
206 private:
207  uint32 _stageColor;
208 
209  DirectorEngine *_vm;
210  DirectorSound *_soundManager;
211  LingoState *_lingoState;
212  Common::Array<LingoState *> _frozenLingoStates;
213  LingoState *_lingoPlayState;
214  bool _isStage;
215  Archive *_mainArchive;
216  Movie *_currentMovie;
217  Common::String _currentPath;
218  Common::StringArray _movieQueue;
219  int16 _startFrame;
220 
221  int _windowType;
222  bool _isModal;
223 
224 private:
225  void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
226  void drawFrameCounter(Graphics::ManagedSurface *blitTo);
227 
228 
229 };
230 
231 } // End of namespace Director
232 
233 #endif
Definition: managed_surface.h:51
Definition: director.h:99
Definition: cast.h:85
Definition: str.h:59
Definition: window.h:44
Definition: channel.h:40
Definition: error.h:84
Definition: array.h:52
Definition: macwindow.h:192
Definition: list.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: window.h:103
Definition: movie.h:87
Definition: archive.h:35
Definition: macwindowmanager.h:148
Definition: archive.h:53
Definition: sound.h:156
Definition: lingo-object.h:71
Definition: hashmap.h:85
Definition: events.h:199
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: lingo.h:130
Definition: director.h:150
Definition: types.h:413
Definition: director.h:330
Definition: lingo.h:325