aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood/graphics.cpp
diff options
context:
space:
mode:
authorjohndoe1232012-09-19 11:03:28 +0000
committerWillem Jan Palenstijn2013-05-08 20:43:42 +0200
commit96153bfe04fff5edc8253226125b225cee6681a0 (patch)
treeebfeb324f1f83d31da1ecf60c8452e994f404202 /engines/neverhood/graphics.cpp
parentd1d1596fd136783a7bc4db9264ba1627b8511355 (diff)
downloadscummvm-rg350-96153bfe04fff5edc8253226125b225cee6681a0.tar.gz
scummvm-rg350-96153bfe04fff5edc8253226125b225cee6681a0.tar.bz2
scummvm-rg350-96153bfe04fff5edc8253226125b225cee6681a0.zip
NEVERHOOD: Implement TextSurface, used in the save/load menus
Diffstat (limited to 'engines/neverhood/graphics.cpp')
-rw-r--r--engines/neverhood/graphics.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/engines/neverhood/graphics.cpp b/engines/neverhood/graphics.cpp
index a58cdcb4b9..b1597f2d5e 100644
--- a/engines/neverhood/graphics.cpp
+++ b/engines/neverhood/graphics.cpp
@@ -168,6 +168,40 @@ void FontSurface::drawString(BaseSurface *destSurface, int16 x, int16 y, const b
}
}
+// TextSurface
+
+TextSurface::TextSurface(NeverhoodEngine *vm, uint32 fileHash, uint16 numRows, uint charCount,
+ byte firstChar, uint16 charWidth, uint16 charHeight)
+ : BaseSurface(vm, 0, charWidth * charCount, charHeight * numRows),
+ _numRows(numRows), _firstChar(firstChar), _charWidth(charWidth), _charHeight(charHeight),
+ _fileHash(fileHash), _charCount(charCount) {
+
+ SpriteResource spriteResource(_vm);
+ spriteResource.load2(_fileHash);
+ drawSpriteResourceEx(spriteResource, false, false, 0, 0);
+}
+
+void TextSurface::drawChar(BaseSurface *destSurface, int16 x, int16 y, byte chr) {
+ NDrawRect sourceRect;
+ chr -= _firstChar;
+ sourceRect.x = (chr % 16) * _charWidth;
+ sourceRect.y = (chr / 16) * _charHeight;
+ sourceRect.width = _charWidth;
+ sourceRect.height = _charHeight;
+ destSurface->copyFrom(_surface, x, y, sourceRect, true);
+}
+
+void TextSurface::drawString(BaseSurface *destSurface, int16 x, int16 y, const byte *string, int stringLen) {
+ for (; stringLen > 0; stringLen--, string++) {
+ drawChar(destSurface, x, y, *string);
+ x += _charWidth;
+ }
+}
+
+int16 TextSurface::getStringWidth(const byte *string, int stringLen) {
+ return string ? stringLen * _charWidth : 0;
+}
+
// Misc
void parseBitmapResource(byte *sprite, bool *rle, NDimensions *dimensions, NPoint *position, byte **palette, byte **pixels) {