diff options
Diffstat (limited to 'engines/bladerunner/font.cpp')
-rw-r--r-- | engines/bladerunner/font.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp index 2f56b3f12d..3af8fc2f7f 100644 --- a/engines/bladerunner/font.cpp +++ b/engines/bladerunner/font.cpp @@ -28,7 +28,8 @@ namespace BladeRunner { -Font::Font(BladeRunnerEngine *vm) : _vm(vm) { +Font::Font(BladeRunnerEngine *vm) { + _vm = vm; reset(); } @@ -62,11 +63,11 @@ bool Font::open(const Common::String &fileName, int screenWidth, int screenHeigh } for (int i = 0; i < _characterCount; i++) { - _characters[i]._x = stream->readUint32LE(); - _characters[i]._y = stream->readUint32LE(); - _characters[i]._width = stream->readUint32LE(); - _characters[i]._height = stream->readUint32LE(); - _characters[i]._dataOffset = stream->readUint32LE(); + _characters[i].x = stream->readUint32LE(); + _characters[i].y = stream->readUint32LE(); + _characters[i].width = stream->readUint32LE(); + _characters[i].height = stream->readUint32LE(); + _characters[i].dataOffset = stream->readUint32LE(); } for (int i = 0; i < _dataSize; i++) { _data[i] = stream->readUint16LE(); @@ -95,7 +96,7 @@ void Font::setColor(uint16 color) { } } -void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, int y) { +void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, int y) const { if (!_data) { return; } @@ -106,7 +107,7 @@ void Font::draw(const Common::String &text, Graphics::Surface &surface, int x, i const char *character = text.c_str(); while (*character != 0) { drawCharacter(*character, surface, x, y); - x += _spacing1 + _characters[*character + 1]._width; + x += _spacing1 + _characters[*character + 1].width; character++; } @@ -119,7 +120,7 @@ void Font::drawColor(const Common::String &text, Graphics::Surface &surface, int draw(text, surface, x, y); } -int Font::getTextWidth(const Common::String &text) { +int Font::getTextWidth(const Common::String &text) const { const char *character = text.c_str(); if (!_data) { @@ -130,13 +131,13 @@ int Font::getTextWidth(const Common::String &text) { return 0; } while (*character != 0) { - totalWidth += _spacing1 + _characters[*character + 1]._width; + totalWidth += _spacing1 + _characters[*character + 1].width; character++; } return totalWidth - _spacing1; } -int Font::getTextHeight(const Common::String &text) { +int Font::getTextHeight(const Common::String &text) const { return _maxHeight; } @@ -153,7 +154,7 @@ void Font::reset() { _color = 0x7FFF; _intersperse = 0; - memset(_characters, 0, 256 * sizeof(FontCharacter)); + memset(_characters, 0, 256 * sizeof(Character)); } void Font::replaceColor(uint16 oldColor, uint16 newColor) { @@ -167,16 +168,16 @@ void Font::replaceColor(uint16 oldColor, uint16 newColor) { } } -void Font::drawCharacter(const char character, Graphics::Surface &surface, int x, int y) { +void Font::drawCharacter(const char character, Graphics::Surface &surface, int x, int y) const { uint8 characterIndex = (uint8)character + 1; if (x < 0 || x >= _screenWidth || y < 0 || y >= _screenHeight || !_data || characterIndex >= _characterCount) { return; } - uint16 *dstPtr = (uint16*)surface.getBasePtr(x + _characters[characterIndex]._x, y + _characters[characterIndex]._y); - uint16 *srcPtr = &_data[_characters[characterIndex]._dataOffset]; - int width = _characters[characterIndex]._width; - int height = _characters[characterIndex]._height; + uint16 *dstPtr = (uint16 *)surface.getBasePtr(x + _characters[characterIndex].x, y + _characters[characterIndex].y); + uint16 *srcPtr = &_data[_characters[characterIndex].dataOffset]; + int width = _characters[characterIndex].width; + int height = _characters[characterIndex].height; if (_intersperse && y & 1) { dstPtr += surface.pitch / 2; } @@ -203,4 +204,5 @@ void Font::drawCharacter(const char character, Graphics::Surface &surface, int x currentY++; } } + } // End of namespace BladeRunner |