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

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Wed Jul 1 03:43:20 CEST 2009


Revision: 41984
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41984&view=rev
Author:   dkasak13
Date:     2009-07-01 01:43:20 +0000 (Wed, 01 Jul 2009)

Log Message:
-----------
Added Text::setText() and Text::setColour() methods. Changed demo animation to use them.

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

Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-01 01:25:48 UTC (rev 41983)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-01 01:43:20 UTC (rev 41984)
@@ -129,26 +129,30 @@
 	Common::String testString = "Testing, testing, read all about it!";
 	xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
 	ypos = 130;
-	Text txt1(testString, _font, kFontColour1, xpos, ypos, 1);
+	Text txt(testString, _font, kFontColour1, xpos, ypos, 1);
 	
-	txt1.draw(surf);
+	txt.draw(surf);
 
 	// Draw small string
 	_font->setFont(kFontSmall);
 	testString = "I'm smaller than the font above me.";
 	xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
 	ypos += 20;
-	Text txt2(testString, _font, kFontColour1, xpos, ypos, 1);
+	txt.setText(testString);
+	txt._x = xpos;
+	txt._y = ypos;
 
-	txt2.draw(surf);
+	txt.draw(surf);
 
 	// Overflow handling test	
 	testString = "Checking overflooooooooooooooooooooooooow...";
 	xpos = 50;
 	ypos += 20;
-	Text txt3(testString, _font, kFontColour1, xpos, ypos, 1);
+	txt.setText(testString);
+	txt._x = xpos;
+	txt._y = ypos;
 
-	txt3.draw(surf);
+	txt.draw(surf);
 
 	_screen->copyToScreen();
 
@@ -162,6 +166,12 @@
 	}	
 
 	testString = "I'm transparent";
+	xpos = (kScreenWidth - _font->getStringWidth(testString, 1)) / 2;
+	ypos = 80;
+	txt.setText(testString);
+	txt.setColour(kDefaultTransparent);
+	txt._x = xpos;
+	txt._y = ypos;
 	for (unsigned int t = 0; t < 25; ++t) {
 		debugC(5, kDraciGeneralDebugLevel, "Drawing frame %d...", t);
 
@@ -177,9 +187,7 @@
 		sp.draw(surf);
 
 		// Draw transparent text over dragon
-		_font->setColour(kDefaultTransparent);	
-		_font->drawString(surf, testString, 
-		(kScreenWidth - _font->getStringWidth(testString, 1)) / 2, 80, 1);
+		txt.draw(surf);
 
 		_screen->copyToScreen();
 		_system->delayMillis(100);

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-07-01 01:25:48 UTC (rev 41983)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-07-01 01:43:20 UTC (rev 41984)
@@ -129,13 +129,13 @@
 Text::Text(const Common::String &str, Font *font, byte fontColour, 
 				uint16 x, uint16 y, uint spacing) {
 	uint len = str.size();
+	_length = len;
 	
 	_x = x;
 	_y = y;
 	
 	_text = new byte[len];
 	memcpy(_text, str.c_str(), len);
-	_length = len;
 	
 	_spacing = spacing;
 	_colour = fontColour;
@@ -144,9 +144,23 @@
 } 
 
 Text::~Text() {
-	delete _text;
+	delete[] _text;
 }
 
+void Text::setText(const Common::String &str) {
+	delete[] _text;
+	
+	uint len = str.size();
+	_length = len;
+
+	 _text = new byte[len];
+	memcpy(_text, str.c_str(), len);
+}
+
+void Text::setColour(byte fontColour) {
+	_colour = fontColour;
+}
+
 void Text::draw(Surface *surface) const {
 	_font->setColour(_colour);
 	_font->drawString(surface, _text, _length, _x, _y, _spacing);

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-07-01 01:25:48 UTC (rev 41983)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-07-01 01:43:20 UTC (rev 41984)
@@ -78,6 +78,9 @@
 		uint16 x = 0, uint16 y = 0, uint spacing = 0);
 	~Text();
 	
+	void setText(const Common::String &str);
+	void setColour(byte fontColour);
+	
 	void draw(Surface *surface) const;
 	
 	byte *_text;


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