[Scummvm-cvs-logs] SF.net SVN: scummvm:[34470] residual/trunk/engine

aquadran at users.sourceforge.net aquadran at users.sourceforge.net
Wed Sep 10 10:10:07 CEST 2008


Revision: 34470
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34470&view=rev
Author:   aquadran
Date:     2008-09-10 08:10:06 +0000 (Wed, 10 Sep 2008)

Log Message:
-----------
fixed text positioning for blast and normal drawing (not yet for subtitles)

Modified Paths:
--------------
    residual/trunk/engine/actor.cpp
    residual/trunk/engine/lua.cpp
    residual/trunk/engine/textobject.cpp
    residual/trunk/engine/textobject.h

Modified: residual/trunk/engine/actor.cpp
===================================================================
--- residual/trunk/engine/actor.cpp	2008-09-10 06:59:55 UTC (rev 34469)
+++ residual/trunk/engine/actor.cpp	2008-09-10 08:10:06 UTC (rev 34470)
@@ -363,7 +363,7 @@
 		_sayLineText = NULL;
 	}
 
-	_sayLineText = new TextObject();
+	_sayLineText = new TextObject(false);
 	_sayLineText->setDefaults(&sayLineDefaults);
 	_sayLineText->setText((char *)msg);
 	_sayLineText->setFGColor(&_talkColor);

Modified: residual/trunk/engine/lua.cpp
===================================================================
--- residual/trunk/engine/lua.cpp	2008-09-10 06:59:55 UTC (rev 34469)
+++ residual/trunk/engine/lua.cpp	2008-09-10 08:10:06 UTC (rev 34470)
@@ -2288,7 +2288,7 @@
 		if (strmatch(key_text, "x"))
 			textObject->setX(atoi(lua_getstring(lua_getresult(2))));
 		else if (strmatch(key_text, "y"))
-			textObject->setY(atoi(lua_getstring(lua_getresult(2))));
+			textObject->setY(atoi(lua_getstring(lua_getresult(2))) + textObject->getBaseOffestY());
 		else if (strmatch(key_text, "width"))
 			textObject->setWidth(atoi(lua_getstring(lua_getresult(2))));
 		else if (strmatch(key_text, "height"))
@@ -2384,13 +2384,13 @@
 		return;
 	}
 
+	modifyObject->destroyBitmap();
+
 	if (lua_istable(tableObj))
 		getTextObjectParams(modifyObject, tableObj);
 	else if (debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
 		warning("Expecting table parameter!");
 
-	// to modify current bitmap it need recreate it
-	modifyObject->destroyBitmap();
 	modifyObject->createBitmap();
 
 	lua_pushnumber(modifyObject->getBitmapWidth());
@@ -2415,7 +2415,7 @@
 }
 
 static void MakeTextObject() {
-	TextObject *textObject = new TextObject();
+	TextObject *textObject = new TextObject(false);
 	lua_Object tableObj;
 	const char *line;
 
@@ -2434,6 +2434,8 @@
 	//printf("Make: %s\n", (char *)text.c_str());
 
 	textObject->setText((char *)text.c_str());
+	textObject->subBaseOffestY();
+
 	textObject->createBitmap();
 	g_engine->registerTextObject(textObject);
 
@@ -2472,7 +2474,7 @@
 
 static void BlastText() {
 	DEBUG_FUNCTION();
-	TextObject *textObject = new TextObject();
+	TextObject *textObject = new TextObject(true);
 	lua_Object tableObj;
 	const char *line;
 

Modified: residual/trunk/engine/textobject.cpp
===================================================================
--- residual/trunk/engine/textobject.cpp	2008-09-10 06:59:55 UTC (rev 34469)
+++ residual/trunk/engine/textobject.cpp	2008-09-10 08:10:06 UTC (rev 34470)
@@ -37,7 +37,7 @@
 TextObjectDefaults printLineDefaults;
 TextObjectDefaults textObjectDefaults;
 
-TextObject::TextObject() :
+TextObject::TextObject(bool blastDraw) :
 		_created(false), _x(0), _y(0), _width(0), _height(0), _justify(0),
 		_numberLines(1), _disabled(false), _font(NULL), _textBitmap(NULL),
 		_bitmapWidthPtr(NULL), _textObjectHandle(NULL) {
@@ -45,6 +45,7 @@
 	_fgColor._vals[0] = 0;
 	_fgColor._vals[1] = 0;
 	_fgColor._vals[2] = 0;
+	_blastDraw = blastDraw;
 }
 
 void TextObject::setText(char *text) {
@@ -212,10 +213,11 @@
 	for (int i = 0; i < _numberLines; i++) {
 		int y;
 
-		if (_height != 0)
-			y = _y + 5;
+		if (_blastDraw)
+			y = _y;
 		else
-			y = _y + 5;
+			y = _y - _font->getBaseOffsetY();
+
 		if (y < 0)
 			y = 0;
 		

Modified: residual/trunk/engine/textobject.h
===================================================================
--- residual/trunk/engine/textobject.h	2008-09-10 06:59:55 UTC (rev 34469)
+++ residual/trunk/engine/textobject.h	2008-09-10 08:10:06 UTC (rev 34470)
@@ -51,7 +51,7 @@
 
 class TextObject {
 public:
-	TextObject();
+	TextObject(bool blastDraw);
 	~TextObject();
 	void createBitmap();
 	void destroyBitmap();
@@ -59,6 +59,18 @@
 	void setText(char *text);
 	void setX(int x) { _x = x; }
 	void setY(int y) { _y = y; }
+	void subBaseOffestY() {
+		if (_font)
+			_y -= _font->getBaseOffsetY();
+		else
+			_y -= 5;
+	}
+	int getBaseOffestY() {
+		if (_font)
+			return _font->getBaseOffsetY();
+		else
+			return 5;
+	}
 	void setWidth(int width) { _width = width; }
 	void setHeight(int height) { _height = height; }
 	void setFGColor(Color *fgColor) { _fgColor = fgColor; }
@@ -86,6 +98,7 @@
 	int _width, _height;
 	int _justify, _numberLines;
 	bool _disabled;
+	bool _blastDraw;
 	Font *_font;
 	char _textID[256];
 	uint8 *_textBitmap;


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