ScummVM API documentation
myst_areas.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 MYST_AREAS_H
23#define MYST_AREAS_H
24
25#include "mohawk/myst.h"
26#include "mohawk/myst_scripts.h"
27#include "mohawk/video.h"
28
29#include "common/rect.h"
30
31namespace Mohawk {
32
33// Myst Resource Types
34enum ResourceType {
35 kMystAreaForward = 0,
36 kMystAreaLeft = 1,
37 kMystAreaRight = 2,
38 kMystAreaDown = 3,
39 kMystAreaUp = 4,
40 kMystAreaAction = 5,
41 kMystAreaVideo = 6,
42 kMystAreaActionSwitch = 7,
43 kMystAreaImageSwitch = 8,
44 kMystAreaSlider = 10,
45 kMystAreaDrag = 11,
46 kMystVideoInfo = 12,
47 kMystAreaHover = 13
48};
49
50// Myst Resource Flags
51// TODO: Figure out other flags
52enum {
53 kMystSubimageEnableFlag = (1 << 0),
54 kMystHotspotEnableFlag = (1 << 1),
55 kMystUnknownFlag = (1 << 2),
56 kMystZipModeEnableFlag = (1 << 3)
57};
58
59class MystArea {
60public:
61 MystArea(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
62 virtual ~MystArea();
63
64 virtual const Common::String describe();
65 void drawBoundingRect();
66
67 bool hasType(ResourceType type) const { return _type == type; }
68 bool contains(Common::Point point) { return _rect.contains(point); }
69 virtual void drawDataToScreen() {}
70 virtual void handleCardChange() {}
71 Common::Rect getRect() { return _rect; }
72 void setRect(const Common::Rect &rect) { _rect = rect; }
73 bool isEnabled();
74 void setEnabled(bool enabled);
75 bool isDrawSubimages() { return _flags & kMystSubimageEnableFlag; }
76 uint16 getDest() { return _dest; }
77 virtual uint16 getImageSwitchVar() { return 0xFFFF; }
78 bool unreachableZipDest();
79 bool canBecomeActive();
80
81 // Mouse interface
82 virtual void handleMouseUp();
83 virtual void handleMouseDown() {}
84 virtual void handleMouseDrag() {}
85
86 MystArea *_parent;
87protected:
89
90 ResourceType _type;
91 uint16 _flags;
92 Common::Rect _rect;
93 uint16 _dest;
94};
95
96class MystAreaAction : public MystArea {
97public:
98 MystAreaAction(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
99
100 void handleMouseUp() override;
101 const Common::String describe() override;
102
103protected:
104 MystScript _script;
105};
106
108public:
109 MystAreaVideo(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
110
111 VideoEntryPtr playMovie();
112 VideoEntryPtr getVideo();
113
114 void handleCardChange() override;
115 bool isPlaying();
116 void setDirection(int16 direction) { _direction = direction; }
117 void setBlocking(bool blocking) { _playBlocking = blocking; }
118 void pauseMovie(bool pause);
119
120protected:
121 static Common::Path convertMystVideoName(const Common::String &name);
122
123 Common::Path _videoFile;
124 int16 _left;
125 int16 _top;
126 uint16 _loop;
127 int16 _direction; // 1 => forward, -1 => backwards
128 uint16 _playBlocking;
129 bool _playOnCardChange;
130 uint16 _playRate; // percents
131};
132
134public:
135 MystAreaActionSwitch(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
136 ~MystAreaActionSwitch() override;
137
138 void drawDataToScreen() override;
139 void handleCardChange() override;
140
141 void handleMouseUp() override;
142 void handleMouseDown() override;
143
144 MystArea *getSubResource(uint16 index) { return _subResources[index]; }
145protected:
146 typedef void (MystArea::*AreaHandler)();
147
148 void doSwitch(AreaHandler handler);
149
150 uint16 _actionSwitchVar;
151 Common::Array<MystArea *> _subResources;
152};
153
155public:
156 MystAreaImageSwitch(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
157 ~MystAreaImageSwitch() override;
158
159 struct SubImage {
160 uint16 wdib;
161 Common::Rect rect;
162 };
163
164 const Common::String describe() override;
165 void drawDataToScreen() override;
166 void drawConditionalDataToScreen(uint16 state, bool update = true);
167 uint16 getImageSwitchVar() override;
168
169 SubImage getSubImage(uint index) const;
170 void setSubImageRect(uint index, const Common::Rect &rect);
171
172protected:
173 uint16 _imageSwitchVar;
174 Common::Array<SubImage> _subImages;
175};
176
178public:
179 MystAreaDrag(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
180 ~MystAreaDrag() override;
181
182 const Common::String describe() override;
183
184 void handleMouseDown() override;
185 void handleMouseUp() override;
186 void handleMouseDrag() override;
187
188 uint16 getList1(uint16 index);
189 uint16 getList2(uint16 index);
190 uint16 getList3(uint16 index);
191
192 uint16 getStepsH() { return _stepsH; }
193 uint16 getStepsV() { return _stepsV; }
194
195 Common::Point _pos;
196protected:
198
199 void setPositionClipping(const Common::Point &mouse, Common::Point &dest);
200
201 uint16 _flagHV;
202 uint16 _minH;
203 uint16 _maxH;
204 uint16 _minV;
205 uint16 _maxV;
206 uint16 _stepsH;
207 uint16 _stepsV;
208 uint16 _stepH;
209 uint16 _stepV;
210 uint16 _mouseDownOpcode;
211 uint16 _mouseDragOpcode;
212 uint16 _mouseUpOpcode;
213 ValueList _lists[3];
214};
215
217public:
218 MystAreaSlider(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
219 ~MystAreaSlider() override;
220
221 void handleMouseDown() override;
222 void handleMouseUp() override;
223 void handleMouseDrag() override;
224 void setStep(uint16 step);
225 void setPosition(uint16 pos);
226 void restoreBackground();
227
228protected:
229 Common::Rect boundingBox();
230 void updatePosition(const Common::Point &mouse);
231
232 uint16 _dragSound;
233 uint16 _sliderWidth;
234 uint16 _sliderHeight;
235};
236
238public:
239 MystVideoInfo(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
240 ~MystVideoInfo() override;
241
242 void drawFrame(uint16 frame);
243 bool pullLeverV();
244 void releaseLeverV();
245 uint16 getNumFrames() { return _numFrames; }
246
247protected:
248 uint16 _numFrames;
249 uint16 _firstFrame;
250 Common::Rect _frameRect;
251};
252
253class MystAreaHover : public MystArea {
254public:
255 MystAreaHover(MohawkEngine_Myst *vm, ResourceType type, Common::SeekableReadStream *rlstStream, MystArea *parent);
256
257 const Common::String describe() override;
258
259 void handleMouseUp() override;
260 void handleMouseEnter();
261 void handleMouseLeave();
262
263protected:
264 uint16 _enterOpcode;
265 uint16 _leaveOpcode;
266};
267
268} // End of namespace Mohawk
269
270#endif
Definition: path.h:52
Definition: stream.h:745
Definition: str.h:59
Definition: myst.h:129
Definition: myst_areas.h:96
Definition: myst_areas.h:133
Definition: myst_areas.h:177
Definition: myst_areas.h:253
Definition: myst_areas.h:59
Definition: myst_areas.h:154
Definition: myst_areas.h:216
Definition: myst_areas.h:107
Definition: myst_areas.h:237
Definition: bitmap.h:32
Definition: rect.h:144
bool contains(T x, T y) const
Definition: rect.h:246
Definition: rect.h:536
Definition: myst_areas.h:159