diff options
author | Benjamin Haisch | 2008-09-16 11:18:09 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-11-20 22:43:06 +0100 |
commit | ca49ded9b346e702538a560ed9de391c3c532b9d (patch) | |
tree | 7aaa9424caef8a17cb74f41e103f64ac7b05ed70 /engines/toltecs | |
parent | 3c479146487893c3e88dc09ead4fb1810ed817c2 (diff) | |
download | scummvm-rg350-ca49ded9b346e702538a560ed9de391c3c532b9d.tar.gz scummvm-rg350-ca49ded9b346e702538a560ed9de391c3c532b9d.tar.bz2 scummvm-rg350-ca49ded9b346e702538a560ed9de391c3c532b9d.zip |
TOLTECS: More changes to wrapGuiText
Diffstat (limited to 'engines/toltecs')
-rw-r--r-- | engines/toltecs/screen.cpp | 36 | ||||
-rw-r--r-- | engines/toltecs/screen.h | 4 |
2 files changed, 21 insertions, 19 deletions
diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp index 8989638734..4f7efaa423 100644 --- a/engines/toltecs/screen.cpp +++ b/engines/toltecs/screen.cpp @@ -628,9 +628,9 @@ void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) { } GuiTextWrapState wrapState; + int16 len; wrapState.width = 0; wrapState.destString = wrapState.textBuffer; - wrapState.len = 0; wrapState.len1 = 0; wrapState.len2 = 0; @@ -640,39 +640,39 @@ void Screen::updateVerbLine(int16 slotIndex, int16 slotOffset) { for (int16 i = 0; i <= _verbLineNum; i++) { wrapState.sourceString = _vm->_script->getSlotData(_verbLineItems[i].slotIndex) + _verbLineItems[i].slotOffset; - wrapGuiText(_fontResIndexArray[0], _verbLineWidth, wrapState); - wrapState.len1 += wrapState.len; + len = wrapGuiText(_fontResIndexArray[0], _verbLineWidth, wrapState); + wrapState.len1 += len; } if (_verbLineCount != 1) { int16 charWidth; if (*wrapState.sourceString < 0xF0) { - while (*wrapState.sourceString > 0x20 && *wrapState.sourceString < 0xF0 && wrapState.len > 0) { + while (*wrapState.sourceString > 0x20 && *wrapState.sourceString < 0xF0 && len > 0) { byte ch = *wrapState.sourceString--; wrapState.len1--; - wrapState.len--; + len--; charWidth = font.getCharWidth(ch) + font.getSpacing() - 1; wrapState.width -= charWidth; } wrapState.width += charWidth; wrapState.sourceString++; - wrapState.len1 -= wrapState.len; - wrapState.len2 = wrapState.len + 1; + wrapState.len1 -= len; + wrapState.len2 = len + 1; drawGuiText(_verbLineX - 1 - (wrapState.width / 2), y, 0xF9, 0xFF, _fontResIndexArray[0], wrapState); wrapState.destString = wrapState.textBuffer; wrapState.width = 0; - wrapGuiText(_fontResIndexArray[0], _verbLineWidth, wrapState); - wrapState.len1 += wrapState.len; + len = wrapGuiText(_fontResIndexArray[0], _verbLineWidth, wrapState); + wrapState.len1 += len; y += 9; } y += 9; } - wrapState.len1 -= wrapState.len; - wrapState.len2 = wrapState.len; + wrapState.len1 -= len; + wrapState.len2 = len; drawGuiText(_verbLineX - 1 - (wrapState.width / 2), y, 0xF9, 0xFF, _fontResIndexArray[0], wrapState); @@ -868,9 +868,8 @@ void Screen::drawGuiTextMulti(byte *textData) { } else { wrapState.destString = wrapState.textBuffer; wrapState.width = 0; - wrapGuiText(_fontResIndexArray[1], 640, wrapState); wrapState.len1 = 0; - wrapState.len2 = wrapState.len; + wrapState.len2 = wrapGuiText(_fontResIndexArray[1], 640, wrapState); drawGuiText(x - wrapState.width / 2, y, _fontColor1, _fontColor2, _fontResIndexArray[1], wrapState); } @@ -878,11 +877,11 @@ void Screen::drawGuiTextMulti(byte *textData) { } -void Screen::wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrapState) { +int16 Screen::wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrapState) { Font font(_vm->_res->load(fontResIndex)); - - wrapState.len = 0; + int16 len = 0; + while (*wrapState.sourceString >= 0x20 && *wrapState.sourceString < 0xF0) { byte ch = *wrapState.sourceString; byte charWidth; @@ -892,10 +891,13 @@ void Screen::wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrap charWidth = font.getCharWidth(ch) + font.getSpacing() - 1; if (wrapState.width + charWidth >= maxWidth) break; - wrapState.len++; + len++; wrapState.width += charWidth; *wrapState.destString++ = *wrapState.sourceString++; } + + return len; + } void Screen::drawGuiText(int16 x, int16 y, byte fontColor1, byte fontColor2, uint fontResIndex, GuiTextWrapState &wrapState) { diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h index fa7cad9430..6050257c1b 100644 --- a/engines/toltecs/screen.h +++ b/engines/toltecs/screen.h @@ -309,7 +309,7 @@ struct TalkTextItem { }; struct GuiTextWrapState { - int16 len, len1, len2; + int16 len1, len2; byte *sourceString; byte *destString; int16 width; @@ -354,7 +354,7 @@ public: // Font/text void registerFont(uint fontIndex, uint resIndex); void drawGuiTextMulti(byte *textData); - void wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrapState); + int16 wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrapState); void drawGuiText(int16 x, int16 y, byte fontColor1, byte fontColor2, uint fontResIndex, GuiTextWrapState &wrapState); int16 drawString(int16 x, int16 y, byte color, uint fontResIndex, byte *text, int len = -1, int16 *ywobble = NULL, bool outline = false); |