aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--engines/titanic/support/screen_manager.h8
4 files changed, 70 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
diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h
index affe2ec0c9..d0580d4957 100644
--- a/engines/titanic/support/screen_manager.h
+++ b/engines/titanic/support/screen_manager.h
@@ -145,7 +145,15 @@ public:
virtual void showCursor() = 0;
virtual void hideCursor() = 0;
+ /**
+ * Set drawing bounds for a specified surface
+ */
void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r);
+
+ /**
+ * Set the current font number
+ */
+ void setFontNumber(int fontNumber) { _fontNumber = fontNumber; }
};
class OSScreenManager: CScreenManager {