[Scummvm-cvs-logs] CVS: residual actor.cpp,1.46,1.47 actor.h,1.21,1.22 driver_gl.cpp,1.40,1.41 engine.cpp,1.66,1.67 lua.cpp,1.112,1.113 textobject.cpp,1.21,1.22 textobject.h,1.10,1.11

Pawel Kolodziejski aquadran at users.sourceforge.net
Sun Mar 20 08:48:46 CET 2005


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19537

Modified Files:
	actor.cpp actor.h driver_gl.cpp engine.cpp lua.cpp 
	textobject.cpp textobject.h 
Log Message:
added experimental subtitles for speak, it may crash after finish speak line

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- actor.cpp	19 Mar 2005 21:48:22 -0000	1.46
+++ actor.cpp	20 Mar 2005 16:48:26 -0000	1.47
@@ -31,8 +31,6 @@
 #include <cmath>
 #include <cstring>
 
-Font *Actor::_sayLineFont = NULL;
-
 Actor::Actor(const char *name) :
 		_name(name), _talkColor(255, 255, 255), _pos(0, 0, 0),
 		_pitch(0), _yaw(0), _roll(0), _walkRate(0), _turnRate(0),
@@ -221,7 +219,6 @@
 	if (msg[0] == '/' || msg[0] == 0 || msgId[0] == 0)
 		return;
 
-	//	_sayLineText = new TextObject(msg, 10, 20, _sayLineFont, _talkColor);
 	// During movies, SayLine is called for text display only
 	if (!g_smush->isPlaying()) {
 		
@@ -251,10 +248,18 @@
 		_talkAnim = -1;
 	}
 
-	if (_sayLineText != NULL) {
+	if (_sayLineText) {
 		g_engine->killTextObject(_sayLineText);
 		delete _sayLineText;
+		_sayLineText = NULL;
 	}
+
+	_sayLineText = new TextObject();
+	_sayLineText->setDefaults(&sayLineDefaults);
+	_sayLineText->setText((char *)msg);
+	_sayLineText->setFGColor(&_talkColor);
+	_sayLineText->createBitmap();
+	g_engine->registerTextObject(_sayLineText);
 }
 
 bool Actor::talking() {
@@ -271,6 +276,12 @@
 	} else if (_mumbleChore >= 0) {
 		_mumbleCostume->stopChore(_mumbleChore);
 	}
+
+	if (_sayLineText != NULL) {
+		g_engine->killTextObject(_sayLineText);
+		delete _sayLineText;
+		_sayLineText = NULL;
+	}
 }
 
 void Actor::pushCostume(const char *name) {

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- actor.h	19 Mar 2005 21:48:22 -0000	1.21
+++ actor.h	20 Mar 2005 16:48:26 -0000	1.22
@@ -116,8 +116,6 @@
 	}
 	void setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw);
 
-	static void setSayLineFont(Font *font) { _sayLineFont = font; }
-
 private:
 	std::string _name;
 	std::string _setName;

Index: driver_gl.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/driver_gl.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- driver_gl.cpp	20 Mar 2005 14:03:08 -0000	1.40
+++ driver_gl.cpp	20 Mar 2005 16:48:26 -0000	1.41
@@ -655,5 +655,5 @@
 
 void DriverGL::destroyTextBitmap(TextObjectHandle *handle) {
 	glDeleteTextures(handle->numTex, (GLuint *)handle->texIds);
-	delete[] handle->texIds;
+	delete[] (GLuint *)handle->texIds;
 }

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- engine.cpp	19 Mar 2005 21:48:23 -0000	1.66
+++ engine.cpp	20 Mar 2005 16:48:26 -0000	1.67
@@ -43,7 +43,37 @@
 		_currScene(NULL), _selectedActor(NULL) {
 	for (int i = 0; i < SDLK_EXTRA_LAST; i++)
 		_controlsEnabled[i] = false;
-	_speechMode = 2; // VOICE_ONLY
+	_speechMode = 3; // VOICE + TEXT
+
+	textObjectDefaults.x = 0;
+	textObjectDefaults.y = 200;
+	textObjectDefaults.width = 10;
+	textObjectDefaults.height = 0;
+	textObjectDefaults.fgColor._vals[0] = 255;
+	textObjectDefaults.fgColor._vals[1] = 255;
+	textObjectDefaults.fgColor._vals[2] = 255;
+	textObjectDefaults.font = NULL;
+	textObjectDefaults.justify = 2;
+
+	sayLineDefaults.x = 0;
+	sayLineDefaults.y = 100;
+	sayLineDefaults.width = 0;
+	sayLineDefaults.height = 0;
+	sayLineDefaults.fgColor._vals[0] = 255;
+	sayLineDefaults.fgColor._vals[1] = 255;
+	sayLineDefaults.fgColor._vals[2] = 255;
+	sayLineDefaults.font = NULL;
+	sayLineDefaults.justify = 1;
+
+	printLineDefaults.x = 0;
+	printLineDefaults.y = 100;
+	printLineDefaults.width = 0;
+	printLineDefaults.height = 0;
+	printLineDefaults.fgColor._vals[0] = 255;
+	printLineDefaults.fgColor._vals[1] = 255;
+	printLineDefaults.fgColor._vals[2] = 255;
+	printLineDefaults.font = NULL;
+	printLineDefaults.justify = 1;
 }
 
 void Engine::mainLoop() {

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- lua.cpp	20 Mar 2005 13:51:40 -0000	1.112
+++ lua.cpp	20 Mar 2005 16:48:26 -0000	1.113
@@ -291,7 +291,7 @@
 
 		key_text = lua_getstring(key);		
 		if (strstr(key_text, "font"))
-			Actor::setSayLineFont(check_font(2));
+			sayLineDefaults.font = check_font(2);
 		else
 			error("Unknown SetSayLineDefaults key %s\n", key_text);
 	}
@@ -1208,13 +1208,14 @@
 	lua_Object tableObj = lua_getparam(2);
 
 	TextObject *textObject = new TextObject();
-	textObject->setDefaultsTextObjectParams();
+	textObject->setDefaults(&textObjectDefaults);
 
 	if (lua_istable(tableObj))
 		getTextObjectParams(textObject, tableObj);
 
 	textObject->setText(line);
 	textObject->createBitmap();
+	g_engine->registerTextObject(textObject);
 
 	lua_pushusertag(textObject, MKID('TEXT'));
 	lua_pushnumber(textObject->getBitmapWidth());
@@ -1261,10 +1262,12 @@
 
 	modifyObject->destroyBitmap();
 
+	textObject->setDefaults(&textObjectDefaults);
 	if (lua_istable(tableObj))
 		getTextObjectParams(modifyObject, tableObj);
 
 	modifyObject->createBitmap();
+	g_engine->registerTextObject(modifyObject);
 
 	lua_pushnumber(modifyObject->getBitmapWidth());
 	lua_pushnumber(modifyObject->getBitmapHeight());
@@ -1276,6 +1279,12 @@
 	lua_pushnumber(textObjectParam->getBitmapHeight());
 }
 
+static void BlastText() {
+	// there is some diffrence to MakeTextObject
+	// it draw directly to gfx buffer from here, not from main loop
+	MakeTextObject();
+}
+
 static void SetSpeechMode() {
 	int mode = check_int(1);
 	if ((mode >= 1) && (mode <= 3))
@@ -1402,48 +1411,6 @@
 	return value;
 }
 
-static void BlastText() {
-	char * str = luaL_check_string(1), *key_text = NULL;
-	lua_Object table_obj = lua_getparam(2), key;
-	int x = 0, y = 0;//, height = 0, width = 0;
-	Color *fgColor = NULL;
-
-	for (;;) {
-		lua_pushobject(table_obj);
-		if (key_text)
-			lua_pushobject(key);
-		else
-			lua_pushnil();
-
-		lua_call("next");
-		key = lua_getresult(1);
-
-		if (lua_isnil(key)) 
-			break;
-
-		key_text = lua_getstring(key);
-		//val_text=lua_getstring(lua_getresult(2));
-		if (strstr(key_text, "x"))
-			x = atoi(lua_getstring(lua_getresult(2)));
-		else if (strstr(key_text, "y"))
-			y = atoi(lua_getstring(lua_getresult(2)));
-		else if (strstr(key_text, "fgcolor"))
-			fgColor = check_color(2);
-		else if (strstr(key_text, "font"))
-			lua_getresult(2);
-		else if (strstr(key_text, "center")) // TRUE or FALSE
-			lua_getresult(2);
-		else if (strstr(key_text, "disabled")) // TRUE or FALSE
-			lua_getresult(2);
-		else
-			error("Unknown BlastText key %s\n", key_text);
-	}
-
-	char msgId[32];
-	std::string msg = parseMsgText(str, msgId);
-	warning("STUB: BlastText(\"%s\", x = %d, y = %d)\n", msg.c_str(), x, y);
-}
-
 static void LockFont() {
 	lua_Object param1 = lua_getparam(1);
 	if (lua_isstring(param1)) {

Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- textobject.cpp	20 Mar 2005 15:48:58 -0000	1.21
+++ textobject.cpp	20 Mar 2005 16:48:26 -0000	1.22
@@ -23,6 +23,10 @@
 
 std::string parseMsgText(const char *msg, char *msgId);
 
+TextObjectDefaults sayLineDefaults;
+TextObjectDefaults printLineDefaults;
+TextObjectDefaults textObjectDefaults;
+
 TextObject::TextObject() :
 		_created(false), _x(0), _y(0), _width(0), _height(0), _justify(0),
 		_font(NULL), _text(NULL), _textBitmap(NULL), _bitmapWidth(0),
@@ -37,17 +41,14 @@
 	destroyBitmap();
 }
 
-void TextObject::setDefaultsTextObjectParams() {
-	_x = 0;
-	_y = 0;
-	_width = 0;
-	_height = 0;
-	_font = NULL;
-	_fgColor._vals[0] = 0;
-	_fgColor._vals[1] = 0;
-	_fgColor._vals[2] = 0;
-	_justify = 0;
-	_text = NULL;
+void TextObject::setDefaults(TextObjectDefaults *defaults) {
+	_x = defaults->x;
+	_y = defaults->x;
+	_width = defaults->width;
+	_height = defaults->height;
+	_font = defaults->font;
+	_fgColor = defaults->fgColor;
+	_justify = defaults->justify;
 }
 
 void TextObject::createBitmap() {
@@ -96,7 +97,6 @@
 
 	delete[] _textBitmap;
 	_created = true;
-	g_engine->registerTextObject(this);
 }
 
 void TextObject::destroyBitmap() {

Index: textobject.h
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- textobject.h	20 Mar 2005 15:48:58 -0000	1.10
+++ textobject.h	20 Mar 2005 16:48:26 -0000	1.11
@@ -26,13 +26,25 @@
 #include <string>
 #include <SDL.h>
 
+struct TextObjectDefaults {
+	Color fgColor;
+	int x, y;
+	int width, height;
+	int justify;
+	Font *font;
+};
+
+extern TextObjectDefaults sayLineDefaults;
+extern TextObjectDefaults printLineDefaults;
+extern TextObjectDefaults textObjectDefaults;
+
 class TextObject {
 public:
 	TextObject();
 	~TextObject();
 	void createBitmap();
 	void destroyBitmap();
-	void setDefaultsTextObjectParams();
+	void setDefaults(TextObjectDefaults *defaults);
 	void setText(char *text) { _text = text; }
 	void setX(int x) { _x = x; }
 	void setY(int y) { _y = y; }





More information about the Scummvm-git-logs mailing list