aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/text/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/zvision/text/text.cpp')
-rw-r--r--engines/zvision/text/text.cpp155
1 files changed, 84 insertions, 71 deletions
diff --git a/engines/zvision/text/text.cpp b/engines/zvision/text/text.cpp
index 406c36e5b0..a5ed044424 100644
--- a/engines/zvision/text/text.cpp
+++ b/engines/zvision/text/text.cpp
@@ -33,27 +33,31 @@
#include "zvision/text/text.h"
#include "zvision/graphics/render_manager.h"
-#include "zvision/graphics/truetype_font.h"
+#include "zvision/text/truetype_font.h"
#include "zvision/scripting/script_manager.h"
namespace ZVision {
cTxtStyle::cTxtStyle() {
- fontname = "Arial";
- blue = 255;
- green = 255;
- red = 255;
- bold = false;
- escapement = 0;
- italic = false;
- justify = TXT_JUSTIFY_LEFT;
- newline = false;
- size = 12;
- skipcolor = false;
- strikeout = false;
- underline = false;
- statebox = 0;
- sharp = false;
+ _fontname = "Arial";
+ _blue = 255;
+ _green = 255;
+ _red = 255;
+ _bold = false;
+#if 0
+ _newline = false;
+ _escapement = 0;
+#endif
+ _italic = false;
+ _justify = TXT_JUSTIFY_LEFT;
+ _size = 12;
+#if 0
+ _skipcolor = false;
+#endif
+ _strikeout = false;
+ _underline = false;
+ _statebox = 0;
+ _sharp = false;
}
txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
@@ -80,10 +84,10 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (_tmp.lastChar() == '"')
_tmp.deleteLastChar();
- fontname = _tmp;
+ _fontname = _tmp;
} else {
if (!tokenizer.empty())
- fontname = token;
+ _fontname = token;
}
retval |= TXT_RET_FNTCHG;
@@ -91,8 +95,8 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
int32 tmp = atoi(token.c_str());
- if (blue != tmp) {
- blue = tmp;
+ if (_blue != tmp) {
+ _blue = tmp;
retval |= TXT_RET_FNTSTL;
}
}
@@ -100,8 +104,8 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
int32 tmp = atoi(token.c_str());
- if (red != tmp) {
- red = tmp;
+ if (_red != tmp) {
+ _red = tmp;
retval |= TXT_RET_FNTSTL;
}
}
@@ -109,43 +113,47 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
int32 tmp = atoi(token.c_str());
- if (green != tmp) {
- green = tmp;
+ if (_green != tmp) {
+ _green = tmp;
retval |= TXT_RET_FNTSTL;
}
}
} else if (token.matchString("newline", true)) {
+#if 0
if ((retval & TXT_RET_NEWLN) == 0)
- newline = 0;
+ _newline = 0;
- newline++;
+ _newline++;
+#endif
retval |= TXT_RET_NEWLN;
} else if (token.matchString("point", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
int32 tmp = atoi(token.c_str());
- if (size != tmp) {
- size = tmp;
+ if (_size != tmp) {
+ _size = tmp;
retval |= TXT_RET_FNTCHG;
}
}
} else if (token.matchString("escapement", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
+#if 0
int32 tmp = atoi(token.c_str());
- escapement = tmp;
+ _escapement = tmp;
+#endif
}
} else if (token.matchString("italic", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
if (token.matchString("on", true)) {
- if (italic != true) {
- italic = true;
+ if (_italic != true) {
+ _italic = true;
retval |= TXT_RET_FNTSTL;
}
} else if (token.matchString("off", true)) {
- if (italic != false) {
- italic = false;
+ if (_italic != false) {
+ _italic = false;
retval |= TXT_RET_FNTSTL;
}
}
@@ -154,13 +162,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
if (token.matchString("on", true)) {
- if (underline != true) {
- underline = true;
+ if (_underline != true) {
+ _underline = true;
retval |= TXT_RET_FNTSTL;
}
} else if (token.matchString("off", true)) {
- if (underline != false) {
- underline = false;
+ if (_underline != false) {
+ _underline = false;
retval |= TXT_RET_FNTSTL;
}
}
@@ -169,13 +177,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
if (token.matchString("on", true)) {
- if (strikeout != true) {
- strikeout = true;
+ if (_strikeout != true) {
+ _strikeout = true;
retval |= TXT_RET_FNTSTL;
}
} else if (token.matchString("off", true)) {
- if (strikeout != false) {
- strikeout = false;
+ if (_strikeout != false) {
+ _strikeout = false;
retval |= TXT_RET_FNTSTL;
}
}
@@ -184,13 +192,13 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
if (token.matchString("on", true)) {
- if (bold != true) {
- bold = true;
+ if (_bold != true) {
+ _bold = true;
retval |= TXT_RET_FNTSTL;
}
} else if (token.matchString("off", true)) {
- if (bold != false) {
- bold = false;
+ if (_bold != false) {
+ _bold = false;
retval |= TXT_RET_FNTSTL;
}
}
@@ -198,29 +206,31 @@ txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
} else if (token.matchString("skipcolor", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
+#if 0
if (token.matchString("on", true)) {
- skipcolor = true;
+ _skipcolor = true;
} else if (token.matchString("off", true)) {
- skipcolor = false;
+ _skipcolor = false;
}
+#endif
}
} else if (token.matchString("image", true)) {
// Not used
} else if (token.matchString("statebox", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
- statebox = atoi(token.c_str());
+ _statebox = atoi(token.c_str());
retval |= TXT_RET_HASSTBOX;
}
} else if (token.matchString("justify", true)) {
if (!tokenizer.empty()) {
token = tokenizer.nextToken();
if (token.matchString("center", true))
- justify = TXT_JUSTIFY_CENTER;
+ _justify = TXT_JUSTIFY_CENTER;
else if (token.matchString("left", true))
- justify = TXT_JUSTIFY_LEFT;
+ _justify = TXT_JUSTIFY_LEFT;
else if (token.matchString("right", true))
- justify = TXT_JUSTIFY_RIGHT;
+ _justify = TXT_JUSTIFY_RIGHT;
}
}
}
@@ -247,19 +257,19 @@ void cTxtStyle::readAllStyle(const Common::String &txt) {
void cTxtStyle::setFontStyle(StyledTTFont &font) {
uint tempStyle = 0;
- if (bold)
+ if (_bold)
tempStyle |= StyledTTFont::STTF_BOLD;
- if (italic)
+ if (_italic)
tempStyle |= StyledTTFont::STTF_ITALIC;
- if (underline)
+ if (_underline)
tempStyle |= StyledTTFont::STTF_UNDERLINE;
- if (strikeout)
+ if (_strikeout)
tempStyle |= StyledTTFont::STTF_STRIKEOUT;
- if (sharp)
+ if (_sharp)
tempStyle |= StyledTTFont::STTF_SHARP;
font.setStyle(tempStyle);
@@ -268,27 +278,27 @@ void cTxtStyle::setFontStyle(StyledTTFont &font) {
void cTxtStyle::setFont(StyledTTFont &font) {
uint tempStyle = 0;
- if (bold)
+ if (_bold)
tempStyle |= StyledTTFont::STTF_BOLD;
- if (italic)
+ if (_italic)
tempStyle |= StyledTTFont::STTF_ITALIC;
- if (underline)
+ if (_underline)
tempStyle |= StyledTTFont::STTF_UNDERLINE;
- if (strikeout)
+ if (_strikeout)
tempStyle |= StyledTTFont::STTF_STRIKEOUT;
- if (sharp)
+ if (_sharp)
tempStyle |= StyledTTFont::STTF_SHARP;
- font.loadFont(fontname, size, tempStyle);
+ font.loadFont(_fontname, _size, tempStyle);
}
Graphics::Surface *TextRenderer::render(StyledTTFont &fnt, const Common::String &txt, cTxtStyle &style) {
style.setFontStyle(fnt);
- uint32 clr = _engine->_pixelFormat.RGBToColor(style.red, style.green, style.blue);
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(style._red, style._green, style._blue);
return fnt.renderSolidText(txt, clr);
}
@@ -307,13 +317,13 @@ int32 TextRenderer::drawTxt(const Common::String &txt, cTxtStyle &fontStyle, Gra
dst.fillRect(Common::Rect(dst.w, dst.h), 0);
- uint32 clr = _engine->_pixelFormat.RGBToColor(fontStyle.red, fontStyle.green, fontStyle.blue);
+ uint32 clr = _engine->_resourcePixelFormat.RGBToColor(fontStyle._red, fontStyle._green, fontStyle._blue);
int16 w;
w = font.getStringWidth(txt);
- drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle.justify);
+ drawTxtWithJustify(txt, font, clr, dst, 0, fontStyle._justify);
return w;
}
@@ -352,7 +362,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
int16 prevbufspace = 0, prevtxtspace = 0;
while (i < stringlen) {
- TxtJustify[currentline] = style.justify;
+ TxtJustify[currentline] = style._justify;
if (text[i] == '<') {
int16 ret = 0;
@@ -396,7 +406,7 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
if (ret & TXT_RET_HASSTBOX) {
Common::String buf3;
- buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style.statebox));
+ buf3 = Common::String::format("%d", _engine->getScriptManager()->getStateValue(style._statebox));
buf += buf3;
textPosition += buf3.size();
}
@@ -452,15 +462,16 @@ void TextRenderer::drawTxtInOneLine(const Common::String &text, Graphics::Surfac
j++;
}
dx = 0;
+ Common::Rect empty;
for (int32 jj = 0; jj < j; jj++) {
if (TxtJustify[i] == TXT_JUSTIFY_LEFT)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
else if (TxtJustify[i] == TXT_JUSTIFY_CENTER)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, ((dst.w - width) / 2) + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
else if (TxtJustify[i] == TXT_JUSTIFY_RIGHT)
- _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
+ _engine->getRenderManager()->blitSurfaceToSurface(*TxtSurfaces[i][jj], empty, dst, dst.w - width + dx, dy + TxtPoint[i] - TxtSurfaces[i][jj]->h, 0);
dx += TxtSurfaces[i][jj]->w;
}
@@ -495,10 +506,12 @@ Common::String readWideLine(Common::SeekableReadStream &stream) {
} else if (value >= 0x80 && value < 0x800) {
asciiString += (char)(0xC0 | ((value >> 6) & 0x1F));
asciiString += (char)(0x80 | (value & 0x3F));
- } else if (value >= 0x800 && value < 0x10000) {
+ } else if (value >= 0x800 && value < 0x10000 && value != 0xCCCC) {
asciiString += (char)(0xE0 | ((value >> 12) & 0xF));
asciiString += (char)(0x80 | ((value >> 6) & 0x3F));
asciiString += (char)(0x80 | (value & 0x3F));
+ } else if (value == 0xCCCC) {
+ // Ignore, this character is used as newline sometimes
} else if (value >= 0x10000 && value < 0x200000) {
asciiString += (char)(0xF0);
asciiString += (char)(0x80 | ((value >> 12) & 0x3F));