[Scummvm-cvs-logs] SF.net SVN: scummvm: [29751] scummvm/trunk

cyx at users.sourceforge.net cyx at users.sourceforge.net
Fri Dec 7 21:53:07 CET 2007


Revision: 29751
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29751&view=rev
Author:   cyx
Date:     2007-12-07 12:53:06 -0800 (Fri, 07 Dec 2007)

Log Message:
-----------
add Common::Rect::center (handy for ::setFocusRectangle())

Modified Paths:
--------------
    scummvm/trunk/common/rect.h
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/sky/logic.cpp
    scummvm/trunk/engines/sword2/function.cpp

Modified: scummvm/trunk/common/rect.h
===================================================================
--- scummvm/trunk/common/rect.h	2007-12-07 20:51:53 UTC (rev 29750)
+++ scummvm/trunk/common/rect.h	2007-12-07 20:53:06 UTC (rev 29751)
@@ -189,7 +189,7 @@
 	}
 
 	void translate(int16 dx, int16 dy) {
-		left += dx;	right += dx;
+		left += dx; right += dx;
 		top += dy; bottom += dy;
 	}
 
@@ -200,6 +200,13 @@
 	void debugPrint(int debuglevel = 0, const char *caption = "Rect:") const {
 		debug(debuglevel, "%s %d, %d, %d, %d", caption, left, top, right, bottom);
 	}
+
+	/*! @brief create a rectangle around the given center */
+	static Rect center(int16 cx, int16 cy, int16 w, int16 h) {
+		w /= 2;
+		h /= 2;
+		return Rect(cx - w, cy - h, cx + w, cy + h);
+	}
 };
 
 }	// End of namespace Common

Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2007-12-07 20:51:53 UTC (rev 29750)
+++ scummvm/trunk/engines/scumm/actor.cpp	2007-12-07 20:53:06 UTC (rev 29751)
@@ -1827,8 +1827,7 @@
 
 		// Set the focus area to the calculated position
 		// TODO: Make the size adjust depending on what it's focusing on.
-		Common::Rect rect(x - 96, y - 64, x + 96, y + 64);
-		_system->setFocusRectangle(rect);
+		_system->setFocusRectangle(Common::Rect::center(x, y, 192, 128));
 	}
 
 	if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES))

Modified: scummvm/trunk/engines/sky/logic.cpp
===================================================================
--- scummvm/trunk/engines/sky/logic.cpp	2007-12-07 20:51:53 UTC (rev 29750)
+++ scummvm/trunk/engines/sky/logic.cpp	2007-12-07 20:53:06 UTC (rev 29751)
@@ -2525,8 +2525,7 @@
 	int x = target->xcood - TOP_LEFT_X;
 	int y = target->ycood - TOP_LEFT_Y;
 	// TODO: Make the box size change based on the object that has the focus
-	Common::Rect rect(x - 96, y - 64, x + 96, y + 64);
-	_skyScreen->setFocusRectangle(rect);
+	_skyScreen->setFocusRectangle(Common::Rect::center(x, y, 192, 128));
 
 
 	if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT) || !speechFileFound) {

Modified: scummvm/trunk/engines/sword2/function.cpp
===================================================================
--- scummvm/trunk/engines/sword2/function.cpp	2007-12-07 20:51:53 UTC (rev 29750)
+++ scummvm/trunk/engines/sword2/function.cpp	2007-12-07 20:53:06 UTC (rev 29751)
@@ -925,8 +925,7 @@
 		// position.
 
 		if (_animId) {
-			Common::Rect rect(_textX - 96, _textY - 64, _textX + 96, _textY + 64);
-			_vm->_system->setFocusRectangle(rect);
+			_vm->_system->setFocusRectangle(Common::Rect::center(_textX, _textY, 192, 128));
 		}
 
 		// Is it to be speech or subtitles or both?


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