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

sev- sev at scummvm.org
Thu Dec 15 18:19:20 CET 2016


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

Summary:
2f7879d118 GRAPHICS: Restrinct MacText to designated width
d6126ffcfa GRAPHICS: Implemented blitting code for MacText


Commit: 2f7879d1183cd327219a8a6f1521ed5332db90d9
    https://github.com/scummvm/scummvm/commit/2f7879d1183cd327219a8a6f1521ed5332db90d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-15T18:07:48+01:00

Commit Message:
GRAPHICS: Restrinct MacText to designated width

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index f7b2ed9..4807e19 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -33,7 +33,10 @@ MacText::MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolo
 
 	_interLinear = 0; // 0 pixels between the lines by default
 
-	_textMaxWidth = -1;
+	if (_maxWidth == -1)
+		_textMaxWidth = 1000000; // Some big value
+	else
+		_textMaxWidth = -1;
 
 	splitString();
 
@@ -46,6 +49,8 @@ void MacText::splitString() {
 	Common::String tmp;
 	bool prevCR;
 
+	_text.clear();
+
 	while (*s) {
 		if (*s == '\n' && prevCR) {	// trean \r\n as one
 			prevCR = false;
@@ -56,8 +61,7 @@ void MacText::splitString() {
 			prevCR = true;
 
 		if (*s == '\r' || *s == '\n') {
-			_text.push_back(tmp);
-			_widths.push_back(_font->getStringWidth(tmp));
+			_maxWidth = MIN(_font->wordWrapText(tmp, _maxWidth, _text), _maxWidth);
 
 			tmp.clear();
 
@@ -68,24 +72,13 @@ void MacText::splitString() {
 	}
 
 	if (_text.size())
-		_text.push_back(tmp);
-
-	calcMaxWidth();
-}
-
-void MacText::calcMaxWidth() {
-	int max = -1;
-
-	for (uint i = 0; i < _widths.size(); i++)
-		if (max < _widths[i])
-			max = _widths[i];
-
-	_textMaxWidth = max;
+		_maxWidth = MIN(_font->wordWrapText(tmp, _maxWidth, _text), _maxWidth);
 }
 
 void MacText::render() {
 	if (_fullRefresh) {
-		_surface.create(_textMaxWidth, _text.size() * (_font->getFontHeight() + _interLinear));
+		_surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth,
+					_text.size() * (_font->getFontHeight() + _interLinear));
 
 		_surface.clear(_bgcolor);
 
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index cf97584..7831e65 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -48,7 +48,6 @@ private:
 	int _interLinear;
 
 	Common::Array<Common::String> _text;
-	Common::Array<int> _widths;
 
 	int _textMaxWidth;
 


Commit: d6126ffcfacb7bb29986196e5826e9ca7e34ad70
    https://github.com/scummvm/scummvm/commit/d6126ffcfacb7bb29986196e5826e9ca7e34ad70
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-15T18:18:12+01:00

Commit Message:
GRAPHICS: Implemented blitting code for MacText

Changed paths:
    graphics/macgui/mactext.cpp
    graphics/macgui/mactext.h


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 4807e19..fde79f9 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -94,4 +94,15 @@ void MacText::render() {
 	}
 }
 
+void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff) {
+	render();
+
+	if (x + w < _surface.w || y + h < _surface.h) {
+		g->fillRect(Common::Rect(x, y, x + w, y + w), _bgcolor);
+	}
+
+	g->blitFrom(_surface, Common::Rect(MIN<int>(_surface.w, x), MIN<int>(_surface.h, y),
+									   MIN<int>(_surface.w, x + w), MIN<int>(_surface.w, y + w)), Common::Point(xoff, yoff));
+}
+
 } // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 7831e65..4add394 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -34,6 +34,9 @@ public:
 
 	void setInterLinear(int interLinear) { _interLinear = interLinear; }
 
+	void draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff);
+
+
 private:
 	void splitString();
 	void render();





More information about the Scummvm-git-logs mailing list