[Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.10,1.11 talk.cpp,1.3,1.4 talk.h,1.2,1.3

David Eriksson twogood at users.sourceforge.net
Tue Oct 7 05:21:07 CEST 2003


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

Modified Files:
	cutaway.cpp talk.cpp talk.h 
Log Message:
Improved Queen::Talk class


Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cutaway.cpp	7 Oct 2003 03:58:44 -0000	1.10
+++ cutaway.cpp	7 Oct 2003 12:20:31 -0000	1.11
@@ -1014,7 +1014,7 @@
 		warning("Cutaway::talk() used but not fully implemented");
 		nextFilename[0] = '\0';
 
-		Talk::run(_talkFile, nextFilename, _logic, _resource);
+		Talk::run(_talkFile, nextFilename, _graphics, _logic, _resource);
 	}
 }
 

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- talk.cpp	7 Oct 2003 09:34:19 -0000	1.3
+++ talk.cpp	7 Oct 2003 12:20:31 -0000	1.4
@@ -35,17 +35,19 @@
 void Talk::run(
 		const char *filename, 
 		char *cutawayFilename,
+		Graphics *graphics,
 		Logic *logic,
 		Resource *resource) {
-	Talk *talk = new Talk(logic, resource);
+	Talk *talk = new Talk(graphics, logic, resource);
 	talk->talk(filename, cutawayFilename);
 	delete talk;
 }
 
 Talk::Talk(
+		Graphics *graphics,
 		Logic *logic,
 		Resource *resource) 
-: _logic(logic), _resource(resource), _fileData(NULL), _quit(false) {
+: _graphics(graphics), _logic(logic), _resource(resource), _fileData(NULL), _quit(false) {
 
 	//! TODO Move this to the Logic class later!
 	memset(_talkSelected, 0, sizeof(_talkSelected));
@@ -102,7 +104,7 @@
 
 	// TODO: split this loop in several functions
 	while(retval != -1) {
-		debug(0, "retval = %i", retval);
+		// debug(0, "retval = %i", retval);
 		
 		char otherVoiceFilePrefix    [MAX_STRING_SIZE];
 		char joeVoiceFilePrefix   [5][MAX_STRING_SIZE];
@@ -151,7 +153,7 @@
 			}
 		}
 
-		debug(0, "choicesLeft = %i", choicesLeft);
+		// debug(0, "choicesLeft = %i", choicesLeft);
 
 		if (1 == choicesLeft) {
 			// Automatically run the final dialogue option
@@ -429,21 +431,155 @@
 	return _talkSelected + _uniqueKey;
 }
 
+int Talk::splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]) {
+
+	//debug(0, "splitOption(\"%s\")", str);
+
+	// Check to see if option fits on one line, and exit early
+
+	/* XXX if (_logic->language() == ENGLISH || textWidth(str) <= MAX_TEXT_WIDTH)*/ {
+		strcpy(optionText[0], str);
+		return 1;
+	}
+
+	abort();
+
+	// Split up multiple line option at closest space character
+	// int optionLines = 0;
+}
+
+static char *removeStar(char *str) {
+	
+	// The remove_star function in talk.c uses a static variable, but this
+	// modifies the string instead, so the caller should use a copy of the
+	// string.
+
+	char *p = strchr(str, '*');
+	if (p)
+		*p = '\0';
+
+	return str;
+}
+
+static void text(int x, int y, const char *str) {
+	
+	// This function is just for debugging, the caller should really use some
+	// method in Queen::Graphics.
+	
+	debug(0, "Write '%s' at (%i,%i)", str, x, y);
+}
+
 int16 Talk::selectSentence() {
+	// Function TALK_BOB (lines 577-739) in talk.c
 	int selectedSentence = 0;
 
-	debug(0, "----- Select a sentence of these -----");
+	int scrollX = 0; 	// XXX: global variable
+	int startOption = 1;
+	int optionLines = 0;
+	char optionText[5][MAX_STRING_SIZE];
+
+	// These bobs are up and down arrows
+
+	BobSlot *bob1 = _graphics->bob(SENTENCE_BOB_1);
+	BobSlot *bob2 = _graphics->bob(SENTENCE_BOB_2);
+
+	bob1->x         = 303 + 8 + scrollX;
+	bob1->y         = 150 + 1;
+	bob1->frameNum  = 3;
+	bob1->box.y2    = 199;
+	bob1->active    = false;
+
+	bob2->x         = 303 + scrollX;
+	bob2->y         = 175;
+	bob2->frameNum  = 4;
+	bob2->box.y2    = 199;
+	bob2->active    = false;
+
+	bool rezone = true;
+
+	while (rezone) {
+		rezone = false;
+
+		// Set zones for UP/DOWN text arrows when not English version
+		// XXX ClearZones(1);
+
+		if (_logic->language() != ENGLISH) {
+			// XXX SetZone(1,5,MAXTEXTLEN+1, 0,319,24);
+			// XXX SetZone(1,6,MAXTEXTLEN+1,25,319,49);
+		}
+
+		// blanktexts(151,199);
+
+		int sentenceCount = 0;
+		int yOffset = 1;
+
+		for (int i = startOption; i <= 4; i++) {
+			// XXX TALK_ZONE[I] = 0;
+			if (_talkString[i][0] != '\0') {
+				sentenceCount++;
+				
+				char temp[MAX_STRING_SIZE];
+				strcpy(temp, _talkString[i]);
+				optionLines = splitOption(removeStar(temp), optionText);
+
+				if (yOffset < 5)
+					/* XXX SetZone(
+							1, 
+							I, 
+							0, 
+							(yofs * 10) - PUSHUP, 
+							(VersionStr[1] =='E') ? 319 : MAX_TEXT_WIDTH,
+							10 * optionLines + (yOffset * 10) - PUSHUP) */;
+
+				for (int j = 0; j < optionLines; j++) {
+					if (yOffset < 5)
+						text((j == 0) ? 0 : 24, 150 - PUSHUP + yOffset * 10, optionText[j]);
+					yOffset++;
+				}
+				
+			// XXX TALK_ZONE[i] = sentenceCount;
+			}
+		}
 
+		yOffset--;
+
+		// Up and down dialogue arrows
+
+		if (_logic->language() != ENGLISH) {
+			bob1->active = (startOption > 1);
+			bob2->active = (yOffset > 4);
+		}
+
+		// XXX KEYVERB=0;
+		if (sentenceCount > 0) {
+			// XXX CH=0, S=0, OLDS=0;
+      // XXX while(CH==0) 
+
+			if (_quit)
+				break;
+
+			// XXX update();
+
+			// XXX manage input 
+		}
+	}
+
+
+	// XXX Begin debug stuff
+	// debug(0, "----- Select a sentence of these -----");
 	for (int i = 1; i <= 4; i++) {
 		if (_talkString[i][0] != '\0') {
-			debug(0, "%i: %s", i, _talkString[i]);
-			if (!selectedSentence)		// XXX debug
-				selectedSentence = i;		// XXX debug
+			// XXX debug(0, "%i: %s", i, _talkString[i]);
+			if (!selectedSentence)
+				selectedSentence = i;
 		}
 	}
-				
+	// XXX End debug stuff
+
+	bob1->active = false;
+	bob2->active = false;
+
 	debug(0, "Selected sentence %i", selectedSentence);
-	
 	return selectedSentence;
 }
 

Index: talk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- talk.h	7 Oct 2003 06:56:29 -0000	1.2
+++ talk.h	7 Oct 2003 12:20:31 -0000	1.3
@@ -26,8 +26,9 @@
 
 namespace Queen {
 
-class Resource;
+class Graphics;
 class Logic;
+class Resource;
 
 class Talk {
 	public:
@@ -36,6 +37,7 @@
 		static void run(
 				const char *filename,
 				char *cutawayFilename,
+				Graphics *graphics,
 				Logic *logic,
 				Resource *resource);
 
@@ -57,7 +59,11 @@
 		enum {
 			MAX_STRING_LENGTH = 255,
 			MAX_STRING_SIZE = (MAX_STRING_LENGTH + 1),
-			TALK_SELECTED_COUNT = 86
+			MAX_TEXT_WIDTH = (320-18),
+			PUSHUP = 4,
+			TALK_SELECTED_COUNT = 86,
+			SENTENCE_BOB_1 = 62,
+			SENTENCE_BOB_2 = 63
 		};
 
 		//! TODO Move this to struct.h later!
@@ -73,8 +79,9 @@
 			int16 gameStateValue;
 		};
 
-		Logic *_logic;
-		Resource *_resource;
+		Graphics  *_graphics;
+		Logic     *_logic;
+		Resource  *_resource;
 		
 		//! Raw .dog file data (without 20 byte header)
 		byte *_fileData;
@@ -117,7 +124,7 @@
 
 		char _talkString[5][MAX_STRING_SIZE];
 
-		Talk(Logic *logic, Resource *resource);
+		Talk(Graphics *graphics, Logic *logic, Resource *resource);
 		~Talk();
 
 		//! Perform talk in file and return a cutaway filename
@@ -143,6 +150,9 @@
 
 		//! Select what to say
 		int16 selectSentence();
+
+		static int splitOption(const char *str, char optionText[5][MAX_STRING_SIZE]);
+
 
 };
 





More information about the Scummvm-git-logs mailing list