ScummVM API documentation
riven_graphics.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 MOHAWK_RIVEN_GRAPHICS_H
23#define MOHAWK_RIVEN_GRAPHICS_H
24
25#include "mohawk/graphics.h"
26#include "mohawk/riven_graphics_detection_enums.h"
27
28#include "common/ustr.h"
29
30namespace Graphics {
31class Font;
32}
33
34namespace Mohawk {
35
36class MohawkEngine_Riven;
37class FliesEffect;
38class WaterEffect;
39
40enum RivenTransition {
41 kRivenTransitionNone = -1,
42 kRivenTransitionWipeLeft = 0,
43 kRivenTransitionWipeRight = 1,
44 kRivenTransitionWipeUp = 2,
45 kRivenTransitionWipeDown = 3,
46 kRivenTransitionPanLeft = 12,
47 kRivenTransitionPanRight = 13,
48 kRivenTransitionPanUp = 14,
49 kRivenTransitionPanDown = 15,
50 kRivenTransitionBlend = 16,
51 kRivenTransitionBlend2 = 17
52};
53
54enum RivenCreditsImageNumber {
55 kRivenCreditsZeroImage = 302,
56 kRivenCreditsFirstImage = 303,
57 kRivenCreditsSecondImage = 304,
58 kRivenCreditsLastImage = 320
59};
60
62public:
64 ~RivenGraphics() override;
65
66 // Screen updates
67 void beginScreenUpdate();
68 void applyScreenUpdate(bool force = false);
69 void enableCardUpdateScript(bool enable);
70
71 void copyImageToScreen(uint16 image, uint32 left, uint32 top, uint32 right, uint32 bottom);
72 void drawRect(const Common::Rect &rect, bool active);
73 void drawImageRect(uint16 id, const Common::Rect &srcRect, const Common::Rect &dstRect);
74 void drawExtrasImage(uint16 id, const Common::Rect &dstRect);
75 void drawExtrasImageToScreen(uint16 id, const Common::Rect &rect);
76
79
80 Graphics::Surface *getEffectScreen();
81 Graphics::Surface *getBackScreen();
82
83 // Water Effect
84 void scheduleWaterEffect(uint16);
85 void clearWaterEffect();
86
87 // Flies Effect
88 void setFliesEffect(uint16 count, bool fireflies);
89 void clearFliesEffect();
90
93
94 // Transitions
95 void scheduleTransition(RivenTransition id, const Common::Rect &rect = Common::Rect(0, 0, 608, 392));
96 void runScheduledTransition();
97 void fadeToBlack();
98 void setTransitionMode(RivenTransitionMode mode);
99 static RivenTransitionMode sanitizeTransitionMode(int mode);
100
101 // Main menu
102 void loadMenuFont();
103 void drawText(const Common::U32String &text, const Common::Rect &dest, uint8 greyLevel);
104
105 // Credits
106 void beginCredits();
107 void updateCredits();
108 uint getCurCreditsImage() const { return _creditsImage; }
109
110protected:
111 MohawkSurface *decodeImage(uint16 id) override;
112 MohawkEngine *getVM() override { return (MohawkEngine *)_vm; }
113
114private:
115 MohawkEngine_Riven *_vm;
116 MohawkBitmap *_bitmapDecoder;
117 int _screenUpdateNesting;
118 bool _screenUpdateRunning;
119 bool _enableCardUpdateScript;
120
121 // Effects
122 WaterEffect *_waterEffect;
123 FliesEffect *_fliesEffect;
124
125 // Transitions
126 RivenTransition _scheduledTransition;
127 Common::Rect _transitionRect;
128 RivenTransitionMode _transitionMode;
129 uint _transitionFrames;
130 uint _transitionDuration;
131 int16 _transitionOffset;
132
133 // Screen Related
134 Graphics::Surface *_mainScreen;
135 Graphics::Surface *_effectScreen;
136 bool _dirtyScreen;
137
138 Graphics::PixelFormat _pixelFormat;
139 void updateScreen();
140 void clearMainScreen();
141
142 // Main menu
143 Graphics::Font *_menuFont;
144 const Graphics::Font *getMenuFont() const;
145
146 // Credits
147 uint _creditsImage, _creditsPos;
148};
149
154public:
155 WaterEffect(MohawkEngine_Riven *vm, uint16 sfxeID);
156 ~WaterEffect();
157
158 void update();
159
160private:
162
163 // Record values
164 Common::Rect _rect;
165 uint16 _speed;
167
168 // Cur frame
169 uint16 _curFrame;
170 uint32 _lastFrameTime;
171};
172
180public:
181 FliesEffect(MohawkEngine_Riven *vm, uint16 count, bool fireflies);
182 ~FliesEffect();
183
185 void update();
186
187private:
188 struct FliesEffectEntry {
189 bool light;
190 int posX;
191 int posY;
192 int posZ;
193 const uint16 *alphaMap;
194 uint width;
195 uint height;
196 int framesTillLightSwitch;
197 bool hasBlur;
198 int blurPosX;
199 int blurPosY;
200 const uint16 *blurAlphaMap;
201 uint blurWidth;
202 uint blurHeight;
203 float posXFloat;
204 float posYFloat;
205 float posZFloat;
206 float directionAngleRad;
207 float directionAngleRadZ;
208 float speed;
209 };
210
211 struct FliesEffectData {
212 bool lightable;
213 bool unlightIfTooBright;
214 bool isLarge;
215 bool canBlur;
216 float maxSpeed;
217 float minSpeed;
218 int maxAcceleration;
219 float blurSpeedTreshold;
220 float blurDistance;
221 uint32 color32;
222 int minFramesLit;
223 int maxLightDuration;
224 };
225
226 MohawkEngine_Riven *_vm;
227
228 uint _nextUpdateTime;
229 int _updatePeriodMs;
230
231 Common::Rect _gameRect;
232 Graphics::Surface *_effectSurface;
233 Graphics::Surface *_backSurface;
234 Common::Array<Common::Rect> _screenSurfaceDirtyRects;
235 Common::Array<Common::Rect> _effectsSurfaceDirtyRects;
236
237 const FliesEffectData *_parameters;
238 static const FliesEffectData _firefliesParameters;
239 static const FliesEffectData _fliesParameters;
240
242
243 void initFlies(uint16 count);
244 void initFlyRandomPosition(uint index);
245 void initFlyAtPosition(uint index, int posX, int posY, int posZ);
246
247 void updateFlies();
248 void updateFlyPosition(uint index);
249
250 void draw();
251 void updateScreen();
252
253 void selectAlphaMap(bool horGridOffset, bool vertGridoffset, const uint16 **alphaMap, uint *width, uint *height);
254 void colorBlending(uint32 flyColor, byte &r, byte &g, byte &b, int alpha);
255
256 void addToScreenDirtyRects(const Common::Rect &rect);
257 void addToEffectsDirtyRects(const Common::Rect &rect);
258 void restoreEffectsSurface();
259
260 int randomBetween(int min, int max);
261};
262
263} // End of namespace Mohawk
264
265#endif
Definition: ustr.h:57
Definition: font.h:83
Definition: riven_graphics.h:179
Definition: graphics.h:68
Definition: riven.h:91
Definition: mohawk.h:54
Definition: graphics.h:40
Definition: riven_graphics.h:61
void copySystemRectToScreen(const Common::Rect &rect)
Definition: riven_graphics.h:153
Definition: formatinfo.h:28
Definition: bitmap.h:32
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: surface.h:67