[Scummvm-cvs-logs] CVS: scummvm/queen display.cpp,1.64,1.65

Gregory Montoir cyx at users.sourceforge.net
Fri Jun 4 10:30:04 CEST 2004


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

Modified Files:
	display.cpp 
Log Message:
handle long command strings better (see bug report 962828)

Index: display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/display.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- display.cpp	5 May 2004 18:03:41 -0000	1.64
+++ display.cpp	4 Jun 2004 17:29:26 -0000	1.65
@@ -828,8 +828,18 @@
 }
 
 void Display::setTextCentered(uint16 y, const char *text, bool outlined) {
-	uint16 x = (GAME_SCREEN_WIDTH - textWidth(text)) / 2;
-	setText(x, y, text, outlined);
+	int len = strlen(text);
+	int16 x;
+	while ((x = (GAME_SCREEN_WIDTH - textWidth(text, len)) / 2) <= 0) {
+		++text;
+		len -= 2;
+	}
+	assert(y < GAME_SCREEN_HEIGHT);
+	TextSlot *pts = &_texts[y];
+	pts->x = x;
+	pts->color = _curTextColor;
+	pts->outlined = outlined;
+	pts->text = Common::String(text, len);	
 }
 
 void Display::drawTexts() {





More information about the Scummvm-git-logs mailing list