From 88b9dd3472883de36acd4d6fdc7fd6d097328808 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 20 Dec 2016 21:19:13 +0100 Subject: GRAPHICS: Simplify MacText --- graphics/macgui/mactext.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'graphics') diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 412ddae640..2af31a9efd 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -70,7 +70,7 @@ void MacText::splitString(Common::String &str) { tmp += *s; } - if (_text.size()) + if (tmp.size()) _maxWidth = MIN(_font->wordWrapText(tmp, _maxWidth, _text), _maxWidth); } @@ -98,10 +98,6 @@ void MacText::reallocSurface() { void MacText::render() { if (_fullRefresh) { - reallocSurface(); - - _surface->clear(_bgcolor); - render(0, _text.size()); _fullRefresh = false; @@ -109,6 +105,8 @@ void MacText::render() { } void MacText::render(int from, int to) { + reallocSurface(); + from = MAX(0, from); to = MIN(to, _text.size()); @@ -133,8 +131,9 @@ void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int g->fillRect(Common::Rect(x, y, x + w, y + w), _bgcolor); } - g->blitFrom(*_surface, Common::Rect(MIN(_surface->w, x), MIN(_surface->h, y), - MIN(_surface->w, x + w), MIN(_surface->w, y + w)), Common::Point(xoff, yoff)); + g->blitFrom(*_surface, Common::Rect(MIN(_surface->w, x), MIN(_surface->h, y), + MIN(_surface->w, x + w), MIN(_surface->w, y + w)), + Common::Point(xoff, yoff)); } void MacText::appendText(Common::String str) { @@ -142,8 +141,6 @@ void MacText::appendText(Common::String str) { splitString(str); - reallocSurface(); - render(oldLen + 1, _text.size()); } -- cgit v1.2.3