diff options
author | Denis Kasak | 2009-06-14 18:59:31 +0000 |
---|---|---|
committer | Denis Kasak | 2009-06-14 18:59:31 +0000 |
commit | 718f84fb9703f894f11d5d6e76b34bc0e345da42 (patch) | |
tree | 9ce804e087ed9070aeae5ffeaa7d5fea51707fde /engines/draci/font.cpp | |
parent | 149b45f7a59c5319c912d13d8259b63b5fbb2a21 (diff) | |
download | scummvm-rg350-718f84fb9703f894f11d5d6e76b34bc0e345da42.tar.gz scummvm-rg350-718f84fb9703f894f11d5d6e76b34bc0e345da42.tar.bz2 scummvm-rg350-718f84fb9703f894f11d5d6e76b34bc0e345da42.zip |
Added a Font _font variable to the engine instance. Fixed font colour handling by replacing the appropriate colours before drawing. Added Font::setColour() method for changing the current font colour. Added include guards to draci/font.h. Moved kFontBig and kFontSmall constants to draci/font.cpp to prevent redefinition errors.
svn-id: r41524
Diffstat (limited to 'engines/draci/font.cpp')
-rw-r--r-- | engines/draci/font.cpp | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/engines/draci/font.cpp b/engines/draci/font.cpp index 104b341fd1..99f1d37a23 100644 --- a/engines/draci/font.cpp +++ b/engines/draci/font.cpp @@ -30,10 +30,25 @@ namespace Draci { +const Common::String kFontSmall("Small.fon"); +const Common::String kFontBig("Big.fon"); + +Font::Font() : + _fontHeight(0), _maxCharWidth(0), + _charWidths(NULL), _charData(0) { + + setFont(kFontBig); + + _currentFontColour = _fontColour1; +} + Font::Font(const Common::String &filename) : _fontHeight(0), _maxCharWidth(0), _charWidths(NULL), _charData(0) { + setFont(filename); + + _currentFontColour = _fontColour1; } Font::~Font() { @@ -41,6 +56,15 @@ Font::~Font() { } /** + * @brief Sets the varying font colour + * @param colour The new font colour + */ + +void Font::setColour(uint8 colour) { + _currentFontColour = colour; +} + +/** * @brief Loads fonts from a file * @param path Path to font file * @return true if the font was loaded successfully, false otherwise @@ -135,9 +159,31 @@ void Font::drawChar(Graphics::Surface *dst, uint8 chr, int tx, int ty) const { for (int y = 0; y < yPixelsToDraw; ++y) { for (int x = 0; x <= xPixelsToDraw; ++x) { - // Paint pixel int curr = y * _maxCharWidth + x; - ptr[x] = _charData[charOffset + curr]; + int colour = _charData[charOffset + curr]; + + // Replace colour with font colours + switch (colour) { + + case 254: + colour = _currentFontColour; + break; + + case 253: + colour = _fontColour2; + break; + + case 252: + colour = _fontColour3; + break; + + case 251: + colour = _fontColour4; + break; + } + + // Paint pixel + ptr[x] = colour; } // Advance to next row |