[Scummvm-git-logs] scummvm master -> dc640ab50a63b0383c6aec6df4e0427df1824c3e

sev- sev at scummvm.org
Sun Jan 29 18:41:24 CET 2017


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:
dc640ab50a GRAPHICS: Added optional initial line width ot text wrapper


Commit: dc640ab50a63b0383c6aec6df4e0427df1824c3e
    https://github.com/scummvm/scummvm/commit/dc640ab50a63b0383c6aec6df4e0427df1824c3e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-01-29T18:41:07+01:00

Commit Message:
GRAPHICS: Added optional initial line width ot text wrapper

Changed paths:
    graphics/font.cpp
    graphics/font.h


diff --git a/graphics/font.cpp b/graphics/font.cpp
index 7768b73..3446619 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -142,11 +142,11 @@ struct WordWrapper {
 };
 
 template<class StringType>
-int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Common::Array<StringType> &lines) {
+int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Common::Array<StringType> &lines, int initWidth) {
 	WordWrapper<StringType> wrapper(lines);
 	StringType line;
 	StringType tmpStr;
-	int lineWidth = 0;
+	int lineWidth = initWidth;
 	int tmpWidth = 0;
 
 	// The rough idea behind this algorithm is as follows:
@@ -305,12 +305,12 @@ void Font::drawString(ManagedSurface *dst, const Common::U32String &str, int x,
 	}
 }
 
-int Font::wordWrapText(const Common::String &str, int maxWidth, Common::Array<Common::String> &lines) const {
-	return wordWrapTextImpl(*this, str, maxWidth, lines);
+int Font::wordWrapText(const Common::String &str, int maxWidth, Common::Array<Common::String> &lines, int initWidth) const {
+	return wordWrapTextImpl(*this, str, maxWidth, lines, initWidth);
 }
 
-int Font::wordWrapText(const Common::U32String &str, int maxWidth, Common::Array<Common::U32String> &lines) const {
-	return wordWrapTextImpl(*this, str, maxWidth, lines);
+int Font::wordWrapText(const Common::U32String &str, int maxWidth, Common::Array<Common::U32String> &lines, int initWidth) const {
+	return wordWrapTextImpl(*this, str, maxWidth, lines, initWidth);
 }
 
 Common::String Font::handleEllipsis(const Common::String &input, int w) const {
diff --git a/graphics/font.h b/graphics/font.h
index 0478608..6682ce0 100644
--- a/graphics/font.h
+++ b/graphics/font.h
@@ -169,13 +169,14 @@ public:
 	 * It returns the maximal width of any of the new lines (i.e. a value which is less
 	 * or equal to maxWidth).
 	 *
-	 * @param str      the string to word wrap
-	 * @param maxWidth the maximum width a line may have
-	 * @param lines    the string list to which the text lines from str are appended
+	 * @param str       the string to word wrap
+	 * @param maxWidth  the maximum width a line may have
+	 * @param lines     the string list to which the text lines from str are appended
+	 * @param initWidth the starting width of the first line, for partially filled lines (optional)
 	 * @return the maximal width of any of the lines added to lines
 	 */
-	int wordWrapText(const Common::String &str, int maxWidth, Common::Array<Common::String> &lines) const;
-	int wordWrapText(const Common::U32String &str, int maxWidth, Common::Array<Common::U32String> &lines) const;
+	int wordWrapText(const Common::String &str, int maxWidth, Common::Array<Common::String> &lines, int initWidth = 0) const;
+	int wordWrapText(const Common::U32String &str, int maxWidth, Common::Array<Common::U32String> &lines, int initWidth = 0) const;
 
 private:
 	Common::String handleEllipsis(const Common::String &str, int w) const;





More information about the Scummvm-git-logs mailing list