aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
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
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')
-rw-r--r--engines/draci/sprite.cpp19
-rw-r--r--engines/draci/sprite.h2
2 files changed, 21 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);
diff --git a/engines/draci/sprite.h b/engines/draci/sprite.h
index 77e45d6a7c..d2aa5ba3af 100644
--- a/engines/draci/sprite.h
+++ b/engines/draci/sprite.h
@@ -129,6 +129,8 @@ public:
void setColour(byte fontColour);
void setSpacing(uint spacing);
+ uint getLength();
+
void draw(Surface *surface, bool markDirty = true) const;
// TODO: drawScaled just calls draw so Text can be accessed through a Drawable pointer.