[Scummvm-git-logs] scummvm master -> 28a5a747b3042da71e764f6a21b4d9007ec6dc78

dreammaster dreammaster at scummvm.org
Mon Aug 29 06:07:47 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
28a5a747b3 TITANIC: Finished CCreditText draw method


Commit: 28a5a747b3042da71e764f6a21b4d9007ec6dc78
    https://github.com/scummvm/scummvm/commit/28a5a747b3042da71e764f6a21b4d9007ec6dc78
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-29T00:07:40-04:00

Commit Message:
TITANIC: Finished CCreditText draw method

Changed paths:
    engines/titanic/support/credit_text.cpp
    engines/titanic/support/screen_manager.cpp
    engines/titanic/support/screen_manager.h



diff --git a/engines/titanic/support/credit_text.cpp b/engines/titanic/support/credit_text.cpp
index 9364acf..009c3f4 100644
--- a/engines/titanic/support/credit_text.cpp
+++ b/engines/titanic/support/credit_text.cpp
@@ -197,11 +197,61 @@ bool CCreditText::draw() {
 		}
 	}
 
-	_screenManagerP->setFontNumber(3);
+	int oldFontNumber = _screenManagerP->setFontNumber(3);
+	CCreditLineGroups::iterator groupIt = _groupIt;
+	CCreditLines::iterator lineIt = _lineIt;
+
+	Point textPos;
+	for (textPos.y = _rect.top + _totalHeight; textPos.y <= _rect.bottom;
+			textPos.y += _fontHeight) {
+		int textR = _field44 + _field50 * _counter / 200;
+		int textG = _field48 + _field54 * _counter / 200;
+		int textB = _field4C + _field58 * _counter / 200;
+
+		// Single iteration loop to figure out RGB values for the line
+		do {
+			int percent = 0;
+			if (textPos.y < (_rect.top + 2 * _fontHeight)) {
+				percent = (textPos.y - _rect.top) * 100 / (_fontHeight * 2);
+				if (percent < 0)
+					percent = 0;
+			} else {
+				int bottom = _rect.bottom - 2 * _fontHeight;
+				if (textPos.y < bottom)
+					break;
 
-	// TODO: Drawing loop
+				percent = (_rect.bottom - textPos.y) * 100
+					/ (_fontHeight * 2);
+			}
+
+			// Adjust the RGB to the specified percentage intensity
+			textR = textR * percent / 100;
+			textG = textG * percent / 100;
+			textB = textB * percent / 100;
+		} while (0);
+
+		// Write out the line
+		_screenManagerP->setFontColor(textR, textG, textB);
+		textPos.x = _rect.left + (_rect.width() - (*lineIt)->_lineWidth) / 2;
+		_screenManagerP->writeString(SURFACE_BACKBUFFER, textPos,
+			_rect, (*lineIt)->_line, (*lineIt)->_lineWidth);
+
+		// Move to next line
+		++lineIt;
+		if (lineIt == (*groupIt)->_lines.end()) {
+			++groupIt;
+			if (groupIt == _groups.end())
+				// Finished all lines
+				break;
 
-	return false;
+			lineIt = (*groupIt)->_lines.begin();
+			textPos.y += _fontHeight * 3 / 2;
+		}
+	}
+
+	_objectP->makeDirty();
+	_screenManagerP->setFontNumber(oldFontNumber);
+	return true;
 }
 
 } // End of namespace Titanic
diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp
index b0d8521..aa72200 100644
--- a/engines/titanic/support/screen_manager.cpp
+++ b/engines/titanic/support/screen_manager.cpp
@@ -239,10 +239,9 @@ int OSScreenManager::writeString(int surfaceNum, const Rect &destRect,
 		yOffset, str, textCursor);
 }
 
-int OSScreenManager::writeString(int surfaceNum, const Rect &srcRect,
-		const Rect &destRect, const CString &str, CTextCursor *textCursor) {
+void OSScreenManager::writeString(int surfaceNum, const Point &destPos,
+		const Rect &clipRect, const CString &str, int maxWidth) {
 	// TODO
-	return 0;
 }
 
 void OSScreenManager::setFontColor(byte r, byte g, byte b) {
diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h
index 0736f13..a47b6a1 100644
--- a/engines/titanic/support/screen_manager.h
+++ b/engines/titanic/support/screen_manager.h
@@ -140,13 +140,13 @@ public:
 	/**
 	 * Write a string
 	 * @param surfaceNum	Destination surface
-	 * @param srcRect		Drawing area
-	 * @param destRect		Bounds of dest surface
+	 * @param destPos		Position to start writing text at
+	 * @param clipRect		Clipping area to constrain text to
 	 * @param str			Line or lines to write
-	 * @param textCursor	Optional text cursor pointer
+	 * @param maxWidth		Maximum allowed line width
 	 */
-	virtual int writeString(int surfaceNum, const Rect &srcRect,
-		const Rect &destRect, const CString &str, CTextCursor *textCursor) = 0;
+	virtual void writeString(int surfaceNum, const Point &destPos,
+		const Rect &clipRect, const CString &str, int maxWidth) = 0;
 
 	/**
 	 * Set the font color
@@ -322,13 +322,13 @@ public:
 	/**
 	 * Write a string
 	 * @param surfaceNum	Destination surface
-	 * @param srcRect		Drawing area
-	 * @param destRect		Bounds of dest surface
+	 * @param destPos		Position to start writing text at
+	 * @param clipRect		Clipping area to constrain text to
 	 * @param str			Line or lines to write
-	 * @param textCursor	Optional text cursor pointer
+	 * @param maxWidth		Maximum allowed line width
 	 */
-	virtual int writeString(int surfaceNum, const Rect &srcRect,
-		const Rect &destRect, const CString &str, CTextCursor *textCursor);
+	virtual void writeString(int surfaceNum, const Point &destPos,
+		const Rect &clipRect, const CString &str, int maxWidth);
 
 	/**
 	 * Set the font color





More information about the Scummvm-git-logs mailing list