2009-06-11 20:31:36 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-06-17 05:18:48 +00:00
|
|
|
#ifndef DRACI_FONT_H
|
|
|
|
#define DRACI_FONT_H
|
2009-06-14 18:59:31 +00:00
|
|
|
|
2009-06-11 20:31:36 +00:00
|
|
|
#include "graphics/font.h"
|
|
|
|
|
|
|
|
namespace Draci {
|
|
|
|
|
2009-09-30 10:45:14 +00:00
|
|
|
extern const char * const kFontSmall;
|
|
|
|
extern const char * const kFontBig;
|
2009-06-14 16:21:44 +00:00
|
|
|
|
2009-12-09 21:03:22 +00:00
|
|
|
class Surface;
|
|
|
|
|
2009-09-30 16:04:21 +00:00
|
|
|
/**
|
2011-04-14 12:12:27 +00:00
|
|
|
* Default font colors. They all seem to remain constant except for the
|
2009-06-19 00:09:36 +00:00
|
|
|
* first one which varies depending on the character speaking.
|
2011-04-14 12:12:27 +00:00
|
|
|
* kOverFontColor is set to transparent.
|
2009-06-19 00:09:36 +00:00
|
|
|
*/
|
2009-09-30 16:04:21 +00:00
|
|
|
enum {
|
2011-04-14 12:12:27 +00:00
|
|
|
kFontColor1 = 2,
|
|
|
|
kFontColor2 = 0,
|
|
|
|
kFontColor3 = 3,
|
|
|
|
kFontColor4 = 4,
|
|
|
|
kOverFontColor = 255,
|
|
|
|
kTitleColor = 255,
|
|
|
|
kLineActiveColor = 254,
|
|
|
|
kLineInactiveColor = 255
|
2009-06-19 00:09:36 +00:00
|
|
|
};
|
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/**
|
|
|
|
* Represents the game's fonts. See docs for setFont() for font format details.
|
|
|
|
*/
|
2009-06-14 16:33:20 +00:00
|
|
|
class Font {
|
2009-09-30 16:04:21 +00:00
|
|
|
|
|
|
|
public:
|
2009-06-14 16:33:20 +00:00
|
|
|
Font(const Common::String &filename);
|
|
|
|
~Font();
|
2009-06-14 18:59:31 +00:00
|
|
|
|
2009-07-15 18:16:54 +00:00
|
|
|
bool loadFont(const Common::String &filename);
|
2010-03-22 20:28:08 +00:00
|
|
|
uint8 getFontHeight() const { return _fontHeight; }
|
|
|
|
uint8 getMaxCharWidth() const { return _maxCharWidth; }
|
2009-06-11 20:31:36 +00:00
|
|
|
uint8 getCharWidth(byte chr) const;
|
2011-04-14 12:12:27 +00:00
|
|
|
void drawChar(Surface *dst, uint8 chr, int tx, int ty, int with_color) const;
|
2009-09-30 10:45:14 +00:00
|
|
|
|
2011-04-14 12:12:27 +00:00
|
|
|
void drawString(Surface *dst, const byte *str, uint len, int x, int y, int with_color,
|
2009-10-30 01:41:57 +00:00
|
|
|
int spacing, bool markDirty) const;
|
2009-09-30 16:04:21 +00:00
|
|
|
void drawString(Surface *dst, const Common::String &str,
|
2011-04-14 12:12:27 +00:00
|
|
|
int x, int y, int with_color, int spacing, bool markDirty) const;
|
2009-09-30 10:45:14 +00:00
|
|
|
|
2009-10-30 01:41:57 +00:00
|
|
|
uint getStringWidth(const Common::String &str, int spacing) const;
|
2009-08-04 19:23:59 +00:00
|
|
|
uint getStringHeight(const Common::String &str) const;
|
2009-10-30 01:41:57 +00:00
|
|
|
uint getLineWidth(const Common::String &str, uint startIndex, int spacing) const;
|
2009-07-27 03:08:19 +00:00
|
|
|
|
2009-06-11 20:31:36 +00:00
|
|
|
private:
|
|
|
|
uint8 _fontHeight;
|
|
|
|
uint8 _maxCharWidth;
|
2009-09-30 10:45:14 +00:00
|
|
|
|
|
|
|
/** Pointer to an array of individual char widths */
|
2009-06-11 20:31:36 +00:00
|
|
|
uint8 *_charWidths;
|
2009-09-30 10:45:14 +00:00
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/** Pointer to a raw byte array representing font pixels stored row-wise */
|
2009-06-11 20:31:36 +00:00
|
|
|
byte *_charData;
|
2009-09-30 16:04:21 +00:00
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/** Number of glyphs in the font */
|
2009-09-30 10:45:14 +00:00
|
|
|
static const uint kCharNum = 138;
|
2009-06-11 20:31:36 +00:00
|
|
|
|
2009-09-30 16:04:21 +00:00
|
|
|
/**
|
2009-09-30 10:45:14 +00:00
|
|
|
* Chars are indexed from the space character so this should be subtracted
|
2009-06-14 13:32:21 +00:00
|
|
|
* to get the index of a glyph
|
|
|
|
*/
|
2009-09-30 10:45:14 +00:00
|
|
|
static const uint kCharIndexOffset = 32;
|
2009-06-11 20:31:36 +00:00
|
|
|
|
2009-06-12 09:45:12 +00:00
|
|
|
/** Internal function for freeing fonts when destructing/loading another */
|
2009-06-11 20:31:36 +00:00
|
|
|
void freeFont();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Draci
|
2009-06-14 18:59:31 +00:00
|
|
|
|
2009-06-17 05:18:48 +00:00
|
|
|
#endif // DRACI_FONT_H
|