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

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Tue Aug 4 21:09:41 CEST 2009


Revision: 43052
          http://scummvm.svn.sourceforge.net/scummvm/?rev=43052&view=rev
Author:   dkasak13
Date:     2009-08-04 19:09:41 +0000 (Tue, 04 Aug 2009)

Log Message:
-----------
Refactored Script::talk() to use the new centering methods.

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

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-08-04 19:07:12 UTC (rev 43051)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-08-04 19:09:41 UTC (rev 43052)
@@ -538,6 +538,8 @@
 	int personID = params.pop() - 1;
 	int sentenceID = params.pop() - 1;
 
+	Surface *surface = _vm->_screen->getSurface();
+
 	// Fetch string
 	BAFile *f = _vm->_stringsArchive->getFile(sentenceID);
 
@@ -549,7 +551,7 @@
 	Person *person = _vm->_game->getPerson(personID);
 
 	// Set the string and text colour
-	_vm->_screen->getSurface()->markDirtyRect(speechFrame->getRect(true));
+	surface->markDirtyRect(speechFrame->getRect(true));
 	speechFrame->setText(Common::String((const char *)f->_data+1, f->_length-1));
 	speechFrame->setColour(person->_fontColour);
 
@@ -562,31 +564,13 @@
 	// TODO: Implement inventory part
 
 	// Set speech text coordinates
-	// TODO: Put this into a function   
 
-	int x = person->_x;
-	int y = person->_y;
+	int x = surface->centerOnX(person->_x, speechFrame->getWidth());
+	int y = surface->centerOnX(person->_y, speechFrame->getHeight() * 2);
 
-	int difX = speechFrame->getWidth() / 2;
-	int difY = speechFrame->getHeight();
-	int newX = x - difX;
-	int newY = y - difY;
-	
-	if (newX < 0)
-		newX = 0;
+	speechFrame->setX(x);
+	speechFrame->setY(y);
 
-	if (newX + 2 * difX >= kScreenWidth - 1)
-		newX = (kScreenWidth - 1) - difX * 2;
-
-	if (newY < 0)
-		newY = 0;
-
-	if (newY + difY >= kScreenHeight - 1)
-		newY = (kScreenHeight - 1) - difY * 2;
-
-	speechFrame->setX(newX);
-	speechFrame->setY(newY);
-
 	// Call the game loop to enable interactivity until the text expires
 	_vm->_game->loop();
 


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