diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index 44a6a04b234..917637a7c13 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -778,7 +778,7 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { // TODO: argument 0 is usually 0, and arguments 1 and 2 are usually 1 reg_t object = argv[3]; Common::String text = s->_segMan->getString(GET_SEL32(s->_segMan, object, text)); - debug("%s", text.c_str()); + debug("kCreateTextBitmap: %s", text.c_str()); return NULL_REG; } diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp index 8e3f57e547f..c2bc7de2ac6 100644 --- a/engines/sci/engine/selector.cpp +++ b/engines/sci/engine/selector.cpp @@ -165,6 +165,8 @@ void Kernel::mapSelectors() { FIND_SELECTOR(plane); FIND_SELECTOR(top); FIND_SELECTOR(left); + FIND_SELECTOR(dimmed); + FIND_SELECTOR(fore); #endif } diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h index 6da18688050..85ece64d7ad 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -204,6 +204,9 @@ struct SelectorCache { Selector plane; Selector top; Selector left; + + Selector fore; + Selector dimmed; #endif }; diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 9cd4c6d7f56..741501744c6 100644 --- a/engines/sci/graphics/frameout.cpp +++ b/engines/sci/graphics/frameout.cpp @@ -32,6 +32,7 @@ #include "sci/engine/selector.h" #include "sci/engine/vm.h" #include "sci/graphics/cache.h" +#include "sci/graphics/font.h" #include "sci/graphics/view.h" #include "sci/graphics/screen.h" #include "sci/graphics/picture.h" @@ -149,6 +150,7 @@ void GfxFrameout::kernelFrameout() { itemEntry->priority = GET_SEL32V(_segMan, itemObject, priority); itemEntry->scaleX = GET_SEL32V(_segMan, itemObject, scaleX); itemEntry->scaleY = GET_SEL32V(_segMan, itemObject, scaleY); + itemEntry->object = itemObject; itemEntry->x += planeLeft; itemEntry->y += planeTop; @@ -198,6 +200,31 @@ void GfxFrameout::kernelFrameout() { view->draw(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, 0, false); else view->drawScaled(itemEntry->celRect, itemEntry->celRect, itemEntry->celRect, itemEntry->loopNo, itemEntry->celNo, 255, itemEntry->scaleX, itemEntry->scaleY); + } else { + // 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) + Kernel *kernel = ((SciEngine *)g_engine)->getKernel(); + if (lookup_selector(_segMan, itemEntry->object, kernel->_selectorCache.text, NULL, NULL) == kSelectorVariable) { + Common::String text = _segMan->getString(GET_SEL32(_segMan, itemEntry->object, text)); + int16 fontRes = GET_SEL32V(_segMan, itemEntry->object, font); + Font *font = new Font(_resMan, _screen, fontRes); + bool dimmed = GET_SEL32V(_segMan, itemEntry->object, dimmed); + uint16 foreColor = GET_SEL32V(_segMan, itemEntry->object, fore); + uint16 curX = itemEntry->x; + uint16 curY = itemEntry->y; + for (uint32 i = 0; i < text.size(); i++) { + // TODO: proper text splitting... this is a hack + if ((text[i] == ' ' && i > 0 && text[i - i] == ' ') || text[i] == '\n' || + (curX + font->getCharWidth(text[i]) > _screen->getWidth())) { + curY += font->getCharHeight('A'); + curX = itemEntry->x; + } + font->draw(text[i], curY, curX, foreColor, dimmed); + curX += font->getCharWidth(text[i]); + } + delete font; + } } listIterator++; }