[Scummvm-cvs-logs] CVS: scummvm/queen talk.cpp,1.15,1.16 talk.h,1.10,1.11 graphics.cpp,1.25,1.26 graphics.h,1.22,1.23 xref.txt,1.11,1.12

David Eriksson twogood at users.sourceforge.net
Sat Oct 18 05:20:07 CEST 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv1457

Modified Files:
	talk.cpp talk.h graphics.cpp graphics.h xref.txt 
Log Message:
Moved function from Talk to Graphics because Cutaway need it too.


Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- talk.cpp	17 Oct 2003 16:50:35 -0000	1.15
+++ talk.cpp	18 Oct 2003 12:18:43 -0000	1.16
@@ -704,7 +704,7 @@
 	int startFrame = 0;
 
 	if (_talkHead && isJoe) {
-		makeSpeakBob(segment, bob, textX, textY, color, (_talkHead == 1));
+		_graphics->bobSetText(bob, segment, textX, textY, color, (_talkHead == 1));
 	}
 	else {
 		if (SPEAK_UNKNOWN_6 == command)
@@ -758,7 +758,7 @@
 			warning("Talking heads not yet handled");
 		}
 
-		makeSpeakBob(segment, bob, textX, textY, color, (_talkHead == 1));
+		_graphics->bobSetText(bob, segment, textX, textY, color, (_talkHead == 1));
 
 		if (parameters->animation[0] != '\0') {
 			// talk.c lines 1639-1690
@@ -1175,122 +1175,6 @@
 	_graphics->textClear(151,151);
 
 	return selectedSentence;
-}
-	
-void Talk::makeSpeakBob(
-		const char *text, 
-		BobSlot *bob, 
-		int textX, int textY, 
-		int color, int flags) {
-	// function MAKE_SPEAK_BOB, lines 335-457 in talk.c
-
-	if (text[0] == '\0')
-		return;
-
-	// debug(0, "makeSpeakBob('%s', (%i,%i), %i, %i, %i, %i);", 
-	//		text, bob->x, bob->y, textX, textY, color, flags);
-
-	// Duplicate string and append zero if needed
-
-	char textCopy[MAX_STRING_SIZE];
-
-	int length = strlen(text);
-	memcpy(textCopy, text, length);
-
-	if (textCopy[length - 1] >= 'A')
-		textCopy[length++] = '.';
-
-	textCopy[length] = '\0';
-
-	// Split text into lines
-	
-	char lines[8][MAX_STRING_SIZE];
-	int line_count = 0;
-	int word_count = 0;
-	int line_length = 0;
-	int i;
-
-	for (i = 0; i < length; i++) {
-		if (textCopy[i] == ' ')
-			word_count++;
-
-		line_length++;
-
-		if ((line_length > 20 && textCopy[i] == ' ') || i == (length-1)) {
-			memcpy(lines[line_count], textCopy + i + 1 - line_length, line_length);
-			lines[line_count][line_length] = '\0';
-			line_count++;
-			line_length = 0;
-		}
-	}
-
-
-	// Plan: write each line to Screen 2, put black outline around lines and
-	// pick them up as a BOB.
-	
-
-	// Find width of widest line 
-	
-	int max_line_width = 0;
-
-	for (i = 0; i < line_count; i++) {
-		int width = _graphics->textWidth(lines[i]);
-		if (max_line_width < width)
-			max_line_width = width;
-	}
-
-	// Calc text position
-
-	short x, y, width, height;
-
-	if (flags) {
-		if (flags == 2)
-			x = 160 - max_line_width / 2;
-		else
-			x = textX;
-
-		y = textY;
-
-		width = 0;
-	}
-	else {
-		x = bob->x;
-		y = bob->y;
-
-		BobFrame *frame = _graphics->frame(bob->frameNum);
-
-		width  = (frame->width  * bob->scale) / 100;
-		height = (frame->height * bob->scale) / 100;
-
-		y = y - height - 16 - line_count * 9;
-	}
-
-	// XXX x -= scrollx;
-
-	if (y < 0) {
-		y = 0;
-
-		if (x < 160)
-			x += width / 2;
-		else
-			x -= width / 2 + max_line_width;
-	}
-	else if (!flags)
-		x -= max_line_width / 2;
-
-	if (x < 0)
-		x = 4;
-	else if ((x + max_line_width) > 320)
-		x = 320 - max_line_width - 4;
-
-	_graphics->textCurrentColor(color);
-
-	for (i = 0; i < line_count; i++) {
-		int lineX = x + (max_line_width - _graphics->textWidth(lines[i])) / 2;
-
-		//debug(0, "Setting text '%s' at (%i, %i)", lines[i], lineX, y + 9 * i);
-		_graphics->textSet(lineX, y + 9 * i, lines[i]);
-	}
 }
 	
 const Talk::SpeechParameters Talk::_speechParameters[] = {

Index: talk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- talk.h	16 Oct 2003 17:02:32 -0000	1.10
+++ talk.h	18 Oct 2003 12:18:43 -0000	1.11
@@ -202,12 +202,6 @@
 			int state, 
 			int faceDirection); // FIND_SACTION
 
-	void makeSpeakBob(
-			const char *text, 
-			BobSlot *bob, 
-			int textX, int textY, 
-			int color, int flags); // MAKE_SPEAK_BOB
-
 	static int splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]);
 
 

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- graphics.cpp	18 Oct 2003 08:12:14 -0000	1.25
+++ graphics.cpp	18 Oct 2003 12:18:43 -0000	1.26
@@ -794,6 +794,120 @@
 	_display->update(_bobs[0].active, _bobs[0].x, _bobs[0].y);
 }
 
+void Graphics::bobSetText(
+		BobSlot *pbs, 
+		const char *text, 
+		int textX, int textY, 
+		int color, int flags) {
+	// function MAKE_SPEAK_BOB, lines 335-457 in talk.c
+
+	if (text[0] == '\0')
+		return;
+
+	// debug(0, "makeSpeakBob('%s', (%i,%i), %i, %i, %i, %i);", 
+	//		text, bob->x, bob->y, textX, textY, color, flags);
+
+	// Duplicate string and append zero if needed
+
+	char textCopy[MAX_STRING_SIZE];
+
+	int length = strlen(text);
+	memcpy(textCopy, text, length);
+
+	if (textCopy[length - 1] >= 'A')
+		textCopy[length++] = '.';
+
+	textCopy[length] = '\0';
+
+	// Split text into lines
+
+	char lines[8][MAX_STRING_SIZE];
+	int lineCount = 0;
+	int wordCount = 0;
+	int lineLength = 0;
+	int i;
+
+	for (i = 0; i < length; i++) {
+		if (textCopy[i] == ' ')
+			wordCount++;
+
+		lineLength++;
+
+		if ((lineLength > 20 && textCopy[i] == ' ') || i == (length-1)) {
+			memcpy(lines[lineCount], textCopy + i + 1 - lineLength, lineLength);
+			lines[lineCount][lineLength] = '\0';
+			lineCount++;
+			lineLength = 0;
+		}
+	}
+
+
+	// Plan: write each line to Screen 2, put black outline around lines and
+	// pick them up as a BOB.
+
+
+	// Find width of widest line 
+
+	int maxLineWidth = 0;
+
+	for (i = 0; i < lineCount; i++) {
+		int width = textWidth(lines[i]);
+		if (maxLineWidth < width)
+			maxLineWidth = width;
+	}
+
+	// Calc text position
+
+	short x, y, width, height;
 
+	if (flags) {
+		if (flags == 2)
+			x = 160 - maxLineWidth / 2;
+		else
+			x = textX;
+
+		y = textY;
+
+		width = 0;
+	}
+	else {
+		x = pbs->x;
+		y = pbs->y;
+
+		BobFrame *pbf = frame(pbs->frameNum);
+
+		width  = (pbf->width  * pbs->scale) / 100;
+		height = (pbf->height * pbs->scale) / 100;
+
+		y = y - height - 16 - lineCount * 9;
+	}
+
+	// XXX x -= scrollx;
+
+	if (y < 0) {
+		y = 0;
+
+		if (x < 160)
+			x += width / 2;
+		else
+			x -= width / 2 + maxLineWidth;
+	}
+	else if (!flags)
+		x -= maxLineWidth / 2;
+
+	if (x < 0)
+		x = 4;
+	else if ((x + maxLineWidth) > 320)
+		x = 320 - maxLineWidth - 4;
+
+	textCurrentColor(color);
+
+	for (i = 0; i < lineCount; i++) {
+		int lineX = x + (maxLineWidth - textWidth(lines[i])) / 2;
+
+		//debug(0, "Setting text '%s' at (%i, %i)", lines[i], lineX, y + 9 * i);
+		textSet(lineX, y + 9 * i, lines[i]);
+	}
+}
 } // End of namespace Queen
 

Index: graphics.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- graphics.h	18 Oct 2003 08:12:13 -0000	1.22
+++ graphics.h	18 Oct 2003 12:18:43 -0000	1.23
@@ -137,6 +137,12 @@
 	BobSlot *bob(int index);
 	void bobCustomParallax(uint16 roomNum);
 
+	void bobSetText(
+		BobSlot *bob, 
+		const char *text, 
+		int textX, int textY, 
+		int color, int flags);	// MAKE_SPEAK_BOB
+
 	void textCurrentColor(uint8 color); // ink()
 	void textSet(uint16 x, uint16 y, const char *text, bool outlined = true); // text()
 	void textSetCentered(uint16 y, const char *text, bool outlined = true);
@@ -163,9 +169,11 @@
 private:
 
 	enum {
+		MAX_STRING_LENGTH = 255,
+		MAX_STRING_SIZE = (MAX_STRING_LENGTH + 1),
 		BOB_SHRINK_BUF_SIZE = 60000
 	};
-	
+
 	struct PackedBank {
 		uint32 indexes[MAX_BANK_SIZE];
 		uint8 *data;

Index: xref.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/xref.txt,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- xref.txt	18 Oct 2003 11:46:52 -0000	1.11
+++ xref.txt	18 Oct 2003 12:18:43 -0000	1.12
@@ -85,6 +85,7 @@
 loadbackdrop()				Graphics::loadBackdrop
 loadfont()					*not needed*
 loadpanel()					Graphics::loadPanel
+MAKE_SPEAK_BOB				Graphics::bobSetText
 makeanim()					Graphics::bobAnimNormal
 movebob()					Graphics::bobMove
 pastebob()					Graphics::bobPaste
@@ -295,7 +296,6 @@
 TALK
 ====
 FIND_SACTION()				Talk::findSpeechParameters
-MAKE_SPEAK_BOB				Talk::makeSpeakBob
 MOVE_SPEAK
 SPEAK						Talk::speak
 SPEAK_SUB					Talk::speakSegment





More information about the Scummvm-git-logs mailing list