[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.87,1.88 actor.h,1.45,1.46

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Wed Jan 12 23:48:00 CET 2005


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

Modified Files:
	actor.cpp actor.h 
Log Message:
A few subtitle-related changes:

* Added speechCoords to the SpeechData structure so that talking actors
  don't drag their speech subtitles with them just because they're moving
  and talking at the same time. (Could this also be useful for non-actor
  speech?) If the actor has multiple strings, the coordinates are updated
  for each new string.

* Made speechColor and outlineCoor arrays so that simultaneous speech (i.e.
  where several actors are talking at the same time) multi-coloured. This
  is completely untested, though.

* Used getBlack() to get the black colour for the text outline. The
  original uses a constant, but we could always make getBlack() return
  that constant, if we want to.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- actor.cpp	11 Jan 2005 21:10:19 -0000	1.87
+++ actor.cpp	13 Jan 2005 07:47:04 -0000	1.88
@@ -609,6 +609,15 @@
 			_activeSpeech.strings[i - 1] = _activeSpeech.strings[i];
 		}
 		_activeSpeech.stringsCount--;
+		if (_activeSpeech.stringsCount > 0 && _activeSpeech.actorIds[0] != 0) {
+			// Update actor speech position for the next string.
+			// Note that we only need to do this for the first
+			// actor since simultaneous speech is never more than
+			// one string at a time.
+			actor = getActor(_activeSpeech.actorIds[0]);
+			_activeSpeech.speechCoords[0] = actor->screenPosition;
+			_activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
+		}
 	}
 
 	if (!isSpeaking())
@@ -966,8 +975,7 @@
 // draw speeches
 	if (isSpeaking() && !_vm->_script->_skipSpeeches) {
 		int i;
-		int textDrawFlags, speechColor;
-		Point speechCoord;
+		int textDrawFlags;
 		char oneChar[2];
 		oneChar[1] = 0;
 		const char *outputString;
@@ -987,16 +995,7 @@
 		if (_activeSpeech.actorIds[0] != 0) {
 			
 			for (i = 0; i < _activeSpeech.actorsCount; i++){
-				actor = getActor(_activeSpeech.actorIds[i]);
-				speechCoord.x = actor->screenPosition.x;
-				speechCoord.y = actor->screenPosition.y;
-				speechCoord.y -= ACTOR_DIALOGUE_HEIGHT;
-				if (_activeSpeech.actorsCount > 1)
-					speechColor = actor->speechColor;
-				else
-					speechColor = _activeSpeech.speechColor;
-
-				_vm->textDraw(MEDIUM_FONT_ID, back_buf, outputString, speechCoord.x, speechCoord.y, speechColor, _activeSpeech.outlineColor, textDrawFlags);
+				_vm->textDraw(MEDIUM_FONT_ID, back_buf, outputString, _activeSpeech.speechCoords[i].x, _activeSpeech.speechCoords[i].y, _activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], textDrawFlags);
 			}
 
 		} else { // non actors speech
@@ -1315,15 +1314,17 @@
 	int i;
 
 	actor = getActor(actorId);
-	for (i = 0; i < stringsCount; i++) {		
+	for (i = 0; i < stringsCount; i++) {
 		_activeSpeech.strings[i] = strings[i];
 	}
 	_activeSpeech.stringsCount = stringsCount;
 	_activeSpeech.speechFlags = speechFlags;
 	_activeSpeech.actorsCount = 1;
 	_activeSpeech.actorIds[0] = actorId;
-	_activeSpeech.speechColor = actor->speechColor;
-	_activeSpeech.outlineColor = 15; // fixme - BLACK
+	_activeSpeech.speechCoords[0] = actor->screenPosition;
+	_activeSpeech.speechCoords[0].y -= ACTOR_DIALOGUE_HEIGHT;
+	_activeSpeech.speechColor[0] = actor->speechColor;
+	_activeSpeech.outlineColor[0] = _vm->_gfx->getBlack();
 	_activeSpeech.sampleResourceId = sampleResourceId;
 	_activeSpeech.playing = false;
 	_activeSpeech.slowModeCharIndex = 0;
@@ -1341,8 +1342,10 @@
 	_activeSpeech.speechFlags = speechFlags;
 	_activeSpeech.actorsCount = 1;
 	_activeSpeech.actorIds[0] = 0;
-	//_activeSpeech.speechColor = ;
-	//_activeSpeech.outlineColor = ; 
+	//_activeSpeech.speechColor[0] = ;
+	//_activeSpeech.outlineColor[0] = ;
+	//_activeSpeech.speechCoords[0].x = ;
+	//_activeSpeech.speechCoords[0].y = ;
 	_activeSpeech.sampleResourceId = -1;
 	_activeSpeech.playing = false;
 	_activeSpeech.slowModeCharIndex = 0;
@@ -1351,15 +1354,20 @@
 void Actor::simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount, int speechFlags) {
 	int i;
 	
-	for (i = 0; i < actorIdsCount; i++) {		
+	for (i = 0; i < actorIdsCount; i++) {
+		ActorData *actor;
+
+		actor = getActor(actorIds[i]);
 		_activeSpeech.actorIds[i] = actorIds[i];
+		_activeSpeech.speechCoords[i] = actor->screenPosition;
+		_activeSpeech.speechCoords[i].y -= ACTOR_DIALOGUE_HEIGHT;
+		_activeSpeech.speechColor[i] = actor->speechColor;
+		_activeSpeech.outlineColor[i] = 0; // disable outline
 	}
 	_activeSpeech.actorsCount = actorIdsCount;
 	_activeSpeech.strings[0] = string;
 	_activeSpeech.stringsCount = 1;
 	_activeSpeech.speechFlags = speechFlags;
-	//_activeSpeech.speechColor = ; // get's from every actor 
-	_activeSpeech.outlineColor = 0; // disable outline 
 	_activeSpeech.sampleResourceId = -1;
 	_activeSpeech.playing = false;
 	_activeSpeech.slowModeCharIndex = 0;

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- actor.h	9 Jan 2005 15:07:48 -0000	1.45
+++ actor.h	13 Jan 2005 07:47:04 -0000	1.46
@@ -243,10 +243,11 @@
 typedef SortedList<ActorDataPointer> ActorOrderList;
 
 struct SpeechData {
-	int speechColor;
-	int outlineColor;
+	int speechColor[ACTOR_SPEECH_ACTORS_MAX];
+	int outlineColor[ACTOR_SPEECH_ACTORS_MAX];
 	int speechFlags;
 	const char *strings[ACTOR_SPEECH_STRING_MAX];
+	Point speechCoords[ACTOR_SPEECH_ACTORS_MAX];
 	int stringsCount;
 	int slowModeCharIndex;
 	uint16 actorIds[ACTOR_SPEECH_ACTORS_MAX];
@@ -294,8 +295,8 @@
 	void nonActorSpeech(const char **strings, int stringsCount, int speechFlags);
 	void simulSpeech(const char *string, uint16 *actorIds, int actorIdsCount, int speechFlags);
 	void setSpeechColor(int speechColor, int outlineColor) {
-		_activeSpeech.speechColor = speechColor;
-		_activeSpeech.outlineColor = outlineColor;
+		_activeSpeech.speechColor[0] = speechColor;
+		_activeSpeech.outlineColor[0] = outlineColor;
 	}
 	void abortAllSpeeches();
 	void abortSpeech();





More information about the Scummvm-git-logs mailing list