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

eriktorbjorn noreply at scummvm.org
Sat Nov 18 21:44:41 UTC 2023


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:
ba501a628e SCUMM: Use Font's built-in word-wrapper for Mac GUI strings


Commit: ba501a628eacb128a1ee175a2ad49a60752e4d91
    https://github.com/scummvm/scummvm/commit/ba501a628eacb128a1ee175a2ad49a60752e4d91
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2023-11-18T22:44:11+01:00

Commit Message:
SCUMM: Use Font's built-in word-wrapper for Mac GUI strings

I didn't realize this existed. Once I found the one in base-str.cpp and
decided I couldn't use it, I wrote my own. But you should never get so
attached to any code you write that you can't bear to throw it away when
a better solution presents itself.

Changed paths:
    engines/scumm/gfx_mac.cpp


diff --git a/engines/scumm/gfx_mac.cpp b/engines/scumm/gfx_mac.cpp
index 4926d37d06d..6f9ccee3d75 100644
--- a/engines/scumm/gfx_mac.cpp
+++ b/engines/scumm/gfx_mac.cpp
@@ -287,37 +287,7 @@ int MacGui::MacWidget::drawText(Common::String text, int x, int y, int w, Color
 	int maxLineWidth = 0;
 
 	if (wordWrap) {
-		int start = 0;
-		int lineWidth = 0;
-		int lastSpace = -1;
-
-		for (uint i = 0; i < text.size(); i++) {
-			if (text[i] == ' ')
-				lastSpace = i;
-
-			lineWidth += font->getCharWidth(text[i]);
-
-			if (lineWidth > w) {
-				if (lastSpace > start)
-					i = lastSpace;
-
-				if (lineWidth > maxLineWidth)
-					maxLineWidth = lineWidth;
-
-				lines.push_back(text.substr(start, i - start));
-				lineWidth = 0;
-
-				if (lastSpace > start)
-					start = i + 1;
-				else
-					start = i;
-			}
-		}
-
-		lines.push_back(text.substr(start));
-
-		if (lineWidth > maxLineWidth)
-			maxLineWidth = lineWidth;
+		maxLineWidth = font->wordWrapText(text, w, lines);
 	} else {
 		lines.push_back(text);
 		maxLineWidth = font->getStringWidth(text);




More information about the Scummvm-git-logs mailing list