[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.444,1.445

Oliver Kiehl olki at users.sourceforge.net
Fri Jul 30 13:06:02 CEST 2004


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

Modified Files:
	simon.cpp 
Log Message:
fix subtitle alignment


Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.444
retrieving revision 1.445
diff -u -d -r1.444 -r1.445
--- simon.cpp	30 Jul 2004 11:47:27 -0000	1.444
+++ simon.cpp	30 Jul 2004 20:05:24 -0000	1.445
@@ -4183,11 +4183,12 @@
 	char *convertedString2 = convertedString;
 	int16 height, len_div_3;
 	int stringLength = strlen(string);
-	int pos, padding, lettersPerRow;
+	int pos, padding, lettersPerRow, lettersPerRowJustified;
 	const int textHeight = 10;
 
 	height = textHeight;
 	lettersPerRow = width / 6;
+	lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1;
 
 	len_div_3 = (stringLength + 3) / 3;
 	if (!(_game & GF_SIMON2) && (_game & GF_TALKIE)) {
@@ -4205,14 +4206,25 @@
 	assert(stringLength > 0);
 	while (stringLength > 0) {
 		if (stringLength > lettersPerRow) {
-			pos = lettersPerRow;
-			while (string[pos] != ' ' && pos > 0)
-				pos--;
+			int removeLastWord = 0;
+			if (lettersPerRow > lettersPerRowJustified) {
+				pos = lettersPerRowJustified;
+				while (string[pos] != ' ')
+					pos++;
+				if (pos > lettersPerRow)
+					removeLastWord = 1;
+			}
+			if (lettersPerRow <= lettersPerRowJustified || removeLastWord) {
+				pos = lettersPerRow;
+				while (string[pos] != ' ' && pos > 0)
+					pos--;
+			}
 			height += textHeight;
 			y -= textHeight;
 		} else
 			pos = stringLength;
-		padding = (lettersPerRow - pos) / 2;
+		padding = (lettersPerRow - pos) % 2 ?
+			(lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2;
 		while (padding--)
 			*convertedString2++ = ' ';
 		stringLength -= pos;





More information about the Scummvm-git-logs mailing list