aboutsummaryrefslogtreecommitdiff
path: root/engines/draci/sprite.cpp
diff options
context:
space:
mode:
authorDenis Kasak2009-08-02 05:09:55 +0000
committerDenis Kasak2009-08-02 05:09:55 +0000
commit854c27ffacd40ab842a71dcbbf3fadfe007e1e1a (patch)
tree9d13e6396fcbb7c91eb6a912d25959a6269865b1 /engines/draci/sprite.cpp
parent2d1df86f6910efe67b8f843448fa2f7c28578a62 (diff)
downloadscummvm-rg350-854c27ffacd40ab842a71dcbbf3fadfe007e1e1a.tar.gz
scummvm-rg350-854c27ffacd40ab842a71dcbbf3fadfe007e1e1a.tar.bz2
scummvm-rg350-854c27ffacd40ab842a71dcbbf3fadfe007e1e1a.zip
Calculate the character length of Text objects (without the '|' separators) when setting a new string. Implemented Text::getLength().
svn-id: r42990
Diffstat (limited to 'engines/draci/sprite.cpp')
-rw-r--r--engines/draci/sprite.cpp19
1 files changed, 19 insertions, 0 deletions
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);