[Scummvm-cvs-logs] scummvm master -> 6ace70a625b76f0b2471b73d702649fbf0cfe7a0
wjp
wjp at usecode.org
Thu Dec 24 15:29:14 CET 2015
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
a08dd694e5 LAB: Improve whitespace handling in flowText
6ace70a625 LAB: Clarify and clean up drawJournalText
Commit: a08dd694e56ee53f99faeb18e1ca7b442b8875ce
https://github.com/scummvm/scummvm/commit/a08dd694e56ee53f99faeb18e1ca7b442b8875ce
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2015-12-24T15:27:48+01:00
Commit Message:
LAB: Improve whitespace handling in flowText
flowText was handling presence/absence of whitespace after lines
inconsistently. This caused end-of-string to be missed, which broke
last-page detection in the journal. It also introduced extra spaces at the
beginning of pages.
Changed paths:
engines/lab/dispman.cpp
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 376c8ad..d8504eb 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -120,26 +120,29 @@ Common::String DisplayMan::getWord(const char *mainBuffer) {
Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth) {
uint16 curWidth = 0;
Common::String result;
- bool doit = true;
- lineWidth += textLength(tf, " ");
-
- while ((*mainBuffer)[0] && doit) {
- Common::String wordBuffer = getWord(*mainBuffer) + " ";
+ while ((*mainBuffer)[0]) {
+ Common::String wordBuffer = getWord(*mainBuffer);
if ((curWidth + textLength(tf, wordBuffer)) <= lineWidth) {
result += wordBuffer;
- (*mainBuffer) += wordBuffer.size() - 1;
+ (*mainBuffer) += wordBuffer.size();
- if ((*mainBuffer)[0] == '\n')
- doit = false;
+ // end of line
+ if ((*mainBuffer)[0] == '\n') {
+ (*mainBuffer)++;
+ break;
+ }
- if ((*mainBuffer)[0])
+ // append any space after the word
+ if ((*mainBuffer)[0]) {
+ result += (*mainBuffer)[0];
(*mainBuffer)++;
+ }
curWidth = textLength(tf, result);
} else
- doit = false;
+ break;
}
return result;
@@ -161,19 +164,20 @@ int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte back
if (!str)
return 0;
+ const char *orig = str;
+
TextFont *msgFont = font;
uint16 fontHeight = textHeight(msgFont) + spacing;
uint16 numLines = (textRect.height() + 1) / fontHeight;
uint16 width = textRect.width() + 1;
uint16 y = textRect.top;
- Common::String lineBuffer;
if (centerv && output) {
const char *temp = str;
uint16 actlines = 0;
while (temp[0]) {
- lineBuffer = getLine(msgFont, &temp, width);
+ getLine(msgFont, &temp, width);
actlines++;
}
@@ -183,6 +187,7 @@ int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte back
int len = 0;
while (numLines && str[0]) {
+ Common::String lineBuffer;
lineBuffer = getLine(msgFont, &str, width);
uint16 x = textRect.left;
@@ -198,11 +203,9 @@ int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte back
y += fontHeight;
}
- len--;
-
_currentDisplayBuffer = saveDisplayBuffer;
- return len;
+ return (str - orig);
}
void DisplayMan::createBox(uint16 y2) {
Commit: 6ace70a625b76f0b2471b73d702649fbf0cfe7a0
https://github.com/scummvm/scummvm/commit/6ace70a625b76f0b2471b73d702649fbf0cfe7a0
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2015-12-24T15:28:25+01:00
Commit Message:
LAB: Clarify and clean up drawJournalText
Changed paths:
engines/lab/special.cpp
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9a631e4..dd2ee1c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -145,34 +145,38 @@ void LabEngine::loadJournalData() {
void LabEngine::drawJournalText() {
uint16 drawingToPage = 1;
- int charsDrawn = 0;
const char *curText = _journalText.c_str();
+ assert((_journalPage & 1) == 0);
+
while (drawingToPage < _journalPage) {
updateMusicAndEvents();
- curText = _journalText.c_str() + charsDrawn;
- charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
+
+ // flowText without output
+ curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
_lastPage = (*curText == 0);
- if (_lastPage)
+ if (_lastPage) {
+ // Reset _journalPage to this page, in case it was set too high
_journalPage = (drawingToPage / 2) * 2;
- else
- drawingToPage++;
+ break;
+ }
+
+ drawingToPage++;
}
- if (_journalPage <= 1) {
- curText = _journalTextTitle.c_str();
- _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage);
+ if (_journalPage == 0) {
+ // draw title page centered
+ _graphics->flowText(_journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), _journalTextTitle.c_str(), _journalBackImage);
} else {
- curText = _journalText.c_str() + charsDrawn;
- charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage);
+ curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText, _journalBackImage);
}
updateMusicAndEvents();
- curText = _journalText.c_str() + charsDrawn;
+ curText += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage);
+
_lastPage = (*curText == 0);
- _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText, _journalBackImage);
}
void LabEngine::turnPage(bool fromLeft) {
More information about the Scummvm-git-logs
mailing list