aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2017-01-31 22:35:06 +0100
committerEugene Sandulenko2017-01-31 23:14:37 +0100
commitc15e063bbd549261e6be020cdd046e7368d22769 (patch)
treec060a2f5d01ce131126aa9fdfbb2c7386540e6aa
parent93265c6d41466dd7513472e160a3579c740410dd (diff)
downloadscummvm-rg350-c15e063bbd549261e6be020cdd046e7368d22769.tar.gz
scummvm-rg350-c15e063bbd549261e6be020cdd046e7368d22769.tar.bz2
scummvm-rg350-c15e063bbd549261e6be020cdd046e7368d22769.zip
GRAPHICS: Store more metainformation on lines in MacText
-rw-r--r--graphics/macgui/mactext.cpp28
-rw-r--r--graphics/macgui/mactext.h13
2 files changed, 26 insertions, 15 deletions
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 4b7dc073ab..426fc296b2 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -68,11 +68,11 @@ void MacText::splitString(Common::String &str) {
if (_textLines.empty()) {
_textLines.resize(1);
- _textLines[0].push_back(_defaultFormatting);
+ _textLines[0].chunks.push_back(_defaultFormatting);
}
int curLine = _textLines.size() - 1;
- int curChunk = _textLines[curLine].size() - 1;
+ int curChunk = _textLines[curLine].chunks.size() - 1;
bool nextChunk = false;
while (*s) {
@@ -97,11 +97,11 @@ void MacText::splitString(Common::String &str) {
_currentFormatting.setValues(_wm, fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);
- if ((_textLines[curLine])[curChunk].text.empty()) {
- (_textLines[curLine])[curChunk] = _currentFormatting;
+ if (_textLines[curLine].chunks[curChunk].text.empty()) {
+ _textLines[curLine].chunks[curChunk] = _currentFormatting;
continue;
} else {
- _textLines[curLine].push_back(_currentFormatting);
+ _textLines[curLine].chunks.push_back(_currentFormatting);
}
nextChunk = true;
@@ -123,7 +123,7 @@ void MacText::splitString(Common::String &str) {
if (text.size()) {
if (nextChunk) {
- (_textLines[curLine])[curChunk].text += text[0];
+ _textLines[curLine].chunks[curChunk].text += text[0];
curChunk++;
_text[curLine] += text[0];
@@ -136,16 +136,16 @@ void MacText::splitString(Common::String &str) {
for (uint i = 0; i < text.size(); i++) {
_text.push_back(text[i]);
- (_textLines[curLine])[curChunk].text = text[i];
+ _textLines[curLine].chunks[curChunk].text = text[i];
curLine++;
_textLines.resize(curLine + 1);
- _textLines[curLine].push_back(_currentFormatting);
+ _textLines[curLine].chunks.push_back(_currentFormatting);
curChunk = 0;
}
} else {
if (nextChunk) { // No text, replacing formatting
- (_textLines[curLine])[curChunk] = _currentFormatting;
+ _textLines[curLine].chunks[curChunk] = _currentFormatting;
}
}
@@ -165,7 +165,7 @@ void MacText::splitString(Common::String &str) {
_textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, text), _textMaxWidth);
- (_textLines[curLine])[curChunk].text = text[0];
+ _textLines[curLine].chunks[curChunk].text = text[0];
_text.push_back(text[0]);
@@ -175,8 +175,8 @@ void MacText::splitString(Common::String &str) {
curLine++;
_textLines.resize(curLine + 1);
- _textLines[curLine].push_back(_currentFormatting);
- (_textLines[curLine])[0].text = text[i];
+ _textLines[curLine].chunks.push_back(_currentFormatting);
+ _textLines[curLine].chunks[0].text = text[i];
}
}
}
@@ -242,8 +242,8 @@ void MacText::render(int from, int to) {
for (uint i = 0; i < _textLines.size(); i++) {
debugN(4, "%2d ", i);
- for (uint j = 0; j < _textLines[i].size(); j++)
- debugN(4, "[%d] \"%s\"", (_textLines[i])[j].fontId, (_textLines[i])[j].text.c_str());
+ for (uint j = 0; j < _textLines[i].chunks.size(); j++)
+ debugN(4, "[%d] \"%s\"", _textLines[i].chunks[j].fontId, _textLines[i].chunks[j].text.c_str());
debug(4, "");
}
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 7234cdcdaf..f94b2bc6ff 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -73,6 +73,17 @@ struct MacFontRun {
const Font *getFont();
};
+struct MacTextLine {
+ int width;
+ int height;
+
+ Common::Array<MacFontRun> chunks;
+
+ MacTextLine() {
+ width = height = -1;
+ }
+};
+
class MacText {
public:
MacText(Common::String s, MacWindowManager *wm, const Graphics::Font *font, int fgcolor, int bgcolor,
@@ -112,7 +123,7 @@ private:
TextAlign _textAlignment;
- Common::Array< Common::Array<MacFontRun> > _textLines;
+ Common::Array<MacTextLine> _textLines;
MacFontRun _defaultFormatting;
MacFontRun _currentFormatting;
};