Skip to content

Commit

Permalink
DIRECTOR: Generate font style runs for MacText
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Jan 31, 2017
1 parent 95be2f2 commit c4f7301
Showing 1 changed file with 44 additions and 15 deletions.
59 changes: 44 additions & 15 deletions graphics/macgui/mactext.cpp
Expand Up @@ -68,9 +68,7 @@ void MacText::splitString(Common::String &str) {

if (_textLines.empty()) {
_textLines.resize(1);
_textLines[0].resize(1);

_textLines[0][0] = _defaultFormatting;
_textLines[0].push_back(_defaultFormatting);
}

int curLine = _textLines.size() - 1;
Expand Down Expand Up @@ -99,7 +97,12 @@ void MacText::splitString(Common::String &str) {

_currentFormatting.setValues(_wm, fontId, textSlant, unk3f, fontSize, palinfo1, palinfo2, palinfo3);

_textLines[curLine].push_back(_currentFormatting);
if ((_textLines[curLine])[curChunk].text.empty()) {
(_textLines[curLine])[curChunk] = _currentFormatting;
continue;
} else {
_textLines[curLine].push_back(_currentFormatting);
}

nextChunk = true;
}
Expand All @@ -117,37 +120,63 @@ void MacText::splitString(Common::String &str) {

_textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, text), _textMaxWidth);

_textLines[curLine][curChunk].text = text[0];
if (text.size()) {
(_textLines[curLine])[curChunk].text = text[0];

if (nextChunk) {
curChunk++;
nextChunk = false;
if (nextChunk) {
curChunk++;

_text[curLine] += text[0];
} else {
_text.push_back(text[0]);
_text[curLine] += text[0];
} else {
_text.push_back(text[0]);
}
}

if (text.size() > 1) {
for (uint i = 1; i < text.size(); i++) {
_text.push_back(text[i]);

//curLine++;
curLine++;
_textLines.resize(curLine + 1);
_textLines[curLine].push_back(_currentFormatting);
(_textLines[curLine])[0].text = text[i];
curChunk = 0;
}
}

tmp.clear();

s++;
if (!nextChunk) // Don't skip next character
s++;

nextChunk = false;
continue;
}

tmp += *s;
s++;
}

if (tmp.size())
_textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, _text), _textMaxWidth);
if (tmp.size()) {
Common::Array<Common::String> text;

_textMaxWidth = MAX(_font->wordWrapText(tmp, _maxWidth, text), _textMaxWidth);

(_textLines[curLine])[curChunk].text = text[0];

_text.push_back(text[0]);

if (text.size() > 1) {
for (uint i = 1; i < text.size(); i++) {
_text.push_back(text[i]);

curLine++;
_textLines.resize(curLine + 1);
_textLines[curLine].push_back(_currentFormatting);
(_textLines[curLine])[0].text = text[i];
}
}
}
}

void MacText::reallocSurface() {
Expand Down

0 comments on commit c4f7301

Please sign in to comment.