diff options
Diffstat (limited to 'graphics')
| -rw-r--r-- | graphics/font.cpp | 2 | ||||
| -rw-r--r-- | graphics/macgui/mactext.cpp | 13 | ||||
| -rw-r--r-- | graphics/macgui/mactext.h | 8 | 
3 files changed, 16 insertions, 7 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp index 7768b7362d..4f53dfe858 100644 --- a/graphics/font.cpp +++ b/graphics/font.cpp @@ -227,7 +227,7 @@ int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Comm  	if (lineWidth > 0) {  		wrapper.add(line, lineWidth);  	} -	return wrapper.actualMaxLineWidth; +	return MAX(wrapper.actualMaxLineWidth, maxWidth);  }  } // End of anonymous namespace diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index abf1e4fc38..4d671e89fc 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -24,7 +24,7 @@  namespace Graphics { -MacText::MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth) { +MacText::MacText(Common::String s, const Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth) {  	_str = s;  	_font = font;  	_fgcolor = fgcolor; @@ -53,6 +53,8 @@ void MacText::splitString(Common::String &str) {  	while (*s) {  		if (*s == '\n' && prevCR) {	// trean \r\n as one  			prevCR = false; + +			s++;  			continue;  		} @@ -64,10 +66,12 @@ void MacText::splitString(Common::String &str) {  			tmp.clear(); +			s++;  			continue;  		}  		tmp += *s; +		s++;  	}  	if (tmp.size()) @@ -77,7 +81,9 @@ void MacText::splitString(Common::String &str) {  void MacText::reallocSurface() {  	int lineH = _font->getFontHeight() + _interLinear;  	// round to closest 10 -	int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH; +	//TODO: work out why this rounding doesn't correctly fill the entire width +	//int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH +	int requiredH = _text.size() * lineH;  	int surfW = _maxWidth == -1 ? _textMaxWidth : _maxWidth;  	if (!_surface) { @@ -117,7 +123,8 @@ void MacText::render(int from, int to) {  	_surface->fillRect(Common::Rect(0, y, _surface->w, to * lineH), _bgcolor);  	for (int i = from; i < to; i++) { -		_font->drawString(_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); +		//TODO: _textMaxWidth, when -1, was not rendering ANY text. +		_font->drawString(_surface, _text[i], 0, y, _maxWidth, _fgcolor);  		y += _font->getFontHeight() + _interLinear;  	} diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index e035eb123f..21c063f896 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -30,7 +30,7 @@ namespace Graphics {  class MacText {  public: -	MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth = -1); +	MacText(Common::String s, const Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth = -1);  	void setInterLinear(int interLinear) { _interLinear = interLinear; } @@ -38,16 +38,18 @@ public:  	void appendText(Common::String str);  	void replaceLastLine(Common::String str); +	void render(); +	Graphics::ManagedSurface *getSurface() { return _surface; } +  private:  	void splitString(Common::String &s); -	void render();  	void render(int from, int to);  	void calcMaxWidth();  	void reallocSurface();  private:  	Common::String _str; -	Graphics::Font *_font; +	const Graphics::Font *_font;  	int _fgcolor, _bgcolor;  	int _maxWidth;  | 
