[Scummvm-cvs-logs] SF.net SVN: scummvm:[46101] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Mon Nov 23 07:44:40 CET 2009


Revision: 46101
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46101&view=rev
Author:   spalek
Date:     2009-11-23 06:44:40 +0000 (Mon, 23 Nov 2009)

Log Message:
-----------
Fixed breaking long lines instead of using smaller font (which is sometimes not enough)

Modified Paths:
--------------
    scummvm/trunk/engines/draci/script.cpp
    scummvm/trunk/engines/draci/sprite.cpp
    scummvm/trunk/engines/draci/sprite.h

Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp	2009-11-22 23:33:58 UTC (rev 46100)
+++ scummvm/trunk/engines/draci/script.cpp	2009-11-23 06:44:40 UTC (rev 46101)
@@ -715,14 +715,8 @@
 		speechFrame->setText("");
 	}
 	speechFrame->setColour(person->_fontColour);
+	speechFrame->repeatedlySplitLongLines(kScreenWidth);
 
-	// HACK: Some strings in the English data files are too long to fit the screen
-	// This is a temporary resolution.
-	speechFrame->setFont(_vm->_bigFont);
-	if (speechFrame->getWidth() >= kScreenWidth) {
-		speechFrame->setFont(_vm->_smallFont);
-	}
-
 	// Speak the dubbing if possible
 	uint dubbingDuration = 0;
 	if (sample) {

Modified: scummvm/trunk/engines/draci/sprite.cpp
===================================================================
--- scummvm/trunk/engines/draci/sprite.cpp	2009-11-22 23:33:58 UTC (rev 46100)
+++ scummvm/trunk/engines/draci/sprite.cpp	2009-11-23 06:44:40 UTC (rev 46101)
@@ -313,5 +313,44 @@
 	_height = _font->getStringHeight(_text);
 }
 
+void Text::repeatedlySplitLongLines(uint maxWidth) {
+	while (_width > maxWidth) {
+		splitLinesLongerThan(maxWidth);
+		_width = _font->getStringWidth(_text, _spacing);
+		_height = _font->getStringHeight(_text);
+	}
+}
+
+void Text::splitLinesLongerThan(uint maxWidth) {
+	char *start = const_cast<char*> (_text.c_str());	// hacky
+	while (1) {
+		char *end = strchr(start, '|');
+		if (end) {
+			*end = 0;
+		}
+		uint lineWidth = _font->getStringWidth(start, _spacing);
+		if (lineWidth > maxWidth) {
+			int middle = end ? (end - start) / 2 : strlen(start) / 2;
+			for (int i = 0; ; ++i) {
+				if (start[middle + i] == ' ') {
+					start[middle + i] = '|';
+					break;
+				}
+				if (start[middle - i] == ' ') {
+					start[middle - i] = '|';
+					break;
+				}
+			}
+			debugC(2, kDraciGeneralDebugLevel, "Long line of width %d split into %s\n", lineWidth, start);
+		}
+		if (end) {
+			*end = '|';
+			start = end + 1;
+		} else {
+			break;
+		}
+	}
+}
+
 } // End of namespace Draci
 

Modified: scummvm/trunk/engines/draci/sprite.h
===================================================================
--- scummvm/trunk/engines/draci/sprite.h	2009-11-22 23:33:58 UTC (rev 46100)
+++ scummvm/trunk/engines/draci/sprite.h	2009-11-23 06:44:40 UTC (rev 46101)
@@ -144,6 +144,8 @@
 	void setSpacing(uint spacing) { _spacing = spacing; }
 	void setFont(const Font *font);
 
+	void repeatedlySplitLongLines(uint maxWidth);
+
 	uint getLength() const { return _length; }
 
 	void draw(Surface *surface, bool markDirty, int relX, int relY) const;
@@ -155,6 +157,8 @@
 
 	DrawableType getType() const { return kDrawableText; }
 private:
+	void splitLinesLongerThan(uint maxWidth);
+
 	Common::String _text;
 	uint _length;
 	uint8 _colour;


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