[Scummvm-cvs-logs] CVS: scummvm/scumm/smush frenderer.cpp,1.10,1.11

Pawel Kolodziejski aquadran at users.sourceforge.net
Thu Nov 21 09:51:02 CET 2002


Update of /cvsroot/scummvm/scummvm/scumm/smush
In directory sc8-pr-cvs1:/tmp/cvs-serv6489

Modified Files:
	frenderer.cpp 
Log Message:
applied patch: #641704

Index: frenderer.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/frenderer.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- frenderer.cpp	16 Nov 2002 19:58:52 -0000	1.10
+++ frenderer.cpp	21 Nov 2002 17:50:14 -0000	1.11
@@ -306,6 +306,7 @@
 }
 
 bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
+	int32 max_substr_width = 0;
 	debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
 	assert(strchr(str, '\n') == 0);
 	char * * words = split(str, ' ');
@@ -324,13 +325,14 @@
 	int32 space_width = charWidth(' ');
 
 	i = 0;
+	width = MIN(width, size.getX());
 	while(i < nb_sub) {
 		int32 substr_width = sizes[i];
 		char * substr = new char[1000];
 		strcpy(substr, words[i]);
 		int32 j = i + 1;
 
-		while(j < nb_sub && (substr_width + space_width + sizes[j]) < size.getX()) {
+		while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
 			substr_width += sizes[j++] + space_width;
 		}
 
@@ -341,6 +343,7 @@
 
 		substrings[nb_subs] = substr;
 		substr_widths[nb_subs++] = substr_width;
+		max_substr_width = MAX(substr_width, max_substr_width);
 		i = j;
 		height += stringHeight(substr);
 	}
@@ -353,6 +356,12 @@
 
 	if(y + height > size.getY()) {
 		y = size.getY() - height;
+	}
+
+	if(x - max_substr_width / 2 < 0) {
+		x = max_substr_width / 2;
+	} else if (x + max_substr_width / 2 >= size.getX()) {
+		x = size.getX() - 1 - max_substr_width / 2;
 	}
 
 	for(i = 0; i < nb_subs; i++) {





More information about the Scummvm-git-logs mailing list