diff options
author | stevenhoefel | 2017-01-15 18:42:50 +1100 |
---|---|---|
committer | stevenhoefel | 2017-01-15 18:42:50 +1100 |
commit | 2e48529fa1f1d865299db81bc99cb7537656b19f (patch) | |
tree | d1f0f7ebf5a60bd17dc40b11f8dd77ce491daace /graphics/macgui | |
parent | 8b4460e310886499f5018cdd264c0e3e835fe6fa (diff) | |
download | scummvm-rg350-2e48529fa1f1d865299db81bc99cb7537656b19f.tar.gz scummvm-rg350-2e48529fa1f1d865299db81bc99cb7537656b19f.tar.bz2 scummvm-rg350-2e48529fa1f1d865299db81bc99cb7537656b19f.zip |
DIRECTOR: Utilise MacText class to provide Text Wrapping.
Diffstat (limited to 'graphics/macgui')
-rw-r--r-- | graphics/macgui/mactext.cpp | 13 | ||||
-rw-r--r-- | graphics/macgui/mactext.h | 8 |
2 files changed, 15 insertions, 6 deletions
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; |