diff options
author | Filippos Karapetis | 2010-07-02 08:55:12 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-07-02 08:55:12 +0000 |
commit | 91a414dbc9f712484de2e5dac66ae3dafe467e6a (patch) | |
tree | e9d367c18fe49c5e29a14e632f46631e051d132b | |
parent | b252d5f0b97e229e73ed1c63b48d8c2e7896775a (diff) | |
download | scummvm-rg350-91a414dbc9f712484de2e5dac66ae3dafe467e6a.tar.gz scummvm-rg350-91a414dbc9f712484de2e5dac66ae3dafe467e6a.tar.bz2 scummvm-rg350-91a414dbc9f712484de2e5dac66ae3dafe467e6a.zip |
Extended the SCI2 text drawing hack for SCI2.1 too, and added font caching
svn-id: r50592
-rw-r--r-- | engines/sci/graphics/frameout.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 48a7742f14..9ce4474ee3 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -278,29 +278,23 @@ void GfxFrameout::kernelFrameout() { // Most likely a text entry // This draws text the "SCI0-SCI11" way. In SCI2, text is prerendered in kCreateTextBitmap // TODO: rewrite this the "SCI2" way (i.e. implement the text buffer to draw inside kCreateTextBitmap) - // This doesn't work for SCI2.1 games... - if (getSciVersion() == SCI_VERSION_2) { - Kernel *kernel = g_sci->getKernel(); - if (lookupSelector(_segMan, itemEntry->object, kernel->_selectorCache.text, NULL, NULL) == kSelectorVariable) { - Common::String text = _segMan->getString(readSelector(_segMan, itemEntry->object, SELECTOR(text))); - int16 fontRes = readSelectorValue(_segMan, itemEntry->object, SELECTOR(font)); - GfxFont *font = new GfxFontFromResource(_resMan, _screen, fontRes); - bool dimmed = readSelectorValue(_segMan, itemEntry->object, SELECTOR(dimmed)); - uint16 foreColor = readSelectorValue(_segMan, itemEntry->object, SELECTOR(fore)); - uint16 curX = itemEntry->x; - uint16 curY = itemEntry->y; - for (uint32 i = 0; i < text.size(); i++) { - unsigned char curChar = text[i]; - // TODO: proper text splitting... this is a hack - if ((curChar == ' ' && i > 0 && text[i - i] == ' ') || curChar == '\n' || - (curX + font->getCharWidth(curChar) > _screen->getWidth())) { - curY += font->getHeight(); - curX = itemEntry->x; - } - font->draw(curChar, curY, curX, foreColor, dimmed); - curX += font->getCharWidth(curChar); + if (lookupSelector(_segMan, itemEntry->object, SELECTOR(text), NULL, NULL) == kSelectorVariable) { + Common::String text = _segMan->getString(readSelector(_segMan, itemEntry->object, SELECTOR(text))); + GfxFont *font = _cache->getFont(readSelectorValue(_segMan, itemEntry->object, SELECTOR(font))); + bool dimmed = readSelectorValue(_segMan, itemEntry->object, SELECTOR(dimmed)); + uint16 foreColor = readSelectorValue(_segMan, itemEntry->object, SELECTOR(fore)); + uint16 curX = itemEntry->x; + uint16 curY = itemEntry->y; + for (uint32 i = 0; i < text.size(); i++) { + unsigned char curChar = text[i]; + // TODO: proper text splitting... this is a hack + if ((curChar == ' ' && i > 0 && text[i - i] == ' ') || curChar == '\n' || + (curX + font->getCharWidth(curChar) > _screen->getWidth())) { + curY += font->getHeight(); + curX = itemEntry->x; } - delete font; + font->draw(curChar, curY, curX, foreColor, dimmed); + curX += font->getCharWidth(curChar); } } } |