diff options
author | RichieSams | 2015-02-11 14:57:05 -0600 |
---|---|---|
committer | RichieSams | 2015-02-11 15:13:19 -0600 |
commit | a851fa8e1aef50334402fec65bf89ee8b582ea62 (patch) | |
tree | 13f17fa8bf1603c7b08376791592d523ef13adef /engines/zvision/scripting | |
parent | 55be1b82a84454ae838419e22ce15cade5298665 (diff) | |
download | scummvm-rg350-a851fa8e1aef50334402fec65bf89ee8b582ea62.tar.gz scummvm-rg350-a851fa8e1aef50334402fec65bf89ee8b582ea62.tar.bz2 scummvm-rg350-a851fa8e1aef50334402fec65bf89ee8b582ea62.zip |
ZVISION: Refactor text rendering code in order to fix word wrapping
and clarify the logic. Fixes bug #6801
Diffstat (limited to 'engines/zvision/scripting')
5 files changed, 27 insertions, 29 deletions
diff --git a/engines/zvision/scripting/controls/input_control.cpp b/engines/zvision/scripting/controls/input_control.cpp index 20c8e7ccbc..df0c77ba96 100644 --- a/engines/zvision/scripting/controls/input_control.cpp +++ b/engines/zvision/scripting/controls/input_control.cpp @@ -79,13 +79,13 @@ InputControl::InputControl(ZVision *engine, uint32 key, Common::SeekableReadStre sscanf(values.c_str(), "%u", &fontFormatNumber); - _stringInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringInit.readAllStyles(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("chooser_init_string", true)) { uint fontFormatNumber; sscanf(values.c_str(), "%u", &fontFormatNumber); - _stringChooserInit.readAllStyle(_engine->getStringManager()->getTextLine(fontFormatNumber)); + _stringChooserInit.readAllStyles(_engine->getStringManager()->getTextLine(fontFormatNumber)); } else if (param.matchString("next_tabstop", true)) { sscanf(values.c_str(), "%u", &_nextTabstop); } else if (param.matchString("cursor_dimensions", true)) { @@ -215,9 +215,9 @@ bool InputControl::process(uint32 deltaTimeInMillis) { int32 oldTxtWidth = _txtWidth; if (!_readOnly || !_focused) - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringInit, txt); + _txtWidth = _engine->getTextRenderer()->drawText(_currentInputText, _stringInit, txt); else - _txtWidth = _engine->getTextRenderer()->drawTxt(_currentInputText, _stringChooserInit, txt); + _txtWidth = _engine->getTextRenderer()->drawText(_currentInputText, _stringChooserInit, txt); if (_readOnly || _txtWidth <= _maxTxtWidth) _engine->getRenderManager()->blitSurfaceToBkg(txt, _textRectangle.left, _textRectangle.top); diff --git a/engines/zvision/scripting/controls/input_control.h b/engines/zvision/scripting/controls/input_control.h index 7f272e8d81..9b48514e16 100644 --- a/engines/zvision/scripting/controls/input_control.h +++ b/engines/zvision/scripting/controls/input_control.h @@ -44,8 +44,8 @@ private: Graphics::Surface *_background; Common::Rect _textRectangle; Common::Rect _headerRectangle; - cTxtStyle _stringInit; - cTxtStyle _stringChooserInit; + TextStyleState _stringInit; + TextStyleState _stringChooserInit; uint32 _nextTabstop; bool _focused; diff --git a/engines/zvision/scripting/controls/titler_control.cpp b/engines/zvision/scripting/controls/titler_control.cpp index 542e0a0b67..683d6660af 100644 --- a/engines/zvision/scripting/controls/titler_control.cpp +++ b/engines/zvision/scripting/controls/titler_control.cpp @@ -82,7 +82,7 @@ TitlerControl::~TitlerControl() { void TitlerControl::setString(int strLine) { if (strLine != _curString && strLine >= 0 && strLine < (int)_strings.size()) { _surface->fillRect(Common::Rect(_surface->w, _surface->h), 0); - _engine->getTextRenderer()->drawTxtInOneLine(_strings[strLine], *_surface); + _engine->getTextRenderer()->drawTextWithWordWrapping(_strings[strLine], *_surface); _engine->getRenderManager()->blitSurfaceToBkg(*_surface, _rectangle.left, _rectangle.top); _curString = strLine; } diff --git a/engines/zvision/scripting/effects/ttytext_effect.cpp b/engines/zvision/scripting/effects/ttytext_effect.cpp index c60b3aa8c5..8d340dae39 100644 --- a/engines/zvision/scripting/effects/ttytext_effect.cpp +++ b/engines/zvision/scripting/effects/ttytext_effect.cpp @@ -57,9 +57,9 @@ ttyTextNode::ttyTextNode(ZVision *engine, uint32 key, const Common::String &file delete infile; } _img.create(_r.width(), _r.height(), _engine->_resourcePixelFormat); - _style._sharp = true; - _style.readAllStyle(_txtbuf); - _style.setFont(_fnt); + _state._sharp = true; + _state.readAllStyles(_txtbuf); + _state.updateFontWithTextState(_fnt); _engine->getScriptManager()->setStateValue(_key, 1); } @@ -74,29 +74,27 @@ bool ttyTextNode::process(uint32 deltaTimeInMillis) { if (_nexttime < 0) { if (_txtpos < _txtbuf.size()) { if (_txtbuf[_txtpos] == '<') { - int32 strt = _txtpos; - int32 endt = 0; + int32 start = _txtpos; + int32 end = 0; int16 ret = 0; while (_txtbuf[_txtpos] != '>' && _txtpos < _txtbuf.size()) _txtpos++; - endt = _txtpos; - if (strt != -1) - if ((endt - strt - 1) > 0) - ret = _style.parseStyle(_txtbuf.c_str() + strt + 1, endt - strt - 1); - - if (ret & (TXT_RET_FNTCHG | TXT_RET_FNTSTL | TXT_RET_NEWLN)) { - if (ret & TXT_RET_FNTCHG) - _style.setFont(_fnt); - if (ret & TXT_RET_FNTSTL) - _style.setFontStyle(_fnt); - - if (ret & TXT_RET_NEWLN) - newline(); + end = _txtpos; + if (start != -1) { + if ((end - start - 1) > 0) { + ret = _state.parseStyle(_txtbuf.c_str() + start + 1, end - start - 1); + } + } + + if (ret & (TEXT_CHANGE_FONT_TYPE | TEXT_CHANGE_FONT_STYLE)) { + _state.updateFontWithTextState(_fnt); + } else if (ret & TEXT_CHANGE_NEWLINE) { + newline(); } - if (ret & TXT_RET_HASSTBOX) { + if (ret & TEXT_CHANGE_HAS_STATE_BOX) { Common::String buf; - buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_style._statebox)); + buf = Common::String::format("%d", _engine->getScriptManager()->getStateValue(_state._statebox)); for (uint8 j = 0; j < buf.size(); j++) outchar(buf[j]); @@ -158,7 +156,7 @@ void ttyTextNode::newline() { } void ttyTextNode::outchar(uint16 chr) { - uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_style._red, _style._green, _style._blue); + uint32 clr = _engine->_resourcePixelFormat.RGBToColor(_state._red, _state._green, _state._blue); if (_dx + _fnt.getCharWidth(chr) > _r.width()) newline(); diff --git a/engines/zvision/scripting/effects/ttytext_effect.h b/engines/zvision/scripting/effects/ttytext_effect.h index 8d8a2518c7..18cbbbaee3 100644 --- a/engines/zvision/scripting/effects/ttytext_effect.h +++ b/engines/zvision/scripting/effects/ttytext_effect.h @@ -51,7 +51,7 @@ public: private: Common::Rect _r; - cTxtStyle _style; + TextStyleState _state; StyledTTFont _fnt; Common::String _txtbuf; uint32 _txtpos; |