aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-24 10:37:34 -0400
committerPaul Gilbert2016-07-10 16:11:59 -0400
commita88c0b09994562d4576e7dd08db8ad2fe3326f53 (patch)
tree09a88bb11d3135342a7b01305474367dbcc31ec3 /engines/titanic/pet_control
parentaf06188baedf10247893c6f964462c74eac5f446 (diff)
downloadscummvm-rg350-a88c0b09994562d4576e7dd08db8ad2fe3326f53.tar.gz
scummvm-rg350-a88c0b09994562d4576e7dd08db8ad2fe3326f53.tar.bz2
scummvm-rg350-a88c0b09994562d4576e7dd08db8ad2fe3326f53.zip
TITANIC: Starting to flesh out CPetText drawing
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r--engines/titanic/pet_control/pet_load_save.cpp2
-rw-r--r--engines/titanic/pet_control/pet_text.cpp58
-rw-r--r--engines/titanic/pet_control/pet_text.h15
3 files changed, 62 insertions, 13 deletions
diff --git a/engines/titanic/pet_control/pet_load_save.cpp b/engines/titanic/pet_control/pet_load_save.cpp
index f777f122fe..9d185a3742 100644
--- a/engines/titanic/pet_control/pet_load_save.cpp
+++ b/engines/titanic/pet_control/pet_load_save.cpp
@@ -36,7 +36,7 @@ bool CPetLoadSave::setup(CPetControl *petControl, CPetGlyphs *owner) {
Rect slotRect = getSlotBounds(idx);
_slotNames[idx].setBounds(slotRect);
_slotNames[idx].resize(3);
- _slotNames[idx].set30(22);
+ _slotNames[idx].setMaxCharsPerLine(22);
_slotNames[idx].setHasBorder(false);
_slotNames[idx].setup();
}
diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp
index faa25d05ad..ca65b23ee1 100644
--- a/engines/titanic/pet_control/pet_text.cpp
+++ b/engines/titanic/pet_control/pet_text.cpp
@@ -25,11 +25,11 @@
namespace Titanic {
CPetText::CPetText(uint count) :
- _stringsMerged(false), _field30(-1), _lineCount(0),
- _field38(-1), _field3C(0), _field40(0), _field44(0),
+ _stringsMerged(false), _maxCharsPerLine(-1), _lineCount(0),
+ _fontNumber1(-1), _field3C(0), _field40(0), _field44(0),
_backR(0xff), _backG(0xff), _backB(0xff),
_textR(0), _textG(0), _textB(200),
- _field60(0), _field64(0), _field68(0), _field6C(0),
+ _fontNumber2(0), _field64(0), _field68(0), _field6C(0),
_hasBorder(true), _field74(0), _field78(0), _field7C(0) {
setupArrays(count);
}
@@ -130,7 +130,16 @@ void CPetText::draw(CScreenManager *screenManager) {
screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
}
- warning("TODO: CPetText::draw");
+ draw2(screenManager);
+
+ tempRect = _bounds;
+ tempRect.grow(-2);
+ screenManager->setFontNumber(_fontNumber2);
+
+// int var14 = 0;
+// screenManager->writeLines(0, &var14, _field74, )
+ warning("TODO: CPetText_Draw");
+ screenManager->setFontNumber(_fontNumber1);
}
void CPetText::mergeStrings() {
@@ -161,7 +170,22 @@ void CPetText::setText(const CString &str) {
}
void CPetText::changeText(const CString &str) {
- warning("TODO: CPetText::changeText");
+ int lineSize = _array[_lineCount]._string1.size();
+ int strSize = str.size();
+
+ if (_maxCharsPerLine == -1) {
+ // No limit on horizontal characters, so append string to current line
+ _array[_lineCount]._string1 += str;
+ } else if ((lineSize + strSize) <= _maxCharsPerLine) {
+ // New string fits into line, so add it on
+ _array[_lineCount]._string1 += str;
+ } else {
+ // Only add part of the str up to the maximum allowed limit for line
+ _array[_lineCount]._string1 += str.left(_maxCharsPerLine - lineSize);
+ }
+
+ updateStr3(_lineCount);
+ _stringsMerged = false;
}
void CPetText::setColor(int val1, uint col) {
@@ -174,9 +198,27 @@ void CPetText::setColor(uint col) {
_textB = (col >> 16) & 0xff;
}
-void CPetText::set30(int val) {
- if (val >= -1 && val < 257)
- _field30 = val;
+void CPetText::setMaxCharsPerLine(int maxChars) {
+ if (maxChars >= -1 && maxChars < 257)
+ _maxCharsPerLine = maxChars;
+}
+
+void CPetText::updateStr3(int lineNum) {
+ if (_field64 > 0 && _field68 > 0) {
+ char line[5];
+ line[0] = line[3] = 26;
+ line[1] = _field64;
+ line[2] = _field68;
+ line[4] = '\0';
+ _array[lineNum]._string3 = CString(line);
+
+ _stringsMerged = false;
+ _field64 = _field68 = 0;
+ }
+}
+
+void CPetText::draw2(CScreenManager *screenManager) {
+
}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h
index 17707117e5..9fd057a652 100644
--- a/engines/titanic/pet_control/pet_text.h
+++ b/engines/titanic/pet_control/pet_text.h
@@ -39,9 +39,9 @@ private:
CString _lines;
bool _stringsMerged;
Rect _bounds;
- int _field30;
+ int _maxCharsPerLine;
int _lineCount;
- int _field38;
+ int _fontNumber1;
int _field3C;
int _field40;
int _field44;
@@ -51,7 +51,7 @@ private:
int _textR;
int _textG;
int _textB;
- int _field60;
+ int _fontNumber2;
int _field64;
int _field68;
int _field6C;
@@ -75,6 +75,10 @@ private:
* Change the text
*/
void changeText(const CString &str);
+
+ void updateStr3(int lineNum);
+
+ void draw2(CScreenManager *screenManager);
public:
CPetText(uint count = 10);
@@ -120,7 +124,10 @@ public:
*/
void setColor(uint col);
- void set30(int val);
+ /**
+ * Sets the maximum number of characters per line
+ */
+ void setMaxCharsPerLine(int maxChars);
};
} // End of namespace Titanic