aboutsummaryrefslogtreecommitdiff
path: root/saga/font.h
diff options
context:
space:
mode:
authorAndrew Kurushin2005-11-03 18:20:12 +0000
committerAndrew Kurushin2005-11-03 18:20:12 +0000
commit43a083a117a42879a18ea4c3a5e721d261fb8489 (patch)
tree8dfb8e3cad472c7b7fa928720d02af148b046eae /saga/font.h
parent7f691c3ca2068e708915b968a6f210ec205ce442 (diff)
downloadscummvm-rg350-43a083a117a42879a18ea4c3a5e721d261fb8489.tar.gz
scummvm-rg350-43a083a117a42879a18ea4c3a5e721d261fb8489.tar.bz2
scummvm-rg350-43a083a117a42879a18ea4c3a5e721d261fb8489.zip
-implement font substitution funcs
-move puzzle data to itedata svn-id: r19411
Diffstat (limited to 'saga/font.h')
-rw-r--r--saga/font.h113
1 files changed, 83 insertions, 30 deletions
diff --git a/saga/font.h b/saga/font.h
index fd0d8fc2ab..7525a608fa 100644
--- a/saga/font.h
+++ b/saga/font.h
@@ -53,6 +53,35 @@ namespace Saga {
#define TEXT_MARGIN 10
#define TEXT_LINESPACING 2
+enum FontId {
+ kSmallFont,
+ kMediumFont,
+ kBigFont,
+ kIHNMUnknown,
+ kIHNMFont8,
+ kIHNMUnknown2,
+ kIHNMMainFont
+};
+
+enum FontEffectFlags {
+ kFontNormal = 0,
+ kFontOutline = 1 << 0,
+ kFontShadow = 1 << 1,
+ kFontBold = 1 << 2,
+ kFontCentered = 1 << 3,
+ kFontDontmap = 1 << 4
+};
+
+enum KnownFont {
+ kKnownFontSmall,
+ kKnownFontMedium,
+ kKnownFontBig,
+
+ kKnownFontPause,
+ kKnownFontScript,
+ kKnownFontVerb,
+};
+
struct TextListEntry {
bool display;
bool useRect;
@@ -61,7 +90,7 @@ struct TextListEntry {
int color;
int effectColor;
FontEffectFlags flags;
- FontId fontId;
+ KnownFont font;
const char *text;
TextListEntry() {
memset(this, 0, sizeof(*this));
@@ -105,38 +134,62 @@ class Font {
public:
Font(SagaEngine *vm);
~Font(void);
- FontData *getFont(FontId fontId);
- int getStringWidth(FontId fontId, const char *text, size_t count, FontEffectFlags flags);
- int getHeight(FontId fontId);
- int getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags);
-
- void textDraw(FontId fontId, Surface *ds, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags);
- void textDrawRect(FontId fontId, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags);
-
- void validate(FontId fontId) {
- if ((fontId < 0) || (fontId >= _loadedFonts)) {
- error("Font::validate: Invalid font id.");
- }
+ int getStringWidth(KnownFont font, const char *text, size_t count, FontEffectFlags flags) {
+ return getStringWidth(knownFont2FontIdx(font), text, count, flags);
}
-
- bool loaded(FontId fontId) {
- return !((fontId < 0) || (fontId >= _loadedFonts));
+ int getHeight(KnownFont font) {
+ return getHeight(knownFont2FontIdx(font));
}
-
- private:
- void loadFont(uint32 fontResourceId);
- void createOutline(FontData *font);
- void draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags);
- void outFont(const FontStyle &drawFont, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags);
- int getByteLen(int numBits) const {
- int byteLength = numBits / 8;
-
- if (numBits % 8) {
- byteLength++;
- }
-
- return byteLength;
+ int getHeight(KnownFont font, const char *text, int width, FontEffectFlags flags) {
+ return getHeight(knownFont2FontIdx(font), text, width, flags);
+ }
+ void textDraw(KnownFont font, Surface *ds, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags) {
+ textDraw(knownFont2FontIdx(font), ds, string, point, color, effectColor, flags);
+ }
+ void textDrawRect(KnownFont font, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags) {
+ textDrawRect(knownFont2FontIdx(font), ds, text, rect, color, effectColor, flags);
}
+
+ private:
+ FontId knownFont2FontIdx(KnownFont font);
+
+ int getStringWidth(FontId fontId, const char *text, size_t count, FontEffectFlags flags);
+ int getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags);
+ void textDrawRect(FontId fontId, Surface *ds, const char *text, const Common::Rect &rect, int color, int effectColor, FontEffectFlags flags);
+ void textDraw(FontId fontId, Surface *ds, const char *string, const Common::Point &point, int color, int effectColor, FontEffectFlags flags);
+
+ void loadFont(uint32 fontResourceId);
+ void createOutline(FontData *font);
+ void draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags);
+ void outFont(const FontStyle &drawFont, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, FontEffectFlags flags);
+
+ FontData *getFont(FontId fontId) {
+ validate(fontId);
+ return _fonts[fontId];
+ }
+
+public:
+ int Font::getHeight(FontId fontId) {
+ return getFont(fontId)->normal.header.charHeight;
+ }
+
+ void validate(FontId fontId) {
+ if (!valid(fontId)) {
+ error("Font::validate: Invalid font id.");
+ }
+ }
+ bool valid(FontId fontId) {
+ return ((fontId >= 0) && (fontId < _loadedFonts));
+ }
+ int getByteLen(int numBits) const {
+ int byteLength = numBits / 8;
+
+ if (numBits % 8) {
+ byteLength++;
+ }
+
+ return byteLength;
+ }
static const int _charMap[256];
SagaEngine *_vm;