ScummVM API documentation
gfx.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 HDB_GFX_H
23#define HDB_GFX_H
24
25#include "graphics/managed_surface.h"
26#include "graphics/screen.h"
27
28namespace Math {
29 class SineTable;
30 class CosineTable;
31}
32
33namespace HDB {
34
35#define HDB_FONT "normalprop"
36
37struct TileLookup {
38 const char *filename;
39 Tile *tData;
40 uint16 skyIndex;
41 uint16 animIndex;
42
43 TileLookup() : filename(nullptr), tData(nullptr), skyIndex(0), animIndex(0) {}
44};
45
46struct GfxCache {
47 char name[32];
48 bool status; // false = tileGfx, true = picGfx
49 union {
50 Tile *tileGfx;
51 Picture *picGfx;
52 };
53 uint32 size;
54 int16 loaded;
55
56 GfxCache() : status(false), tileGfx(nullptr), size(0), loaded(0) { name[0] = 0; }
57};
58
59struct FontInfo {
60 int type; // 0 = mono, 1 = proportional
61 int numChars; // how many characters in font
62 int height; // height of entire font
63 int kerning; // space between chars
64 int leading; // space between lines
65};
66
67struct CharInfo {
68 int16 width; // Character width in pixels
69 int32 offset; // From the start of the font charInfo chunk
70};
71
72class Gfx {
73public:
74
75 Gfx();
76 ~Gfx();
77
78 Graphics::Screen _globalSurface;
79
80 void init();
81 void save(Common::OutSaveFile *out);
82 void loadSaveFile(Common::InSaveFile *in);
83 void fillScreen();
84 void updateVideo();
85 void setPointerState(int value);
86 void drawPointer();
87 void showPointer(bool status) {
88 _showCursor = status;
89 }
90 bool getPointer() {
91 return _showCursor;
92 }
93
94 void setFade(bool fadeIn, bool black, int steps);
95 void updateFade();
96 bool isFadeActive() { return _fadeInfo.active; }
97 bool isFadeStaying() { return _fadeInfo.stayFaded; }
98 void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
99 void turnOnSnow();
100 void turnOffSnow() { _snowInfo.active = false; }
101
102 Picture *loadPic(const char *picName);
103 Tile *loadTile(const char *tileName);
104 Tile *loadIcon(const char *tileName);
105 void setPixel(int x, int y, uint32 color);
106
107 Tile *getTile(int index);
108 void cacheTileSequence(int index, int count);
109 int getTileIndex(const char *name);
110 Picture *getPicture(const char *name);
111
112 void emptyGfxCaches();
113 void markTileCacheFreeable();
114 void markGfxCacheFreeable();
115
116 // Returns: true->Tile, false->Pic
117 bool selectGfxType(const char *name);
118 Tile *getTileGfx(const char *name, int32 size);
119 Picture *getPicGfx(const char *name, int32 size);
120
121 int isSky(int skyIndex);
122 void setSky(int skyIndex);
123 void setup3DStars();
124 void setup3DStarsLeft();
125 void draw3DStars();
126 void draw3DStarsLeft();
127 void drawSky();
128 void drawSnow();
129
130 int animateTile(int tileIndex);
131
132 // Font Functions
133
134 bool loadFont(const char *string);
135 void drawText(const char *string);
136 void getDimensions(const char *string, int *pixelsWide, int *lines);
137 int stringLength(const char *string);
138 void centerPrint(const char *string);
139 void setTextEdges(int left, int right, int top, int bottom);
140 void getTextEdges(int *left, int *right, int *top, int *bottom);
141 void setKernLead(int kern, int lead);
142 void getKernLead(int *kern, int *lead);
143 void setCursor(int x, int y);
144 void getCursor(int *x, int *y);
145
146 // Trig Functions
147
148 double getSin(int index);
149 double getCos(int index);
150
151 // Bonus star functions
152
153 void turnOnBonusStars(int which);
154 void drawBonusStars();
155
156 void drawDebugInfo(Tile *_debugLogo, int fps);
157
158private:
159 int _numTiles;
160 TileLookup *_tLookupArray;
161 uint16 _skyTiles[kMaxSkies];
162
163 Graphics::ManagedSurface _fadeBuffer1, _fadeBuffer2;
164
165 Common::Array<GfxCache *> *_gfxCache;
166
167 int _currentSky; // 0 if no Sky, 1+ for which Sky to use
168 struct {
169 bool active;
170 bool stayFaded;
171 bool isBlack;
172 int speed;
173 bool isFadeIn;
174
175 int curStep;
176 } _fadeInfo;
177
178#define MAX_SNOW 50 // how many snowflakes onscreen
179#define MAX_SNOW_XV 12
180 struct {
181 bool active;
182 double x[MAX_SNOW];
183 double y[MAX_SNOW];
184 double yv[MAX_SNOW];
185 int xvindex[MAX_SNOW];
186 } _snowInfo;
187
188 struct {
189 int x, y, speed;
190 uint32 color;
191 } _stars3D[kNum3DStars];
192
193 struct {
194 double x, y, speed;
195 uint32 color;
196 } _stars3DSlow[kNum3DStars];
197
198 int _tileSkyStars; // Index of sky_stars tile
199 int _tileSkyStarsLeft; // Left-scrolling stars, slow
200 int _tileSkyClouds; // Index of sky_stars tile
201 Picture *_starField[4];
202 Picture *_snowflake;
203 Picture *_skyClouds;
204
205 struct {
206 bool active;
207 int starAngle[10];
208 Picture *gfx[2];
209 uint32 timer;
210 int anim, radius;
211 double angleSpeed;
212 uint32 totalTime;
213 } _starsInfo;
214
215 // Cursor
216 int _cursorX, _cursorY;
217 Picture *_mousePointer[8]; // Gfx for screen pointer (4 Animations)
218 int _pointerDisplayable;
219 bool _showCursor;
220
221 // Font Data
222
223 FontInfo _fontHeader;
224 Common::Array<CharInfo *> _charInfoBlocks;
225 Graphics::ManagedSurface _fontSurfaces[256];
226 uint16 _fontGfx;
227 int _eLeft, _eRight, _eTop, _eBottom;
228
229 bool _systemInit;
230
231 Math::SineTable *_sines;
232 Math::CosineTable *_cosines;
233};
234
235class Picture {
236public:
237
238 Picture();
239 ~Picture();
240
242 int draw(int x, int y);
243 int drawMasked(int x, int y, uint8 alpha = 0xff);
244
245 int _width, _height;
246
247 char *getName() { return _name; }
248
249 Graphics::ManagedSurface *getSurface() { return &_surface; }
250
251private:
252 char _name[64];
253
255};
256
257class Tile {
258public:
259
260 Tile();
261 ~Tile();
262
264 int draw(int x, int y);
265 int drawMasked(int x, int y, uint8 alpha = 0xff);
266
267 uint32 _flags;
268
269 char *getName() { return _name; }
270private:
271 char _name[64];
272
274};
275
276} // End of Namespace HDB
277
278#endif // !HDB_GFX_H
Definition: array.h:52
Definition: savefile.h:54
Definition: stream.h:745
Definition: managed_surface.h:51
Definition: screen.h:47
Definition: gfx.h:72
Definition: gfx.h:235
Definition: gfx.h:257
Definition: surface.h:67
Definition: gfx.h:67
Definition: gfx.h:59
Definition: gfx.h:46
Definition: gfx.h:37