[Scummvm-git-logs] scummvm master -> ef01a6ad29c789af369e931d3463515e9ef55115
Strangerke
Strangerke at scummvm.org
Tue Jun 8 07:44:45 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ef01a6ad29 TRECISION: Turn _drawTextLines into an array of Common::String
Commit: ef01a6ad29c789af369e931d3463515e9ef55115
https://github.com/scummvm/scummvm/commit/ef01a6ad29c789af369e931d3463515e9ef55115
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2021-06-08T08:44:38+01:00
Commit Message:
TRECISION: Turn _drawTextLines into an array of Common::String
Changed paths:
engines/trecision/struct.h
engines/trecision/utils.cpp
diff --git a/engines/trecision/struct.h b/engines/trecision/struct.h
index 0a7298569b..94842d7284 100644
--- a/engines/trecision/struct.h
+++ b/engines/trecision/struct.h
@@ -167,7 +167,7 @@ struct SDText {
uint16 _textCol;
uint16 _shadowCol;
Common::String _text;
- char _drawTextLines[MAXDTEXTLINES][MAXDTEXTCHARS];
+ Common::String _drawTextLines[MAXDTEXTLINES];
void set(SDText *org);
void set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, uint16 shadowCol, const Common::String &text);
diff --git a/engines/trecision/utils.cpp b/engines/trecision/utils.cpp
index f37fdcd263..5f34b06836 100644
--- a/engines/trecision/utils.cpp
+++ b/engines/trecision/utils.cpp
@@ -308,10 +308,8 @@ void SDText::set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, u
_text = text;
// Clean output buffer
- for (int i = 0; i < MAXDTEXTLINES; ++i) {
- for (int j = 0; j < MAXDTEXTCHARS; ++j)
- _drawTextLines[i][j] = '\0';
- }
+ for (int i = 0; i < MAXDTEXTLINES; ++i)
+ _drawTextLines[i] = "";
}
/**
@@ -323,7 +321,7 @@ uint16 SDText::calcHeight(TrecisionEngine *vm) {
uint8 curLine = 0;
if (vm->textLength(_text) <= _rect.width()) {
- strcpy((char *)_drawTextLines[curLine], _text.c_str());
+ _drawTextLines[curLine] = _text;
return CARHEI;
}
@@ -338,13 +336,9 @@ uint16 SDText::calcHeight(TrecisionEngine *vm) {
if (vm->textLength(_text, curInit, a) <= _rect.width())
lastSpace = a;
else if (vm->textLength(_text, curInit, lastSpace) <= _rect.width()) {
- uint16 b;
- for (b = curInit; b < lastSpace; ++b)
- _drawTextLines[curLine][b - curInit] = _text[b];
+ _drawTextLines[curLine] = _text.substr(curInit, lastSpace - curInit);
- _drawTextLines[curLine][b - curInit] = '\0';
++curLine;
-
curInit = lastSpace + 1;
tmpDy += CARHEI;
@@ -353,33 +347,21 @@ uint16 SDText::calcHeight(TrecisionEngine *vm) {
return 0;
} else if (a == _text.size()) {
if (vm->textLength(_text, curInit, a) <= _rect.width()) {
- uint16 b;
- for (b = curInit; b < a; ++b)
- _drawTextLines[curLine][b - curInit] = _text[b];
- _drawTextLines[curLine][b - curInit] = '\0';
+ _drawTextLines[curLine] = _text.substr(curInit, a - curInit);
tmpDy += CARHEI;
-
return tmpDy;
}
if (vm->textLength(_text, curInit, lastSpace) <= _rect.width()) {
- uint16 b;
- for (b = curInit; b < lastSpace; ++b)
- _drawTextLines[curLine][b - curInit] = _text[b];
+ _drawTextLines[curLine] = _text.substr(curInit, lastSpace - curInit);
- _drawTextLines[curLine][b - curInit] = '\0';
++curLine;
-
curInit = lastSpace + 1;
tmpDy += CARHEI;
if (curInit < _text.size()) {
- for (b = curInit; b < _text.size(); ++b)
- _drawTextLines[curLine][b - curInit] = _text[b];
-
- _drawTextLines[curLine][b - curInit] = '\0';
-
+ _drawTextLines[curLine] = _text.substr(curInit);
tmpDy += CARHEI;
}
return tmpDy;
More information about the Scummvm-git-logs
mailing list