From 854c27ffacd40ab842a71dcbbf3fadfe007e1e1a Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sun, 2 Aug 2009 05:09:55 +0000 Subject: Calculate the character length of Text objects (without the '|' separators) when setting a new string. Implemented Text::getLength(). svn-id: r42990 --- engines/draci/sprite.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'engines/draci/sprite.cpp') diff --git a/engines/draci/sprite.cpp b/engines/draci/sprite.cpp index 31a55bfddb..ecbfaf2767 100644 --- a/engines/draci/sprite.cpp +++ b/engines/draci/sprite.cpp @@ -307,6 +307,13 @@ Text::Text(const Common::String &str, Font *font, byte fontColour, _delay = 0; _text = str; + + _length = 0; + for (uint i = 0; i < _text.size(); ++i) { + if (_text[i] != '|') { + ++_length; + } + } _spacing = spacing; _colour = fontColour; @@ -321,10 +328,18 @@ Text::Text(const Common::String &str, Font *font, byte fontColour, } void Text::setText(const Common::String &str) { + _width = _font->getStringWidth(str, _spacing); _height = _font->getStringHeight(str); _text = str; + + _length = 0; + for (uint i = 0; i < _text.size(); ++i) { + if (_text[i] != '|') { + ++_length; + } + } } void Text::setColour(byte fontColour) { @@ -335,6 +350,10 @@ void Text::setSpacing(uint spacing) { _spacing = spacing; } +uint Text::getLength() { + return _length; +} + void Text::draw(Surface *surface, bool markDirty) const { _font->setColour(_colour); -- cgit v1.2.3