From 16b0cde5fba7b16ff412710942e95ca91f87cecb Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 20 Dec 2016 21:07:54 +0100 Subject: GRAPHICS: Implemented partial MacText drawing --- graphics/macgui/mactext.cpp | 32 ++++++++++++++++++++++---------- graphics/macgui/mactext.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp index 2dc1fc8e2c..389fca4872 100644 --- a/graphics/macgui/mactext.cpp +++ b/graphics/macgui/mactext.cpp @@ -74,12 +74,12 @@ void MacText::splitString(Common::String &str) { } void MacText::reallocSurface() { - int lineHeight = _font->getFontHeight() + _interLinear; - int requiredHeight = (_text.size() + (_text.size() * 10 + 9) / 10) * lineHeight; + int lineH = _font->getFontHeight() + _interLinear; + int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH; - if (_surface.w < requiredHeight) { + if (_surface.w < requiredH) { // realloc surface - _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth, requiredHeight); + _surface.create(_maxWidth == -1 ? _textMaxWidth : _maxWidth, requiredH); } } @@ -89,16 +89,28 @@ void MacText::render() { _surface.clear(_bgcolor); - int y = 0; + render(0, _text.size()); - for (uint i = 0; i < _text.size(); i++) { - _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); + _fullRefresh = false; + } +} - y += _font->getFontHeight() + _interLinear; - } +void MacText::render(int from, int to) { + from = MAX(0, from); + to = MIN(to, _text.size()); - _fullRefresh = false; + int lineH = _font->getFontHeight() + _interLinear; + int y = from * lineH; + + // Clear the screen + _surface.fillRect(Common::Rect(0, y, _surface.w, to * lineH), _bgcolor); + + for (uint i = from; i < to; i++) { + _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor); + + y += _font->getFontHeight() + _interLinear; } + } void MacText::draw(ManagedSurface *g, int x, int y, int w, int h, int xoff, int yoff) { diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h index 65e93ca5c3..a133c5c24b 100644 --- a/graphics/macgui/mactext.h +++ b/graphics/macgui/mactext.h @@ -41,6 +41,7 @@ public: private: void splitString(Common::String &s); void render(); + void render(int from, int to); void calcMaxWidth(); void reallocSurface(); -- cgit v1.2.3