[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.185,1.186 animation.cpp,1.62,1.63 font.cpp,1.35,1.36 font.h,1.17,1.18 sfuncs.cpp,1.161,1.162

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Tue Sep 27 23:34:20 CEST 2005


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

Modified Files:
	actor.cpp animation.cpp font.cpp font.h sfuncs.cpp 
Log Message:
Some more IHNM-related stuff:

* Use the script-specified text area for subtitles, if there is one.

* Fixed a word-wrapping bug that would happen if a new line began with a
  space. I don't know about ITE, but IHNM puts two spaces after periods. Of
  course, the case where I saw this happen will probably go away once we
  start using the right font, but it could still happen elsewhere.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- actor.cpp	8 Sep 2005 18:01:39 -0000	1.185
+++ actor.cpp	28 Sep 2005 06:33:13 -0000	1.186
@@ -1017,34 +1017,41 @@
 	}
 
 	if (_activeSpeech.actorsCount == 1) {
-		width = _activeSpeech.speechBox.width();
-		height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1;
-
-		if (height > 40 && width < _vm->getDisplayWidth() - 100) {
-			width = _vm->getDisplayWidth() - 100;
+		if (_speechBoxScript.width() > 0) {
+			_activeSpeech.drawRect.left = _speechBoxScript.left;
+			_activeSpeech.drawRect.right = _speechBoxScript.right;
+			_activeSpeech.drawRect.top = _speechBoxScript.top;
+			_activeSpeech.drawRect.bottom = _speechBoxScript.bottom;
+		} else {
+			width = _activeSpeech.speechBox.width();
 			height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1;
-		}
 
-		_activeSpeech.speechBox.setWidth(width);
+			if (height > 40 && width < _vm->getDisplayWidth() - 100) {
+				width = _vm->getDisplayWidth() - 100;
+				height = _vm->_font->getHeight(kMediumFont, _activeSpeech.strings[0], width - 2, _activeSpeech.getFontFlags(0)) + 1;
+			}
 
-		if (_activeSpeech.actorIds[0] != 0) {
-			actor = getActor(_activeSpeech.actorIds[0]);
-			_activeSpeech.speechBox.setHeight(height);
+			_activeSpeech.speechBox.setWidth(width);
 
-			if (_activeSpeech.speechBox.right > _vm->getDisplayWidth() - 10) {
-				_activeSpeech.drawRect.left = _vm->getDisplayWidth() - 10 - width;
+			if (_activeSpeech.actorIds[0] != 0) {
+				actor = getActor(_activeSpeech.actorIds[0]);
+				_activeSpeech.speechBox.setHeight(height);
+
+				if (_activeSpeech.speechBox.right > _vm->getDisplayWidth() - 10) {
+					_activeSpeech.drawRect.left = _vm->getDisplayWidth() - 10 - width;
+				} else {
+					_activeSpeech.drawRect.left = _activeSpeech.speechBox.left;
+				}
+
+				height2 =  actor->_screenPosition.y - 50;
+				_activeSpeech.speechBox.top = _activeSpeech.drawRect.top = MAX(10, (height2 - height) / 2);
 			} else {
 				_activeSpeech.drawRect.left = _activeSpeech.speechBox.left;
+				_activeSpeech.drawRect.top = _activeSpeech.speechBox.top + (_activeSpeech.speechBox.height() - height) / 2;
 			}
-
-			height2 =  actor->_screenPosition.y - 50;
-			_activeSpeech.speechBox.top = _activeSpeech.drawRect.top = MAX(10, (height2 - height) / 2);
-		} else {
-			_activeSpeech.drawRect.left = _activeSpeech.speechBox.left;
-			_activeSpeech.drawRect.top = _activeSpeech.speechBox.top + (_activeSpeech.speechBox.height() - height) / 2;
+			_activeSpeech.drawRect.setWidth(width);
+			_activeSpeech.drawRect.setHeight(height);
 		}
-		_activeSpeech.drawRect.setWidth(width);
-		_activeSpeech.drawRect.setHeight(height);
 	}
 
 	_activeSpeech.playing = true;

Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- animation.cpp	27 Sep 2005 17:38:35 -0000	1.62
+++ animation.cpp	28 Sep 2005 06:33:13 -0000	1.63
@@ -119,6 +119,8 @@
 	free(buf);
 	free(resourceData);
 
+	// Play the animation
+
 	int cutawaySlot = -1;
 
 	for (int i = 0; i < ARRAYSIZE(_cutawayAnimations); i++) {

Index: font.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/font.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- font.cpp	8 Sep 2005 18:01:39 -0000	1.35
+++ font.cpp	28 Sep 2005 06:33:13 -0000	1.36
@@ -62,6 +62,10 @@
 	}
 }
 
+FontData *Font::getFont(FontId fontId) {
+	return _fonts[fontId];
+}
+
 void Font::loadFont(uint32 fontResourceId) {
 	FontData *font;
 	byte *fontResourcePointer;
@@ -70,7 +74,6 @@
 	int c;
 	ResourceContext *fontContext;
 
-
 	debug(1, "Font::loadFont(): Reading fontResourceId %d...", fontResourceId);
 
 	fontContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
@@ -134,7 +137,6 @@
 	_fonts[_loadedFonts++] = font;
 }
 
-
 void Font::createOutline(FontData *font) {
 	int i;
 	int row;
@@ -249,7 +251,7 @@
 
 	validate(fontId);
 
-	font = _fonts[fontId];
+	font = getFont(fontId);
 
 	txt = (const byte *) text;
 
@@ -273,7 +275,7 @@
 
 	validate(fontId);
 
-	font = _fonts[fontId];
+	font = getFont(fontId);
 
 	return font->normal.header.charHeight;
 }
@@ -285,7 +287,7 @@
 
 	validate(fontId);
 
-	font = _fonts[fontId];
+	font = getFont(fontId);
 
 	if (flags & kFontOutline) {
 		offsetPoint.x--;
@@ -554,7 +556,7 @@
 	textPoint.y = rect.top;
 
 	if (fitWidth >= textWidth) {
-	// Entire string fits, draw it
+		// Entire string fits, draw it
 		textPoint.x -= (textWidth / 2);
 		draw(fontId, ds, text, textLength, textPoint, color, effectColor, flags);
 		return;
@@ -604,6 +606,19 @@
 				searchPointer = measurePointer + 1;
 			}
 			wc = 0;
+
+			// Advance the search pointer to the next non-space.
+			// Otherwise, the first "word" to be measured will be
+			// an empty string. Measuring or drawing a string of
+			// length 0 is interpreted as measure/draw the entire
+			// buffer, which certainly is not what we want here.
+			//
+			// This happes because a string may contain several
+			// spaces in a row, e.g. after a period.
+
+			while (*searchPointer == ' ')
+				searchPointer++;
+
 			measurePointer = searchPointer;
 			startPointer = searchPointer;
 		} else {

Index: font.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/font.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- font.h	7 Aug 2005 14:54:11 -0000	1.17
+++ font.h	28 Sep 2005 06:33:13 -0000	1.18
@@ -76,7 +76,6 @@
 	}
 };
 
-
 struct FontHeader {
 	int charHeight;
 	int charWidth;
@@ -106,6 +105,7 @@
  public:
 	Font(SagaEngine *vm);
 	~Font(void);
+	FontData *getFont(FontId fontId);
 	int getStringWidth(FontId fontId, const char *text, size_t count, FontEffectFlags flags);
 	int getHeight(FontId fontId);
 	int getHeight(FontId fontId, const char *text, int width, FontEffectFlags flags);
@@ -124,7 +124,6 @@
 	}
 
  private:
-
 	void loadFont(uint32 fontResourceId);
 	void createOutline(FontData *font);
 	void draw(FontId fontId, Surface *ds, const char *text, size_t count, const Common::Point &point, int color, int effectColor, FontEffectFlags flags);
@@ -139,7 +138,6 @@
 		return byteLength;
 	}
 
-
 	static const int _charMap[256];
 	SagaEngine *_vm;
 

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- sfuncs.cpp	26 Sep 2005 07:22:32 -0000	1.161
+++ sfuncs.cpp	28 Sep 2005 06:33:13 -0000	1.162
@@ -1970,8 +1970,6 @@
 	_vm->_actor->_speechBoxScript.top = param2;
 	_vm->_actor->_speechBoxScript.setWidth(param3);
 	_vm->_actor->_speechBoxScript.setHeight(param4);
-
-	debug(0, "STUB: sfSetSpeechBox(%d, %d, %d, %d)", param1, param2, param3, param4);
 }
 
 void Script::sfDebugShowData(SCRIPTFUNC_PARAMS) {





More information about the Scummvm-git-logs mailing list