diff options
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 7 | ||||
-rw-r--r-- | engines/sci/graphics/text32.cpp | 11 | ||||
-rw-r--r-- | engines/sci/graphics/text32.h | 4 |
3 files changed, 12 insertions, 10 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index a91b9e8e81..e3a41fe361 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1389,13 +1389,14 @@ reg_t kCreateTextBitmap(EngineState *s, int argc, reg_t *argv) { debugC(kDebugLevelStrings, "kCreateTextBitmap case 0 (%04x:%04x, %04x:%04x, %04x:%04x)", PRINT_REG(argv[1]), PRINT_REG(argv[2]), PRINT_REG(argv[3])); debugC(kDebugLevelStrings, "%s", text.c_str()); - // TODO: arguments 1 and 2 - g_sci->_gfxText32->createTextBitmap(object); + uint16 maxWidth = argv[1].toUint16(); // nsRight - nsLeft + 1 + uint16 maxHeight = argv[2].toUint16(); // nsBottom - nsTop + 1 + g_sci->_gfxText32->createTextBitmap(object, maxWidth, maxHeight); break; } case 1: { if (argc != 2) { - warning("kCreateTextBitmap(0): expected 2 arguments, got %i", argc); + warning("kCreateTextBitmap(1): expected 2 arguments, got %i", argc); return NULL_REG; } reg_t object = argv[1]; diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index 82740c0ad9..6ec1261a88 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -56,7 +56,7 @@ void GfxText32::purgeCache() { _textCache.clear(); } -void GfxText32::createTextBitmap(reg_t textObject) { +void GfxText32::createTextBitmap(reg_t textObject, uint16 maxWidth, uint16 maxHeight) { if (_textCache.size() >= MAX_CACHED_TEXTS) purgeCache(); @@ -70,7 +70,7 @@ void GfxText32::createTextBitmap(reg_t textObject) { _textCache.erase(textId); } - _textCache[textId] = createTextEntry(textObject); + _textCache[textId] = createTextEntry(textObject, maxWidth, maxHeight); } // TODO: Finish this! @@ -133,9 +133,11 @@ TextEntry *GfxText32::getTextEntry(reg_t textObject) { } // TODO: Finish this! Currently buggy. -TextEntry *GfxText32::createTextEntry(reg_t textObject) { +TextEntry *GfxText32::createTextEntry(reg_t textObject, uint16 maxWidth, uint16 maxHeight) { reg_t stringObject = readSelector(_segMan, textObject, SELECTOR(text)); + // TODO: maxWidth, maxHeight (if > 0) + // The object in the text selector of the item can be either a raw string // or a Str object. In the latter case, we need to access the object's data // selector to get the raw string. @@ -174,10 +176,9 @@ TextEntry *GfxText32::createTextEntry(reg_t textObject) { memset(newEntry->surface, 0, newEntry->width * newEntry->height); newEntry->text = _segMan->getString(stringObject); - int16 maxTextWidth, charCount; + int16 maxTextWidth = 0, charCount = 0; uint16 curX = 0, curY = 0; - maxTextWidth = 0; while (*text) { charCount = GetLongest(text, planeRect.width(), font); if (charCount == 0) diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index 7f70afc880..620bcfc155 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -51,7 +51,7 @@ class GfxText32 { public: GfxText32(SegManager *segMan, GfxCache *fonts, GfxScreen *screen); ~GfxText32(); - void createTextBitmap(reg_t textObject); + void createTextBitmap(reg_t textObject, uint16 maxWidth = 0, uint16 maxHeight = 0); void drawTextBitmap(reg_t textObject, uint16 textX, uint16 textY, uint16 planeWidth); int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font); TextEntry *getTextEntry(reg_t textObject); @@ -59,7 +59,7 @@ public: void kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight); private: - TextEntry *createTextEntry(reg_t textObject); + TextEntry *createTextEntry(reg_t textObject, uint16 maxWidth, uint16 maxHeight); int16 Size(Common::Rect &rect, const char *text, GuiResourceId fontId, int16 maxWidth); void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight, bool restoreFont); void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight); |