2019-05-31 07:21:09 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-07-24 10:07:37 +00:00
|
|
|
#ifndef HDB_GFX_H
|
|
|
|
#define HDB_GFX_H
|
2019-05-31 07:21:09 +00:00
|
|
|
|
2019-06-07 22:25:38 +00:00
|
|
|
#include "graphics/managed_surface.h"
|
2019-05-31 07:21:09 +00:00
|
|
|
|
|
|
|
namespace HDB {
|
|
|
|
|
2019-06-07 16:57:29 +00:00
|
|
|
struct TileLookup {
|
|
|
|
const char *filename;
|
|
|
|
Tile *tData;
|
|
|
|
uint16 skyIndex;
|
|
|
|
uint16 animIndex;
|
2019-06-08 11:27:28 +00:00
|
|
|
|
|
|
|
TileLookup() : filename(NULL), tData(NULL), skyIndex(0), animIndex(0) {}
|
2019-06-07 16:57:29 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 23:44:37 +00:00
|
|
|
struct GfxCache {
|
|
|
|
char name[32];
|
2019-07-18 13:38:59 +00:00
|
|
|
bool status; // false = tileGfx, true = picGfx
|
2019-06-20 23:21:19 +00:00
|
|
|
union {
|
|
|
|
Tile *tileGfx;
|
|
|
|
Picture *picGfx;
|
|
|
|
};
|
2019-06-19 23:44:37 +00:00
|
|
|
uint32 size;
|
2019-06-20 14:57:49 +00:00
|
|
|
int16 loaded;
|
2019-06-19 23:44:37 +00:00
|
|
|
|
2019-07-18 13:38:59 +00:00
|
|
|
GfxCache() : status(false), tileGfx(NULL), size(0), loaded(0) { name[0] = 0; }
|
2019-06-19 23:44:37 +00:00
|
|
|
};
|
2019-06-08 11:27:28 +00:00
|
|
|
|
2019-06-23 00:13:08 +00:00
|
|
|
struct FontInfo {
|
2019-06-23 14:38:53 +00:00
|
|
|
int type; // 0 = mono, 1 = proportional
|
|
|
|
int numChars; // how many characters in font
|
|
|
|
int height; // height of entire font
|
|
|
|
int kerning; // space between chars
|
|
|
|
int leading; // space between lines
|
2019-06-23 00:13:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CharInfo {
|
2019-06-23 14:38:53 +00:00
|
|
|
int16 width; // Character width in pixels
|
|
|
|
int32 offset; // From the start of the font charInfo chunk
|
2019-06-23 00:13:08 +00:00
|
|
|
};
|
|
|
|
|
2019-07-01 22:49:56 +00:00
|
|
|
class Gfx {
|
2019-05-31 07:21:09 +00:00
|
|
|
public:
|
|
|
|
|
2019-07-01 22:49:56 +00:00
|
|
|
Gfx();
|
|
|
|
~Gfx();
|
2019-05-31 07:21:09 +00:00
|
|
|
|
2019-06-17 17:03:52 +00:00
|
|
|
Graphics::ManagedSurface _globalSurface;
|
|
|
|
|
2019-05-31 07:21:09 +00:00
|
|
|
bool init();
|
2019-07-06 15:04:54 +00:00
|
|
|
void save(Common::OutSaveFile *out);
|
|
|
|
void loadSaveFile(Common::InSaveFile *in);
|
2019-06-08 17:39:05 +00:00
|
|
|
void fillScreen(uint32 color);
|
2019-06-18 17:38:03 +00:00
|
|
|
void updateVideo();
|
2019-06-28 15:25:12 +00:00
|
|
|
void setPointerState(int value);
|
|
|
|
void drawPointer();
|
|
|
|
void showPointer(bool status) {
|
|
|
|
_showCursor = status;
|
|
|
|
}
|
|
|
|
bool getPointer() {
|
|
|
|
return _showCursor;
|
|
|
|
}
|
2019-06-18 17:38:03 +00:00
|
|
|
|
2019-06-18 11:28:58 +00:00
|
|
|
void setFade(bool fadeIn, bool black, int steps);
|
2019-06-18 11:29:40 +00:00
|
|
|
void updateFade();
|
2019-06-18 11:36:30 +00:00
|
|
|
bool isFadeActive() { return _fadeInfo.active; }
|
|
|
|
bool isFadeStaying() { return _fadeInfo.stayFaded; }
|
|
|
|
void turnOffFade() { _fadeInfo.active = _fadeInfo.stayFaded = false; }
|
2019-07-05 20:17:05 +00:00
|
|
|
void turnOnSnow();
|
2019-07-03 15:01:00 +00:00
|
|
|
void turnOffSnow() { _snowInfo.active = false; }
|
2019-06-18 11:28:58 +00:00
|
|
|
|
2019-06-22 21:13:22 +00:00
|
|
|
Picture *loadPic(const char *picName);
|
2019-06-25 05:31:19 +00:00
|
|
|
Tile *loadTile(const char *tileName);
|
2019-07-15 06:19:22 +00:00
|
|
|
Tile *loadIcon(const char *tileName);
|
2019-06-22 21:13:22 +00:00
|
|
|
|
2019-06-07 17:53:58 +00:00
|
|
|
Tile *getTile(int index);
|
2019-06-22 16:51:40 +00:00
|
|
|
void cacheTileSequence(int index, int count);
|
2019-06-07 18:48:30 +00:00
|
|
|
int getTileIndex(const char *name);
|
|
|
|
Picture *getPicture(const char *name);
|
2019-06-18 11:28:58 +00:00
|
|
|
|
2019-07-03 15:01:00 +00:00
|
|
|
void emptyGfxCaches();
|
2019-07-13 14:04:05 +00:00
|
|
|
void markTileCacheFreeable();
|
|
|
|
void markGfxCacheFreeable();
|
2019-07-03 15:01:00 +00:00
|
|
|
|
2019-06-20 23:25:31 +00:00
|
|
|
// Returns: true->Tile, false->Pic
|
|
|
|
bool selectGfxType(const char *name);
|
2019-07-03 19:49:13 +00:00
|
|
|
Tile *getTileGfx(const char *name, int32 size);
|
|
|
|
Picture *getPicGfx(const char *name, int32 size);
|
2019-06-19 23:45:47 +00:00
|
|
|
|
2019-06-07 17:55:06 +00:00
|
|
|
int isSky(int skyIndex);
|
2019-06-07 18:49:07 +00:00
|
|
|
void setSky(int skyIndex);
|
2019-06-07 20:55:11 +00:00
|
|
|
void setup3DStars();
|
|
|
|
void setup3DStarsLeft();
|
2019-06-08 15:56:34 +00:00
|
|
|
void draw3DStars();
|
|
|
|
void draw3DStarsLeft();
|
|
|
|
void drawSky();
|
2019-07-03 15:01:00 +00:00
|
|
|
void drawSnow();
|
2019-05-31 07:21:09 +00:00
|
|
|
|
2019-06-21 02:57:44 +00:00
|
|
|
int animateTile(int tileIndex);
|
|
|
|
|
2019-06-23 00:15:29 +00:00
|
|
|
// Font Functions
|
|
|
|
|
2019-06-23 00:21:45 +00:00
|
|
|
bool loadFont(const char *string);
|
2019-06-23 00:22:22 +00:00
|
|
|
void drawText(const char *string);
|
2019-06-23 00:18:50 +00:00
|
|
|
void getDimensions(const char *string, int *pixelsWide, int *lines);
|
2019-06-25 05:31:19 +00:00
|
|
|
int stringLength(const char *string);
|
2019-07-10 20:54:12 +00:00
|
|
|
void centerPrint(const char *string);
|
2019-06-23 00:17:45 +00:00
|
|
|
void setTextEdges(int left, int right, int top, int bottom);
|
|
|
|
void getTextEdges(int *left, int *right, int *top, int *bottom);
|
2019-06-23 00:16:36 +00:00
|
|
|
void setKernLead(int kern, int lead);
|
|
|
|
void getKernLead(int *kern, int *lead);
|
2019-06-23 00:15:29 +00:00
|
|
|
void setCursor(int x, int y);
|
|
|
|
void getCursor(int *x, int *y);
|
|
|
|
|
2019-07-10 19:20:59 +00:00
|
|
|
// Trig Functions
|
|
|
|
|
|
|
|
double getSin(int index) {
|
|
|
|
return _sines->at(index);
|
|
|
|
}
|
|
|
|
double getCos(int index) {
|
|
|
|
return _cosines->at(index);
|
|
|
|
}
|
|
|
|
|
2019-07-11 22:04:14 +00:00
|
|
|
// Bonus star functions
|
|
|
|
|
|
|
|
void turnOnBonusStars(int which);
|
|
|
|
void drawBonusStars();
|
|
|
|
|
2019-07-15 06:41:02 +00:00
|
|
|
void drawDebugInfo(Tile *_debugLogo, int fps);
|
|
|
|
|
2019-05-31 07:21:09 +00:00
|
|
|
private:
|
2019-06-07 14:16:16 +00:00
|
|
|
int _numTiles;
|
2019-06-07 16:57:29 +00:00
|
|
|
TileLookup *_tLookupArray;
|
|
|
|
uint16 _skyTiles[kMaxSkies];
|
2019-06-18 11:26:53 +00:00
|
|
|
|
2019-06-19 23:45:04 +00:00
|
|
|
Common::Array<GfxCache *> *_gfxCache;
|
|
|
|
|
2019-06-07 16:57:29 +00:00
|
|
|
int _currentSky; // 0 if no Sky, 1+ for which Sky to use
|
2019-06-18 11:26:53 +00:00
|
|
|
struct {
|
|
|
|
bool active;
|
|
|
|
bool stayFaded;
|
|
|
|
bool isBlack;
|
|
|
|
int speed;
|
|
|
|
bool isFadeIn;
|
|
|
|
|
|
|
|
int curStep;
|
|
|
|
} _fadeInfo;
|
2019-06-07 20:55:11 +00:00
|
|
|
|
2019-07-03 15:01:00 +00:00
|
|
|
#define MAX_SNOW 50 // how many snowflakes onscreen
|
|
|
|
#define MAX_SNOW_XV 12
|
|
|
|
struct {
|
|
|
|
bool active;
|
|
|
|
double x[MAX_SNOW];
|
|
|
|
double y[MAX_SNOW];
|
|
|
|
double yv[MAX_SNOW];
|
|
|
|
int xvindex[MAX_SNOW];
|
|
|
|
} _snowInfo;
|
|
|
|
|
2019-06-07 20:55:11 +00:00
|
|
|
struct {
|
|
|
|
int x, y, speed;
|
|
|
|
uint16 color;
|
|
|
|
} _stars3D[kNum3DStars];
|
|
|
|
|
|
|
|
struct {
|
|
|
|
double x, y, speed;
|
|
|
|
uint16 color;
|
|
|
|
} _stars3DSlow[kNum3DStars];
|
|
|
|
|
2019-06-07 18:46:03 +00:00
|
|
|
int _tileSkyStars; // Index of sky_stars tile
|
|
|
|
int _tileSkyStarsLeft; // Left-scrolling stars, slow
|
|
|
|
int _tileSkyClouds; // Index of sky_stars tile
|
2019-06-08 12:12:16 +00:00
|
|
|
Picture *_starField[4];
|
2019-07-12 20:25:03 +00:00
|
|
|
Picture *_snowflake;
|
2019-06-07 18:46:03 +00:00
|
|
|
Picture *_skyClouds;
|
|
|
|
|
2019-07-11 22:04:14 +00:00
|
|
|
struct {
|
|
|
|
bool active;
|
|
|
|
int starAngle[10];
|
|
|
|
Picture *gfx[2];
|
|
|
|
uint32 timer;
|
|
|
|
int anim, radius;
|
|
|
|
double angleSpeed;
|
|
|
|
uint32 totalTime;
|
|
|
|
} _starsInfo;
|
|
|
|
|
2019-06-23 00:13:08 +00:00
|
|
|
// Cursor
|
|
|
|
int _cursorX, _cursorY;
|
2019-06-28 15:24:53 +00:00
|
|
|
Picture *_mousePointer[8]; // Gfx for screen pointer (4 Animations)
|
|
|
|
int _pointerDisplayable;
|
|
|
|
bool _showCursor;
|
2019-06-23 00:13:08 +00:00
|
|
|
|
|
|
|
// Font Data
|
|
|
|
|
|
|
|
FontInfo _fontHeader;
|
|
|
|
Common::Array<CharInfo *> _charInfoBlocks;
|
|
|
|
Graphics::Surface _fontSurfaces[256];
|
|
|
|
uint16 _fontGfx;
|
|
|
|
int _eLeft, _eRight, _eTop, _eBottom;
|
|
|
|
|
2019-05-31 07:21:09 +00:00
|
|
|
bool _systemInit;
|
|
|
|
|
2019-07-10 19:20:59 +00:00
|
|
|
Common::SineTable *_sines;
|
|
|
|
Common::CosineTable *_cosines;
|
2019-05-31 07:21:09 +00:00
|
|
|
};
|
|
|
|
|
2019-06-01 10:50:56 +00:00
|
|
|
class Picture {
|
|
|
|
public:
|
|
|
|
|
2019-06-20 21:19:28 +00:00
|
|
|
Picture();
|
2019-06-01 16:12:25 +00:00
|
|
|
~Picture();
|
|
|
|
|
2019-07-17 20:49:18 +00:00
|
|
|
Graphics::Surface load(Common::SeekableReadStream *stream);
|
2019-07-04 17:59:23 +00:00
|
|
|
int draw(int x, int y);
|
2019-07-07 23:41:38 +00:00
|
|
|
int drawMasked(int x, int y, int alpha = 0xff);
|
2019-06-01 10:50:56 +00:00
|
|
|
|
2019-07-04 22:39:38 +00:00
|
|
|
int _width, _height;
|
2019-06-23 19:40:30 +00:00
|
|
|
|
2019-06-26 06:52:37 +00:00
|
|
|
char *getName() { return _name; }
|
|
|
|
|
2019-07-17 20:49:18 +00:00
|
|
|
Graphics::ManagedSurface *getSurface() { return &_surface; }
|
2019-06-01 10:50:56 +00:00
|
|
|
|
2019-07-12 23:18:38 +00:00
|
|
|
private:
|
2019-06-01 10:50:56 +00:00
|
|
|
char _name[64];
|
|
|
|
|
2019-07-17 20:49:18 +00:00
|
|
|
Graphics::ManagedSurface _surface;
|
2019-06-01 10:50:56 +00:00
|
|
|
};
|
|
|
|
|
2019-06-01 12:26:04 +00:00
|
|
|
class Tile {
|
|
|
|
public:
|
2019-06-01 16:12:25 +00:00
|
|
|
|
2019-06-20 21:19:28 +00:00
|
|
|
Tile();
|
2019-06-01 16:12:25 +00:00
|
|
|
~Tile();
|
|
|
|
|
2019-07-17 20:49:18 +00:00
|
|
|
Graphics::Surface load(Common::SeekableReadStream *stream);
|
2019-07-04 17:59:23 +00:00
|
|
|
int draw(int x, int y);
|
2019-07-07 23:41:38 +00:00
|
|
|
int drawMasked(int x, int y, int alpha = 0xff);
|
2019-06-01 12:26:04 +00:00
|
|
|
|
|
|
|
uint32 _flags;
|
2019-06-07 22:25:38 +00:00
|
|
|
|
2019-06-26 06:52:37 +00:00
|
|
|
char *getName() { return _name; }
|
2019-06-07 22:25:38 +00:00
|
|
|
private:
|
2019-06-01 12:26:04 +00:00
|
|
|
char _name[64];
|
|
|
|
|
2019-07-17 20:49:18 +00:00
|
|
|
Graphics::ManagedSurface _surface;
|
2019-06-01 12:26:04 +00:00
|
|
|
};
|
|
|
|
|
2019-05-31 07:21:09 +00:00
|
|
|
} // End of Namespace HDB
|
|
|
|
|
2019-07-24 10:07:37 +00:00
|
|
|
#endif // !HDB_GFX_H
|