[Scummvm-cvs-logs] SF.net SVN: scummvm:[42990] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sun Aug 2 07:09:56 CEST 2009


Revision: 42990
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42990&view=rev
Author:   dkasak13
Date:     2009-08-02 05:09:55 +0000 (Sun, 02 Aug 2009)

Log Message:
-----------
Calculate the character length of Text objects (without the '|' separators) when setting a new string. Implemented Text::getLength().

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/sprite.h

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-08-02 03:16:44 UTC (rev 42989)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-08-02 05:09:55 UTC (rev 42990)
@@ -307,6 +307,13 @@
 	_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 @@
 } 
 
 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 @@
 	_spacing = spacing;
 }
 
+uint Text::getLength() {
+	return _length;
+}
+
 void Text::draw(Surface *surface, bool markDirty) const {
 	_font->setColour(_colour);
 

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-08-02 03:16:44 UTC (rev 42989)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-08-02 05:09:55 UTC (rev 42990)
@@ -129,6 +129,8 @@
 	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. 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list