[Scummvm-cvs-logs] SF.net SVN: scummvm: [26192] scummvm/trunk/engines/parallaction/dialogue. cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Mar 18 09:58:41 CET 2007


Revision: 26192
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26192&view=rev
Author:   peres001
Date:     2007-03-18 01:58:41 -0700 (Sun, 18 Mar 2007)

Log Message:
-----------
broke down huge runDialogue in more manageable chunks

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/dialogue.cpp

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2007-03-18 08:58:25 UTC (rev 26191)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2007-03-18 08:58:41 UTC (rev 26192)
@@ -219,7 +219,179 @@
 }
 
 
+uint16 askDialoguePassword(Dialogue *v60, StaticCnv *v48) {
+	debugC(1, kDebugDialogue, "checkDialoguePassword()");
 
+	char password[100];
+	uint16 passwordLen = 0;
+
+	while (true) {
+		strcpy(password, ".......");
+		_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
+
+		Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]);
+		r.moveTo(_answerBalloonX[0], _answerBalloonY[0]);
+
+		_vm->_gfx->drawBalloon(r, 1);
+
+		_vm->_gfx->displayWrappedString(
+			v60->_answers[0],
+			_answerBalloonX[0],
+			_answerBalloonY[0],
+			MAX_BALLOON_WIDTH,
+			3
+		);
+
+		_vm->_gfx->flatBlitCnv(
+			v48,
+			ANSWER_CHARACTER_X,
+			ANSWER_CHARACTER_Y,
+			Gfx::kBitFront,
+			v48->_data1
+		);
+
+		_vm->_gfx->displayBalloonString(
+			_answerBalloonX[0] + 5,
+			_answerBalloonY[0] + _answerBalloonH[0] - 15,
+			"> ",
+			0
+		);
+
+		Common::Event e;
+
+		while (e.kbd.ascii != 0xD && passwordLen < MAX_PASSWORD_LENGTH) {
+
+			// FIXME: see comment for updateInput()
+			if (!g_system->getEventManager()->pollEvent(e)) continue;
+			if (e.type != Common::EVENT_KEYDOWN) continue;
+			if (e.type != Common::EVENT_QUIT) g_system->quit();
+			if (!isdigit(e.kbd.ascii)) continue;
+
+			password[passwordLen] = e.kbd.ascii;
+			passwordLen++;
+			password[passwordLen] = '\0';
+
+			_vm->_gfx->displayBalloonString(
+				_answerBalloonX[0] + 5,
+				_answerBalloonY[0] + _answerBalloonH[0] - 15,
+				password,
+				0
+			);
+
+			g_system->delayMillis(20);
+		}
+
+		if ((!scumm_stricmp(_vm->_characterName, _doughName) && !scumm_strnicmp(password, "1732461", 7)) ||
+			(!scumm_stricmp(_vm->_characterName, _donnaName) && !scumm_strnicmp(password, "1622", 4)) ||
+			(!scumm_stricmp(_vm->_characterName, _dinoName) && !scumm_strnicmp(password, "179", 3))) {
+
+			break;
+
+		}
+
+	}
+
+	return 0;
+
+}
+
+bool _askPassword;
+
+bool displayAnswer(Dialogue *v60, uint16 _si) {
+
+	uint32 v28 = _localFlags[_vm->_currentLocationIndex];
+	if (v60->_yesFlags[_si] & kFlagsGlobal) {
+		v28 = _commandFlags | kFlagsGlobal;
+	}
+
+	// display suitable answers
+	if (((v60->_yesFlags[_si] & v28) == v60->_yesFlags[_si]) && ((v60->_noFlags[_si] & ~v28) == v60->_noFlags[_si])) {
+
+		_vm->_gfx->getStringExtent(
+			v60->_answers[_si],
+			MAX_BALLOON_WIDTH,
+			&_answerBalloonW[_si],
+			&_answerBalloonH[_si]
+		);
+
+		debugC(1, kDebugDialogue, "runDialogue: showing answer #%i '%s'",
+			_si,
+			v60->_answers[_si]
+		);
+
+		Common::Rect r(_answerBalloonW[_si], _answerBalloonH[_si]);
+		r.moveTo(_answerBalloonX[_si], _answerBalloonY[_si]);
+
+		_vm->_gfx->drawBalloon(r, 1);
+
+		_answerBalloonY[_si+1] = 10 + _answerBalloonY[_si] + _answerBalloonH[_si];
+
+		_askPassword = _vm->_gfx->displayWrappedString(
+			v60->_answers[_si],
+			_answerBalloonX[_si],
+			_answerBalloonY[_si],
+			MAX_BALLOON_WIDTH,
+			3
+		);
+
+		debugC(1, kDebugDialogue, "runDialogue: answer #%i shown at (%i, %i)+(%i, %i)",
+			_si,
+			_answerBalloonX[_si],
+			_answerBalloonY[_si],
+			_answerBalloonW[_si],
+			_answerBalloonH[_si]
+		);
+
+
+		return true;
+	}
+
+	return false;
+
+}
+
+void displayQuestion(Dialogue *v60, StaticCnv *v5C) {
+
+	int16 question_width = 0, question_height = 0;
+
+	// display Question if any
+	if (scumm_stricmp(v60->_text, "NULL")) {
+		debugC(1, kDebugDialogue, "runDialogue: showing question '%s'", v60->_text);
+
+		_vm->_gfx->flatBlitCnv(
+			v5C,
+			QUESTION_CHARACTER_X,
+			QUESTION_CHARACTER_Y,
+			Gfx::kBitFront,
+			v5C->_data1
+		);
+
+		_vm->_gfx->getStringExtent(
+			v60->_text,
+			MAX_BALLOON_WIDTH,
+			&question_width,
+			&question_height
+		);
+
+		Common::Rect r(question_width, question_height);
+		r.moveTo(QUESTION_BALLOON_X, QUESTION_BALLOON_Y);
+
+		_vm->_gfx->drawBalloon(r, v60->_mood & 0x10);
+
+		_vm->_gfx->displayWrappedString(
+			v60->_text,
+			QUESTION_BALLOON_X,
+			QUESTION_BALLOON_Y,
+			MAX_BALLOON_WIDTH,
+			0
+		);
+
+		waitUntilLeftClick();
+		_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
+	}
+
+}
+
 void runDialogue(SpeakData *data) {
 	debugC(1, kDebugDialogue, "runDialogue: starting dialogue '%s'", data->_name);
 
@@ -253,8 +425,7 @@
 	v48._height = _vm->_char._talk._height;
 
 	bool displayedAnswers = false;
-	int16 question_width = 0, question_height = 0;
-	bool askPassword = false;
+	_askPassword = false;
 	uint16 _di = 0;
 	Command *v34 = NULL;
 
@@ -266,42 +437,8 @@
 		v48._data0 = _vm->_char._talk._array[0];
 		v48._data1 = NULL; // _talk.field_8[0];
 
-		// display Question if any
-		if (scumm_stricmp(v60->_text, "NULL")) {
-			debugC(1, kDebugDialogue, "runDialogue: showing question '%s'", v60->_text);
+		displayQuestion(v60, &v5C);
 
-			_vm->_gfx->flatBlitCnv(
-				&v5C,
-				QUESTION_CHARACTER_X,
-				QUESTION_CHARACTER_Y,
-				Gfx::kBitFront,
-				v5C._data1
-			);
-
-			_vm->_gfx->getStringExtent(
-				v60->_text,
-				MAX_BALLOON_WIDTH,
-				&question_width,
-				&question_height
-			);
-
-			Common::Rect r(question_width, question_height);
-			r.moveTo(QUESTION_BALLOON_X, QUESTION_BALLOON_Y);
-
-			_vm->_gfx->drawBalloon(r, v60->_mood & 0x10);
-
-			_vm->_gfx->displayWrappedString(
-				v60->_text,
-				QUESTION_BALLOON_X,
-				QUESTION_BALLOON_Y,
-				MAX_BALLOON_WIDTH,
-				0
-			);
-
-			waitUntilLeftClick();
-			_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
-		}
-
 		if (v60->_answers[0] == NULL) break;
 
 		_answerBalloonY[0] = 10;
@@ -313,51 +450,10 @@
 			uint16 _si = 0;
 			while (_si < 5 && v60->_answers[_si]) {
 
-				uint32 v28 = _localFlags[_vm->_currentLocationIndex];
-				if (v60->_yesFlags[_si] & kFlagsGlobal) {
-					v28 = _commandFlags | kFlagsGlobal;
-				}
+				if (displayAnswer(v60, _si)) {
 
-				// display suitable answers
-				if (((v60->_yesFlags[_si] & v28) == v60->_yesFlags[_si]) && ((v60->_noFlags[_si] & ~v28) == v60->_noFlags[_si])) {
+					displayedAnswers = true;
 
-					_vm->_gfx->getStringExtent(
-						v60->_answers[_si],
-						MAX_BALLOON_WIDTH,
-						&_answerBalloonW[_si],
-						&_answerBalloonH[_si]
-					);
-
-					debugC(1, kDebugDialogue, "runDialogue: showing answer #%i '%s'",
-						_si,
-						v60->_answers[_si]
-					);
-
-					Common::Rect r(_answerBalloonW[_si], _answerBalloonH[_si]);
-					r.moveTo(_answerBalloonX[_si], _answerBalloonY[_si]);
-
-					_vm->_gfx->drawBalloon(r, 1);
-
-					_answerBalloonY[_si+1] = 10 + _answerBalloonY[_si] + _answerBalloonH[_si];
-
-					askPassword = _vm->_gfx->displayWrappedString(
-						v60->_answers[_si],
-						_answerBalloonX[_si],
-						_answerBalloonY[_si],
-						MAX_BALLOON_WIDTH,
-						3
-					);
-
-					debugC(1, kDebugDialogue, "runDialogue: answer #%i shown at (%i, %i)+(%i, %i)",
-						_si,
-						_answerBalloonX[_si],
-						_answerBalloonY[_si],
-						_answerBalloonW[_si],
-						_answerBalloonH[_si]
-					);
-
-
-					displayedAnswers = true;
 				} else {
 					debugC(1, kDebugDialogue, "runDialogue: skipping answer #%i", _si);
 
@@ -385,7 +481,7 @@
 
 				debugC(1, kDebugDialogue, "runDialogue: answering face shown");
 
-				if (askPassword == false) {
+				if (_askPassword == false) {
 
 					debugC(1, kDebugDialogue, "runDialogue: waiting for user to select answer");
 					_di = selectAnswer(v60, &v48);
@@ -393,79 +489,8 @@
 
 				} else {
 
-					char password[100];
-					uint16 passwordLen = 0;
+					_di = askDialoguePassword(v60, &v48);
 
-					debugC(1, kDebugDialogue, "runDialogue: asking password");
-
-					while (askPassword == true) {
-						strcpy(password, ".......");
-						_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
-
-						Common::Rect r(_answerBalloonW[0], _answerBalloonH[0]);
-						r.moveTo(_answerBalloonX[0], _answerBalloonY[0]);
-
-						_vm->_gfx->drawBalloon(r, 1);
-
-						_vm->_gfx->displayWrappedString(
-							v60->_answers[0],
-							_answerBalloonX[0],
-							_answerBalloonY[0],
-							MAX_BALLOON_WIDTH,
-							3
-						);
-
-						_vm->_gfx->flatBlitCnv(
-							&v48,
-							ANSWER_CHARACTER_X,
-							ANSWER_CHARACTER_Y,
-							Gfx::kBitFront,
-							v48._data1
-						);
-
-						_vm->_gfx->displayBalloonString(
-							_answerBalloonX[0] + 5,
-							_answerBalloonY[0] + _answerBalloonH[0] - 15,
-							"> ",
-							0
-						);
-
-						Common::Event e;
-
-						while (e.kbd.ascii != 0xD && passwordLen < MAX_PASSWORD_LENGTH) {
-
-							// FIXME: see comment for updateInput()
-							if (!g_system->getEventManager()->pollEvent(e)) continue;
-							if (e.type != Common::EVENT_KEYDOWN) continue;
-							if (e.type != Common::EVENT_QUIT) g_system->quit();
-							if (!isdigit(e.kbd.ascii)) continue;
-
-							password[passwordLen] = e.kbd.ascii;
-							passwordLen++;
-							password[passwordLen] = '\0';
-
-							_vm->_gfx->displayBalloonString(
-								_answerBalloonX[0] + 5,
-								_answerBalloonY[0] + _answerBalloonH[0] - 15,
-								password,
-								0
-							);
-
-							g_system->delayMillis(20);
-						}
-
-						if ((!scumm_stricmp(_vm->_characterName, _doughName) && !scumm_strnicmp(password, "1732461", 7)) ||
-							(!scumm_stricmp(_vm->_characterName, _donnaName) && !scumm_strnicmp(password, "1622", 4)) ||
-							(!scumm_stricmp(_vm->_characterName, _dinoName) && !scumm_strnicmp(password, "179", 3))) {
-
-							askPassword = false;
-
-						}
-
-						_di = 0;
-
-					}
-
 				}
 
 				_vm->_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);


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