[Scummvm-cvs-logs] SF.net SVN: scummvm:[42755] scummvm/trunk/engines/drascula

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sat Jul 25 15:07:50 CEST 2009


Revision: 42755
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42755&view=rev
Author:   eriktorbjorn
Date:     2009-07-25 13:07:50 +0000 (Sat, 25 Jul 2009)

Log Message:
-----------
Added word-wrapping to Drascula's conversation options. Fixes bug #2826607.

Modified Paths:
--------------
    scummvm/trunk/engines/drascula/converse.cpp
    scummvm/trunk/engines/drascula/drascula.h
    scummvm/trunk/engines/drascula/graphics.cpp

Modified: scummvm/trunk/engines/drascula/converse.cpp
===================================================================
--- scummvm/trunk/engines/drascula/converse.cpp	2009-07-25 13:07:40 UTC (rev 42754)
+++ scummvm/trunk/engines/drascula/converse.cpp	2009-07-25 13:07:50 UTC (rev 42755)
@@ -143,6 +143,7 @@
 		game3 = kDialogOptionUnselected;
 	char phrase1[78], phrase2[78], phrase3[78], phrase4[78];
 	char sound1[13], sound2[13], sound3[13], sound4[13];
+	int phrase1_bottom, phrase2_bottom, phrase3_bottom, phrase4_bottom;
 	int answer1, answer2, answer3;
 	char buffer[256];
 
@@ -207,12 +208,12 @@
 
 		updateEvents();
 
-		print_abc_opc(phrase1, 2, game1);
-		print_abc_opc(phrase2, 10, game2);
-		print_abc_opc(phrase3, 18, game3);
-		print_abc_opc(phrase4, 26, kDialogOptionUnselected);
+		phrase1_bottom = 8 * print_abc_opc(phrase1, 2, game1);
+		phrase2_bottom = phrase1_bottom + 8 * print_abc_opc(phrase2, phrase1_bottom + 2, game2);
+		phrase3_bottom = phrase2_bottom + 8 * print_abc_opc(phrase3, phrase2_bottom + 2, game3);
+		phrase4_bottom = phrase3_bottom + 8 * print_abc_opc(phrase4, phrase3_bottom + 2, kDialogOptionUnselected);
 
-		if (mouseY > 0 && mouseY < 9) {
+		if (mouseY > 0 && mouseY < phrase1_bottom) {
 			if (game1 == kDialogOptionClicked && _color != kColorWhite)
 				color_abc(kColorWhite);
 			else if (game1 != kDialogOptionClicked && _color != kColorLightGreen)
@@ -226,13 +227,13 @@
 				talk(phrase1, sound1);
 				response(answer1);
 			}
-		} else if (mouseY > 8 && mouseY < 17) {
+		} else if (mouseY > phrase1_bottom && mouseY < phrase2_bottom) {
 			if (game2 == kDialogOptionClicked && _color != kColorWhite)
 				color_abc(kColorWhite);
 			else if (game2 != kDialogOptionClicked && _color != kColorLightGreen)
 				color_abc(kColorLightGreen);
 
-			print_abc_opc(phrase2, 10, kDialogOptionSelected);
+			print_abc_opc(phrase2, phrase1_bottom + 2, kDialogOptionSelected);
 
 			if (leftMouseButton == 1) {
 				delay(100);
@@ -240,13 +241,13 @@
 				talk(phrase2, sound2);
 				response(answer2);
 			}
-		} else if (mouseY > 16 && mouseY < 25) {
+		} else if (mouseY > phrase2_bottom && mouseY < phrase3_bottom) {
 			if (game3 == kDialogOptionClicked && _color != kColorWhite)
 				color_abc(kColorWhite);
 			else if (game3 != kDialogOptionClicked && _color != kColorLightGreen)
 				color_abc(kColorLightGreen);
 
-			print_abc_opc(phrase3, 18, kDialogOptionSelected);
+			print_abc_opc(phrase3, phrase2_bottom + 2, kDialogOptionSelected);
 
 			if (leftMouseButton == 1) {
 				delay(100);
@@ -254,8 +255,8 @@
 				talk(phrase3, sound3);
 				response(answer3);
 			}
-		} else if (mouseY > 24 && mouseY < 33) {
-			print_abc_opc(phrase4, 26, kDialogOptionSelected);
+		} else if (mouseY > phrase3_bottom && mouseY < phrase4_bottom) {
+			print_abc_opc(phrase4, phrase3_bottom + 2, kDialogOptionSelected);
 
 			if (leftMouseButton == 1) {
 				delay(100);

Modified: scummvm/trunk/engines/drascula/drascula.h
===================================================================
--- scummvm/trunk/engines/drascula/drascula.h	2009-07-25 13:07:40 UTC (rev 42754)
+++ scummvm/trunk/engines/drascula/drascula.h	2009-07-25 13:07:50 UTC (rev 42755)
@@ -564,7 +564,7 @@
 	void playTalkSequence(int sequence);
 	void doTalkSequenceCommand(TalkSequenceCommand cmd);
 	void converse(int);
-	void print_abc_opc(const char *, int, int);
+	int print_abc_opc(const char *, int, int);
 	void response(int);
 	void activatePendulum();
 

Modified: scummvm/trunk/engines/drascula/graphics.cpp
===================================================================
--- scummvm/trunk/engines/drascula/graphics.cpp	2009-07-25 13:07:40 UTC (rev 42754)
+++ scummvm/trunk/engines/drascula/graphics.cpp	2009-07-25 13:07:50 UTC (rev 42755)
@@ -235,13 +235,30 @@
 	}	// for
 }
 
-void DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) {
+int DrasculaEngine::print_abc_opc(const char *said, int screenY, int game) {
 	int signY, letterY, letterX = 0;
 	uint len = strlen(said);
 
 	int screenX = 1;
+	int lines = 1;
 
 	for (uint h = 0; h < len; h++) {
+		int wordLength;
+
+		// Look ahead to the end of the word.
+		wordLength = 0;
+		int pos = h;
+		while (said[pos] && said[pos] != ' ') {
+			wordLength++;
+			pos++;
+		}
+
+		if (screenX + wordLength * CHAR_WIDTH_OPC > 317) {
+			screenX = 0;
+			screenY += (CHAR_HEIGHT + 2);
+			lines++;
+		}
+
 		if (game == 1) {
 			letterY = 6;
 			signY = 15;
@@ -281,6 +298,8 @@
 
 		screenX = screenX + CHAR_WIDTH_OPC;
 	}
+
+	return lines;
 }
 
 bool DrasculaEngine::textFitsCentered(char *text, int x) {


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