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  Movie *getCurrentMovie() const { return _currentMovie; }
133  Common::String getCurrentPath() const { return _currentPath; }
134  DirectorSound *getSoundManager() const { return _soundManager; }
135 
136  void setVisible(bool visible, bool silent = false) override;
137  bool setNextMovie(Common::String &movieFilenameRaw);
138 
139  void ensureMovieIsLoaded();
140 
141  void setWindowType(int type) { _windowType = type; updateBorderType(); }
142  int getWindowType() const { return _windowType; }
143  void setTitleVisible(bool titleVisible) override;
144  Datum getStageRect();
145  bool setStageRect(Datum datum);
146  void setModal(bool modal);
147  bool getModal() { return _isModal; };
148  void setFileName(Common::String filename);
149  Common::String getFileName() { return _fileName.toString(g_director->_dirSeparator); }
150 
151  void updateBorderType();
152 
153  bool step();
154  bool loadNextMovie();
155  void loadNewSharedCast(Cast *previousSharedCast);
156 
157  Common::Path getSharedCastPath();
158 
159  LingoState *getLingoState() { return _lingoState; };
160  LingoState *getLingoPlayState() { return _lingoPlayState; };
161  uint32 frozenLingoStateCount() { return _frozenLingoStates.size(); };
162  uint32 frozenLingoRecursionCount();
163  void freezeLingoState();
164  void thawLingoState();
165  void freezeLingoPlayState();
166  bool thawLingoPlayState();
167  LingoState *getLastFrozenLingoState() { return _frozenLingoStates.empty() ? nullptr : _frozenLingoStates[_frozenLingoStates.size() - 1]; }
168  void moveLingoState(Window *target);
169 
170  Common::String formatWindowInfo();
171 
172  static void inkBlitFrom(Channel *channel, Common::Rect destRect, Graphics::ManagedSurface *blitTo = nullptr);
173 
174  // events.cpp
175  bool processEvent(Common::Event &event) override;
176 
177  // tests.cpp
178  Common::HashMap<Common::String, Movie *> *scanMovies(const Common::Path &folder);
179  void testFontScaling();
180  void testFonts();
181  void enqueueAllMovies();
182  MovieReference getNextMovieFromQueue();
183  void runTests();
184 
185  // resource.cpp
186  Common::Error loadInitialMovie();
187  void probeResources(Archive *archive);
188  void loadINIStream();
189  void loadXtrasFromPath();
190  void loadStartMovieXLibs();
191 
192  // lingo/lingo-object.cpp
193  Common::String asString() override;
194  bool hasProp(const Common::String &propName) override;
195  Datum getProp(const Common::String &propName) override;
196  bool setProp(const Common::String &propName, const Datum &value, bool force = false) override;
197  bool hasField(int field) override;
198  Datum getField(int field) override;
199  bool setField(int field, const Datum &value) override;
200 
201  Common::Path _fileName;
202 
203 public:
204  Common::List<Channel *> _dirtyChannels;
205  TransParams *_puppetTransition;
206 
207  MovieReference _nextMovie;
208  Common::List<MovieReference> _movieStack;
209  bool _newMovieStarted;
210  bool _skipFrameAdvance;
211 
212 private:
213  uint32 _stageColor;
214 
215  DirectorEngine *_vm;
216  DirectorSound *_soundManager;
217  LingoState *_lingoState;
218  Common::Array<LingoState *> _frozenLingoStates;
219  LingoState *_lingoPlayState;
220  bool _isStage;
221  Movie *_currentMovie;
222  Common::String _currentPath;
223  Common::StringArray _movieQueue;
224  int16 _startFrame;
225 
226  int _windowType;
227  bool _isModal;
228  Common::String _sharedCastFilenameHint;
229  Common::String _soundsFilenameHint;
230 
231 private:
232  static void drawChannelBox(Director::Movie *currentMovie, Graphics::ManagedSurface *blitTo, int selectedChannel);
233  void drawFrameCounter(Graphics::ManagedSurface *blitTo);
234 
235 
236 };
237 
238 } // End of namespace Director
239 
240 #endif
Definition: managed_surface.h:51
Definition: director.h:105
Definition: cast.h:87
Definition: str.h:59
Definition: window.h:44
Definition: channel.h:40
Definition: error.h:81
Definition: array.h:52
Definition: macwindow.h:192
Definition: list.h:44
Definition: rect.h:524
Definition: path.h:52
Definition: window.h:103
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
Definition: director.h:156
Definition: types.h:411
Definition: director.h:347
Definition: lingo.h:327