[Scummvm-git-logs] scummvm master -> d0d00f6beb9a2fab19455f653837af1b629d00da
dreammaster
dreammaster at scummvm.org
Sun Jan 1 11:25:31 CET 2017
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:
d0d00f6beb TITANIC: Rename CPetText to CTextControl
Commit: d0d00f6beb9a2fab19455f653837af1b629d00da
https://github.com/scummvm/scummvm/commit/d0d00f6beb9a2fab19455f653837af1b629d00da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-01-01T05:24:31-05:00
Commit Message:
TITANIC: Rename CPetText to CTextControl
The class is used in several areas outside of the PET, so it makes
better sense to not have it in the pet_control/ folder and named so
Changed paths:
A engines/titanic/gfx/text_control.cpp
A engines/titanic/gfx/text_control.h
R engines/titanic/pet_control/pet_text.cpp
R engines/titanic/pet_control/pet_text.h
engines/titanic/continue_save_dialog.h
engines/titanic/core/game_object.cpp
engines/titanic/core/game_object.h
engines/titanic/module.mk
engines/titanic/pet_control/pet_conversations.h
engines/titanic/pet_control/pet_glyphs.cpp
engines/titanic/pet_control/pet_glyphs.h
engines/titanic/pet_control/pet_inventory.h
engines/titanic/pet_control/pet_inventory_glyphs.cpp
engines/titanic/pet_control/pet_inventory_glyphs.h
engines/titanic/pet_control/pet_load.cpp
engines/titanic/pet_control/pet_load.h
engines/titanic/pet_control/pet_load_save.h
engines/titanic/pet_control/pet_quit.cpp
engines/titanic/pet_control/pet_quit.h
engines/titanic/pet_control/pet_real_life.h
engines/titanic/pet_control/pet_remote.cpp
engines/titanic/pet_control/pet_remote.h
engines/titanic/pet_control/pet_remote_glyphs.cpp
engines/titanic/pet_control/pet_remote_glyphs.h
engines/titanic/pet_control/pet_rooms.cpp
engines/titanic/pet_control/pet_rooms.h
engines/titanic/pet_control/pet_rooms_glyphs.cpp
engines/titanic/pet_control/pet_rooms_glyphs.h
engines/titanic/pet_control/pet_save.cpp
engines/titanic/pet_control/pet_save.h
engines/titanic/pet_control/pet_section.cpp
engines/titanic/pet_control/pet_section.h
engines/titanic/pet_control/pet_sound.cpp
engines/titanic/pet_control/pet_sound.h
engines/titanic/pet_control/pet_starfield.h
engines/titanic/pet_control/pet_translation.cpp
engines/titanic/pet_control/pet_translation.h
diff --git a/engines/titanic/continue_save_dialog.h b/engines/titanic/continue_save_dialog.h
index 58c7dee..b6d9aeb 100644
--- a/engines/titanic/continue_save_dialog.h
+++ b/engines/titanic/continue_save_dialog.h
@@ -28,7 +28,7 @@
#include "titanic/support/image.h"
#include "titanic/support/rect.h"
#include "titanic/support/string.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
@@ -43,7 +43,7 @@ class CContinueSaveDialog : public CEventTarget {
};
private:
Common::Array<SaveEntry> _saves;
- CPetText _slotNames[5];
+ CTextControl _slotNames[5];
int _highlightedSlot, _selectedSlot;
Point _mousePos;
bool _evilTwinShown;
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index b7cc688..a27584c 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -1081,7 +1081,7 @@ void CGameObject::setMovieFrameRate(double rate) {
void CGameObject::setText(const CString &str, int border, int borderRight) {
if (!_text)
- _text = new CPetText();
+ _text = new CTextControl();
_textBorder = border;
_textBorderRight = borderRight;
@@ -1093,7 +1093,7 @@ void CGameObject::setText(const CString &str, int border, int borderRight) {
void CGameObject::setTextHasBorders(bool hasBorders) {
if (!_text)
- _text = new CPetText();
+ _text = new CTextControl();
_text->setHasBorder(hasBorders);
}
@@ -1109,14 +1109,14 @@ void CGameObject::setTextBounds() {
void CGameObject::setTextColor(byte r, byte g, byte b) {
if (!_text)
- _text = new CPetText();
+ _text = new CTextControl();
_text->setColor(r, g, b);
}
void CGameObject::setTextFontNumber(int fontNumber) {
if (!_text)
- _text = new CPetText();
+ _text = new CTextControl();
_text->setFontNumber(fontNumber);
}
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 6671cbf..b367a0e 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -34,7 +34,7 @@
#include "titanic/support/strings.h"
#include "titanic/support/movie_clip.h"
#include "titanic/pet_control/pet_section.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
#include "titanic/game_state.h"
namespace Titanic {
@@ -87,7 +87,7 @@ protected:
int _initialFrame;
CMovieRangeInfoList _movieRangeInfoList;
int _frameNumber;
- CPetText *_text;
+ CTextControl *_text;
uint _textBorder;
uint _textBorderRight;
int _field9C;
diff --git a/engines/titanic/gfx/text_control.cpp b/engines/titanic/gfx/text_control.cpp
new file mode 100644
index 0000000..f731dbb
--- /dev/null
+++ b/engines/titanic/gfx/text_control.cpp
@@ -0,0 +1,491 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software(0), you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation(0), either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY(0), without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program(0), if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/gfx/text_control.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+CTextControl::CTextControl(uint count) :
+ _stringsMerged(false), _maxCharsPerLine(-1), _lineCount(0),
+ _displayEndCharIndex(-1), _unused1(0), _unused2(0), _unused3(0),
+ _backR(0xff), _backG(0xff), _backB(0xff),
+ _textR(0), _textG(0), _textB(200),
+ _fontNumber(0), _npcFlag(0), _npcId(0), _hasBorder(true),
+ _scrollTop(0), _textCursor(nullptr) {
+ setupArrays(count);
+}
+
+void CTextControl::setupArrays(int count) {
+ freeArrays();
+ if (count < 10 || count > 60)
+ count = 10;
+ _array.resize(count);
+}
+
+void CTextControl::freeArrays() {
+ _array.clear();
+}
+
+void CTextControl::setup() {
+ for (int idx = 0; idx < (int)_array.size(); ++idx) {
+ _array[idx]._line.clear();
+ setLineColor(idx, _textR, _textG, _textB);
+ _array[idx]._string3.clear();
+ }
+
+ _lineCount = 0;
+ _stringsMerged = false;
+}
+
+void CTextControl::setLineColor(uint lineNum, uint col) {
+ setLineColor(lineNum, col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff);
+}
+
+void CTextControl::setLineColor(uint lineNum, byte r, byte g, byte b) {
+ _array[lineNum]._rgb = getColorText(r, g, b);
+ _stringsMerged = false;
+}
+
+CString CTextControl::getColorText(byte r, byte g, byte b) {
+ char buffer[6];
+ if (!r)
+ r = 1;
+ if (!g)
+ g = 1;
+ if (!b)
+ b = 1;
+
+ buffer[0] = TEXTCMD_SET_COLOR;
+ buffer[1] = r;
+ buffer[2] = g;
+ buffer[3] = b;
+ buffer[4] = TEXTCMD_SET_COLOR;
+ buffer[5] = '\0';
+
+ return CString(buffer);
+}
+
+void CTextControl::load(SimpleFile *file, int param) {
+ if (!param) {
+ uint numLines = file->readNumber();
+ int charsPerLine = file->readNumber();
+ uint count = file->readNumber();
+ _bounds = file->readRect();
+ _unused1 = file->readNumber();
+ _unused2 = file->readNumber();
+ _unused3 = file->readNumber();
+ _backR = file->readNumber();
+ _backG = file->readNumber();
+ _backB = file->readNumber();
+ _textR = file->readNumber();
+ _textG = file->readNumber();
+ _textB = file->readNumber();
+ _hasBorder = file->readNumber() != 0;
+ _scrollTop = file->readNumber();
+
+ setMaxCharsPerLine(charsPerLine);
+ resize(numLines);
+ _lineCount = (count == 0) ? 0 : count - 1;
+
+ assert(_array.size() >= count);
+ for (uint idx = 0; idx < count; ++idx) {
+ _array[idx]._line = file->readString();
+ _array[idx]._rgb = file->readString();
+ _array[idx]._string3 = file->readString();
+ }
+ }
+}
+
+void CTextControl::save(SimpleFile *file, int indent) {
+ int numLines = _lineCount + 1;
+
+ file->writeNumberLine(_array.size(), indent);
+ file->writeNumberLine(_maxCharsPerLine, indent);
+ file->writeNumberLine(numLines, indent);
+
+ file->writeRect(_bounds, indent);
+ file->writeNumberLine(_unused1, indent);
+ file->writeNumberLine(_unused2, indent);
+ file->writeNumberLine(_unused3, indent);
+ file->writeNumberLine(_backR, indent);
+ file->writeNumberLine(_backG, indent);
+ file->writeNumberLine(_backB, indent);
+ file->writeNumberLine(_textR, indent);
+ file->writeNumberLine(_textG, indent);
+ file->writeNumberLine(_textB, indent);
+ file->writeNumberLine(_hasBorder, indent);
+ file->writeNumberLine(_scrollTop, indent);
+
+ for (int idx = 0; idx < numLines; ++idx) {
+ file->writeQuotedLine(_array[idx]._line, indent);
+ file->writeQuotedLine(_array[idx]._rgb, indent);
+ file->writeQuotedLine(_array[idx]._string3, indent);
+ }
+}
+
+void CTextControl::draw(CScreenManager *screenManager) {
+ Rect tempRect = _bounds;
+
+ if (_hasBorder) {
+ // Create border effect
+ // Top edge
+ tempRect.bottom = tempRect.top + 1;
+ screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
+
+ // Bottom edge
+ tempRect.top = _bounds.bottom - 1;
+ tempRect.bottom = _bounds.bottom;
+ screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
+
+ // Left edge
+ tempRect = _bounds;
+ tempRect.right = tempRect.left + 1;
+ screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
+
+ // Right edge
+ tempRect = _bounds;
+ tempRect.left = tempRect.right - 1;
+ screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
+ }
+
+ getTextHeight(screenManager);
+
+ tempRect = _bounds;
+ tempRect.grow(-2);
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+
+ _displayEndCharIndex = screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor);
+
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::mergeStrings() {
+ if (!_stringsMerged) {
+ _lines.clear();
+
+ for (int idx = 0; idx <= _lineCount; ++idx) {
+ CString line = _array[idx]._rgb + _array[idx]._string3 +
+ _array[idx]._line + "\n";
+ _lines += line;
+ }
+
+ _stringsMerged = true;
+ }
+}
+
+void CTextControl::resize(uint count) {
+ if (!count || _array.size() == count)
+ return;
+ _array.clear();
+ _array.resize(count);
+}
+
+CString CTextControl::getText() const {
+ CString result = "";
+ for (int idx = 0; idx <= _lineCount; ++idx)
+ result += _array[idx]._line;
+
+ return result;
+}
+
+void CTextControl::setText(const CString &str) {
+ setup();
+ appendText(str);
+}
+
+void CTextControl::setText(StringId stringId) {
+ setText(g_vm->_strings[stringId]);
+}
+
+void CTextControl::appendText(const CString &str) {
+ int lineSize = _array[_lineCount]._line.size();
+ int strSize = str.size();
+
+ if (_maxCharsPerLine == -1) {
+ // No limit on horizontal characters, so append string to current line
+ _array[_lineCount]._line += str;
+ } else if ((lineSize + strSize) <= _maxCharsPerLine) {
+ // New string fits into line, so add it on
+ _array[_lineCount]._line += str;
+ } else {
+ // Only add part of the str up to the maximum allowed limit for line
+ _array[_lineCount]._line += str.left(_maxCharsPerLine - lineSize);
+ }
+
+ updateStr3(_lineCount);
+ _stringsMerged = false;
+}
+
+void CTextControl::setColor(uint col) {
+ _textR = col & 0xff;
+ _textG = (col >> 8) & 0xff;
+ _textB = (col >> 16) & 0xff;
+}
+
+void CTextControl::setColor(byte r, byte g, byte b) {
+ _textR = r;
+ _textG = g;
+ _textB = b;
+}
+
+void CTextControl::remapColors(uint count, uint *srcColors, uint *destColors) {
+ for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) {
+ if (_array[lineNum]._rgb.empty())
+ continue;
+
+ // Get the rgb values
+ uint r = _array[lineNum]._rgb[1];
+ uint g = _array[lineNum]._rgb[2];
+ uint b = _array[lineNum]._rgb[3];
+ uint color = r | (g << 8) | (b << 16);
+
+ for (uint index = 0; index < count; ++index) {
+ if (color == srcColors[index]) {
+ // Found a match, so replace the color
+ setLineColor(lineNum, destColors[lineNum]);
+ break;
+ }
+ }
+ }
+
+ _stringsMerged = false;
+}
+
+void CTextControl::setMaxCharsPerLine(int maxChars) {
+ if (maxChars >= -1 && maxChars < 257)
+ _maxCharsPerLine = maxChars;
+}
+
+void CTextControl::updateStr3(int lineNum) {
+ if (_npcFlag > 0 && _npcId > 0) {
+ char line[5];
+ line[0] = line[3] = TEXTCMD_NPC;
+ line[1] = _npcFlag;
+ line[2] = _npcId;
+ line[4] = '\0';
+ _array[lineNum]._string3 = CString(line);
+
+ _stringsMerged = false;
+ _npcFlag = _npcId = 0;
+ }
+}
+
+int CTextControl::getTextWidth(CScreenManager *screenManager) {
+ mergeStrings();
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ int textWidth = screenManager->stringWidth(_lines);
+ screenManager->setFontNumber(oldFontNumber);
+
+ return textWidth;
+}
+
+int CTextControl::getTextHeight(CScreenManager *screenManager) {
+ mergeStrings();
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ int textHeight = screenManager->getTextBounds(_lines, _bounds.width() - 4);
+ screenManager->setFontNumber(oldFontNumber);
+
+ return textHeight;
+}
+
+void CTextControl::deleteLastChar() {
+ if (!_array[_lineCount]._line.empty()) {
+ _array[_lineCount]._line.deleteLastChar();
+ _stringsMerged = false;
+ }
+}
+
+void CTextControl::setNPC(int npcFlag, int npcId) {
+ _npcFlag = npcFlag;
+ _npcId = npcId;
+}
+
+void CTextControl::scrollUp(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ _scrollTop -= screenManager->getFontHeight();
+ constrainScrollUp(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::scrollDown(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ _scrollTop += screenManager->getFontHeight();
+ constrainScrollDown(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::scrollUpPage(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ _scrollTop -= getPageHeight(screenManager);
+ constrainScrollUp(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::scrollDownPage(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ _scrollTop += getPageHeight(screenManager);
+ constrainScrollDown(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::scrollToTop(CScreenManager *screenManager) {
+ _scrollTop = 0;
+}
+
+void CTextControl::scrollToBottom(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ _scrollTop = getTextHeight(screenManager);
+ constrainScrollDown(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CTextControl::constrainScrollUp(CScreenManager *screenManager) {
+ if (_scrollTop < 0)
+ _scrollTop = 0;
+}
+
+void CTextControl::constrainScrollDown(CScreenManager *screenManager) {
+ // Figure out the maximum scroll amount allowed
+ int maxScroll = getTextHeight(screenManager) - _bounds.height() - 4;
+ if (maxScroll < 0)
+ maxScroll = 0;
+
+ if (_scrollTop > maxScroll)
+ _scrollTop = maxScroll;
+}
+
+int CTextControl::getPageHeight(CScreenManager *screenManager) {
+ int textHeight = _bounds.height();
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber);
+ int fontHeight = screenManager->getFontHeight();
+ screenManager->setFontNumber(oldFontNumber);
+
+ if (fontHeight) {
+ int lines = textHeight / fontHeight;
+ if (lines > 1)
+ --lines;
+ return lines * fontHeight;
+ } else {
+ return 0;
+ }
+}
+
+void CTextControl::addLine(const CString &str) {
+ addLine(str, _textR, _textG, _textB);
+}
+
+void CTextControl::addLine(const CString &str, uint color) {
+ addLine(str, color & 0xff, (color >> 8) & 0xff,
+ (color >> 16) & 0xff);
+}
+
+void CTextControl::addLine(const CString &str, byte r, byte g, byte b) {
+ if (_lineCount == ((int)_array.size() - 1)) {
+ // Lines array is full
+ if (_array.size() > 1) {
+ // Delete the oldest line, and add a new entry at the end
+ _array.remove_at(0);
+ _array.resize(_array.size() + 1);
+ }
+
+ --_lineCount;
+ }
+
+ setLineColor(_lineCount, r, g, b);
+ appendText(str);
+ ++_lineCount;
+}
+
+bool CTextControl::handleKey(char c) {
+ switch (c) {
+ case (char)Common::KEYCODE_BACKSPACE:
+ deleteLastChar();
+ break;
+
+ case (char)Common::KEYCODE_RETURN:
+ return true;
+
+ default:
+ if ((byte)c >= 32 && (byte)c <= 127)
+ appendText(CString(c, 1));
+ break;
+ }
+
+ return false;
+}
+
+void CTextControl::showCursor(int mode) {
+ CScreenManager *screenManager = CScreenManager::setCurrent();
+ _textCursor = screenManager->_textCursor;
+ if (_textCursor) {
+ _textCursor->setPos(Point(0, 0));
+ _textCursor->setSize(Point(2, 10));
+ _textCursor->setColor(0, 0, 0);
+ _textCursor->setBlinkRate(300);
+ _textCursor->setMode(mode);
+ _textCursor->setBounds(_bounds);
+ _textCursor->show();
+ }
+}
+
+void CTextControl::hideCursor() {
+ if (_textCursor) {
+ _textCursor->setMode(-1);
+ _textCursor->hide();
+ _textCursor = nullptr;
+ }
+}
+
+int CTextControl::getNPCNum(uint ident, uint startIndex) {
+ if (!_stringsMerged) {
+ mergeStrings();
+ if (!_stringsMerged)
+ return -1;
+ }
+
+ uint size = _lines.size();
+ if (startIndex < 5 || startIndex >= size)
+ return -1;
+
+ // Loop backwards from the starting index to find an NPC ident sequence
+ for (const char *strP = _lines.c_str() + startIndex;
+ strP >= (_lines.c_str() + 5); --strP) {
+ if (*strP == 26) {
+ byte id = *(strP - 2);
+ if (id == ident)
+ return *(strP - 1);
+ strP -= 3;
+ } else if (*strP == 27) {
+ strP -= 4;
+ }
+ }
+
+ return -1;
+}
+
+void CTextControl::setFontNumber(int fontNumber) {
+ if (fontNumber >= 0 && fontNumber <= 2)
+ _fontNumber = fontNumber;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/gfx/text_control.h b/engines/titanic/gfx/text_control.h
new file mode 100644
index 0000000..d4ef19a
--- /dev/null
+++ b/engines/titanic/gfx/text_control.h
@@ -0,0 +1,285 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_TEXT_CONTROL_H
+#define TITANIC_TEXT_CONTROL_H
+
+#include "common/keyboard.h"
+#include "titanic/support/simple_file.h"
+#include "titanic/support/screen_manager.h"
+#include "titanic/support/text_cursor.h"
+
+namespace Titanic {
+
+class CTextControl {
+ struct ArrayEntry {
+ CString _line;
+ CString _rgb;
+ CString _string3;
+ };
+private:
+ Common::Array<ArrayEntry> _array;
+ CString _lines;
+ bool _stringsMerged;
+ Rect _bounds;
+ int _maxCharsPerLine;
+ int _lineCount;
+ int _displayEndCharIndex;
+ int _unused1;
+ int _unused2;
+ int _unused3;
+ int _backR;
+ int _backG;
+ int _backB;
+ int _textR;
+ int _textG;
+ int _textB;
+ int _fontNumber;
+ int _npcFlag;
+ int _npcId;
+ bool _hasBorder;
+ int _scrollTop;
+ CTextCursor *_textCursor;
+private:
+ void setupArrays(int count);
+
+ void freeArrays();
+
+ /**
+ * Merges the strings in the strings array
+ */
+ void mergeStrings();
+
+ /**
+ * Append text to the current text line
+ */
+ void appendText(const CString &str);
+
+ void updateStr3(int lineNum);
+
+ /**
+ * Ensures the Y scrolling for the text is in the valid range
+ */
+ void constrainScrollUp(CScreenManager *screenManager);
+
+ /**
+ * Ensures the Y scrolling for the text is in the valid range
+ */
+ void constrainScrollDown(CScreenManager *screenManager);
+
+ /**
+ * Get the page height for paging up and down
+ */
+ int getPageHeight(CScreenManager *screenManager);
+public:
+ CTextControl(uint count = 10);
+
+ /**
+ * Set up the control
+ */
+ void setup();
+
+ /**
+ * Load the data for the control
+ */
+ void load(SimpleFile *file, int param);
+
+ /**
+ * Save the data for the control
+ */
+ void save(SimpleFile *file, int indent);
+
+ /**
+ * Set the bounds for the control
+ */
+ void setBounds(const Rect &bounds) { _bounds = bounds; }
+
+ /**
+ * Sets the flag for whether to draw a frame border around the control
+ */
+ void setHasBorder(bool val) { _hasBorder = val; }
+
+ /**
+ * Draw the control
+ */
+ void draw(CScreenManager *screenManager);
+
+ void resize(uint count);
+
+ /**
+ * Returns the text from all the lines as a single string
+ */
+ CString getText() const;
+
+ /**
+ * Set the text
+ */
+ void setText(const CString &str);
+
+ /**
+ * Set the text
+ */
+ void setText(StringId stringId);
+
+ /**
+ * Set text color
+ */
+ void setColor(uint col);
+
+ /**
+ * Set text color
+ */
+ void setColor(byte r, byte g, byte b);
+
+ /**
+ * Set the color for a line
+ */
+ void setLineColor(uint lineNum, byte r, byte g, byte b);
+
+ /**
+ * Gets the text string representing a color encoding
+ */
+ static CString getColorText(byte r, byte g, byte b);
+
+ /**
+ * Set the color for a line
+ */
+ void setLineColor(uint lineNum, uint col);
+
+ /**
+ * Sets the maximum number of characters per line
+ */
+ void setMaxCharsPerLine(int maxChars);
+
+ /**
+ * Delete the last character from the last line
+ */
+ void deleteLastChar();
+
+ /**
+ * Sets the current NPC text is being added for
+ */
+ void setNPC(int npcFlag, int npcId);
+
+ /**
+ * Returns the character index into _lines of the last
+ * character to be displayed on-screen
+ */
+ int displayEndIndex() const { return _displayEndCharIndex; }
+
+ /**
+ * Scroll the text up
+ */
+ void scrollUp(CScreenManager *screenManager);
+
+ /**
+ * Scroll the text down
+ */
+ void scrollDown(CScreenManager *screenManager);
+
+ /**
+ * Scroll the text up one page
+ */
+ void scrollUpPage(CScreenManager *screenManager);
+
+ /**
+ * Scroll the text down one page
+ */
+ void scrollDownPage(CScreenManager *screenManager);
+
+ /**
+ * Scroll to the top of the text
+ */
+ void scrollToTop(CScreenManager *screenManager);
+
+ /**
+ * Scroll to the bottom of the text
+ */
+ void scrollToBottom(CScreenManager *screenManager);
+
+ /**
+ * Add a line to the text
+ */
+ void addLine(const CString &str);
+
+ /**
+ * Add a line to the text
+ */
+ void addLine(const CString &str, uint color);
+
+ /**
+ * Add a line to the text
+ */
+ void addLine(const CString &str, byte r, byte g, byte b);
+
+ /**
+ * Handles character processing to add or remove characters to
+ * the current text line
+ * @returns True if the Enter key was pressed
+ */
+ bool handleKey(char c);
+
+ /**
+ * Attaches the current system cursor to the text control,
+ * and give it suitable defaults
+ */
+ void showCursor(int mode);
+
+ /**
+ * Removes the cursor attached to the text
+ */
+ void hideCursor();
+
+ /**
+ * Get an NPC Number embedded within on-screen text.
+ * Used by the PET log to encode which NPC spoke
+ * @param ident Npc Type. Always passed as 1
+ * @param startIndex Starting index to scan backwards
+ * through the log text to find an NPC ident sequence
+ */
+ int getNPCNum(uint ident, uint startIndex);
+
+ /**
+ * Replaces any occurances of line colors that appear in the
+ * first list with the entry at the same index in the dest list
+ */
+ void remapColors(uint count, uint *srcColors, uint *destColors);
+
+ /**
+ * Set the font number to use
+ */
+ void setFontNumber(int fontNumber);
+
+ /**
+ * Get the width of the text
+ */
+ int getTextWidth(CScreenManager *screenManager);
+
+ /**
+ * Get the required height to draw the text
+ */
+ int getTextHeight(CScreenManager *screenManager);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TEXT_CONTROL_H */
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index e802456..51c77ba 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -280,6 +280,7 @@ MODULE_OBJS := \
gfx/chev_right_on.o \
gfx/chev_send_rec_switch.o \
gfx/edit_control.o \
+ gfx/text_control.o \
gfx/elevator_button.o \
gfx/get_from_succ.o \
gfx/helmet_on_off.o \
@@ -398,7 +399,6 @@ MODULE_OBJS := \
pet_control/pet_show_translation.o \
pet_control/pet_slider.o \
pet_control/pet_sound.o \
- pet_control/pet_text.o \
sound/auto_music_player.o \
sound/auto_music_player_base.o \
sound/auto_sound_player.o \
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index c3508f6..37d216e 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -24,7 +24,7 @@
#define TITANIC_PET_CONVERSATIONS_H
#include "titanic/pet_control/pet_section.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
#include "titanic/pet_control/pet_gfx_element.h"
#include "titanic/true_talk/true_talk_manager.h"
@@ -48,8 +48,8 @@ private:
CPetGfxElement _splitter;
CPetGfxElement _npcIcons[9];
int _npcNum;
- CPetText _log;
- CPetText _textInput;
+ CTextControl _log;
+ CTextControl _textInput;
bool _logChanged;
int _field418;
CString _npcName;
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp
index ed04381..b42b871 100644
--- a/engines/titanic/pet_control/pet_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_glyphs.cpp
@@ -39,7 +39,7 @@ void CPetGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHi
}
void CPetGlyph::updateTooltip() {
- CPetText *petText = getPetSection()->getText();
+ CTextControl *petText = getPetSection()->getText();
if (petText) {
petText->setColor(getPetSection()->getColor(0));
getTooltip(petText);
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index ac008c5..6229d17 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -35,7 +35,7 @@ namespace Titanic {
class CPetGlyphs;
class CPetSection;
-class CPetText;
+class CTextControl;
enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 };
@@ -177,7 +177,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text) {}
+ virtual void getTooltip(CTextControl *text) {}
/**
* Saves the data for the glyph
diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h
index 7710ee0..7efc075 100644
--- a/engines/titanic/pet_control/pet_inventory.h
+++ b/engines/titanic/pet_control/pet_inventory.h
@@ -26,7 +26,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_inventory_glyphs.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
@@ -35,7 +35,7 @@ namespace Titanic {
*/
class CPetInventory : public CPetSection {
private:
- CPetText _text;
+ CTextControl _text;
CPetInventoryGlyphs _items;
CGameObject *_itemBackgrounds[46];
CGameObject *_itemGlyphs[46];
@@ -134,7 +134,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText() { return &_text; }
+ virtual CTextControl *getText() { return &_text; }
/**
* Special retrieval of glyph background image
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index 74d769a..9d745d8 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -143,7 +143,7 @@ bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg
}
}
-void CPetInventoryGlyph::getTooltip(CPetText *text) {
+void CPetInventoryGlyph::getTooltip(CTextControl *text) {
if (text) {
text->setText("");
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h
index 508db67..e843cf5 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.h
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.h
@@ -106,7 +106,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
/**
* Return whether the glyph is currently valid
diff --git a/engines/titanic/pet_control/pet_load.cpp b/engines/titanic/pet_control/pet_load.cpp
index 3d67cf6..81ea858 100644
--- a/engines/titanic/pet_control/pet_load.cpp
+++ b/engines/titanic/pet_control/pet_load.cpp
@@ -50,7 +50,7 @@ bool CPetLoad::MouseButtonUpMsg(const Point &pt) {
}
}
-void CPetLoad::getTooltip(CPetText *text) {
+void CPetLoad::getTooltip(CTextControl *text) {
text->setText("Load the game.");
}
diff --git a/engines/titanic/pet_control/pet_load.h b/engines/titanic/pet_control/pet_load.h
index 5669991..103477a 100644
--- a/engines/titanic/pet_control/pet_load.h
+++ b/engines/titanic/pet_control/pet_load.h
@@ -47,7 +47,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
/**
* Highlights a save slot
diff --git a/engines/titanic/pet_control/pet_load_save.h b/engines/titanic/pet_control/pet_load_save.h
index 26ddec0..5bdb2b5 100644
--- a/engines/titanic/pet_control/pet_load_save.h
+++ b/engines/titanic/pet_control/pet_load_save.h
@@ -24,7 +24,7 @@
#define TITANIC_PET_LOAD_SAVE_H
#include "titanic/pet_control/pet_glyphs.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
@@ -52,7 +52,7 @@ private:
*/
bool isSlotHighlighted(int index, const Point &pt);
protected:
- CPetText _slotNames[SAVEGAME_SLOTS_COUNT];
+ CTextControl _slotNames[SAVEGAME_SLOTS_COUNT];
bool _slotInUse[SAVEGAME_SLOTS_COUNT];
CPetGfxElement _btnLoadSave;
CPetGfxElement _gutter;
diff --git a/engines/titanic/pet_control/pet_quit.cpp b/engines/titanic/pet_control/pet_quit.cpp
index a6fb22d..0d94474 100644
--- a/engines/titanic/pet_control/pet_quit.cpp
+++ b/engines/titanic/pet_control/pet_quit.cpp
@@ -83,7 +83,7 @@ bool CPetQuit::MouseButtonUpMsg(const Point &pt) {
}
}
-void CPetQuit::getTooltip(CPetText *text) {
+void CPetQuit::getTooltip(CTextControl *text) {
text->setText("Quit the game.");
}
diff --git a/engines/titanic/pet_control/pet_quit.h b/engines/titanic/pet_control/pet_quit.h
index b775000..7eeedaf 100644
--- a/engines/titanic/pet_control/pet_quit.h
+++ b/engines/titanic/pet_control/pet_quit.h
@@ -25,13 +25,13 @@
#include "titanic/pet_control/pet_gfx_element.h"
#include "titanic/pet_control/pet_glyphs.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
class CPetQuit : public CPetGlyph {
private:
- CPetText _text;
+ CTextControl _text;
CPetGfxElement _btnYes;
public:
/**
@@ -62,12 +62,12 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText() { return &_text; }
+ virtual CTextControl *getText() { return &_text; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_real_life.h b/engines/titanic/pet_control/pet_real_life.h
index 7c7101a..294f9a3 100644
--- a/engines/titanic/pet_control/pet_real_life.h
+++ b/engines/titanic/pet_control/pet_real_life.h
@@ -25,7 +25,7 @@
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_glyphs.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
@@ -35,7 +35,7 @@ class CPetSaveGlyphs : public CPetGlyphs {
class CPetRealLife : public CPetSection {
private:
CPetGlyphs _glyphs;
- CPetText _text;
+ CTextControl _text;
private:
/**
* Does setup
@@ -124,7 +124,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText() { return &_text; }
+ virtual CTextControl *getText() { return &_text; }
};
diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp
index 3f00ce5..0293ec9 100644
--- a/engines/titanic/pet_control/pet_remote.cpp
+++ b/engines/titanic/pet_control/pet_remote.cpp
@@ -202,7 +202,7 @@ void CPetRemote::enterRoom(CRoomItem *room) {
}
}
-CPetText *CPetRemote::getText() {
+CTextControl *CPetRemote::getText() {
return &_text;
}
diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h
index 9cd9c1e..008c645 100644
--- a/engines/titanic/pet_control/pet_remote.h
+++ b/engines/titanic/pet_control/pet_remote.h
@@ -27,7 +27,7 @@
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/pet_control/pet_remote_glyphs.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
@@ -45,7 +45,7 @@ private:
CPetGfxElement _send;
CPetGfxElement _receive;
CPetGfxElement _call;
- CPetText _text;
+ CTextControl _text;
private:
/**
* Setup the control
@@ -137,7 +137,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText();
+ virtual CTextControl *getText();
/**
* Get an element from the section by a designated Id
diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp
index f0e71d3..7f52ca7 100644
--- a/engines/titanic/pet_control/pet_remote_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp
@@ -81,7 +81,7 @@ bool CBasicRemoteGlyph::MouseButtonUpMsg(const Point &pt) {
return false;
}
-void CBasicRemoteGlyph::getTooltip(CPetText *text) {
+void CBasicRemoteGlyph::getTooltip(CTextControl *text) {
text->setText(_tooltip);
}
@@ -160,7 +160,7 @@ bool CRemoteGotoGlyph::MouseButtonUpMsg(const Point &pt) {
return true;
}
-void CRemoteGotoGlyph::getTooltip(CPetText *text) {
+void CRemoteGotoGlyph::getTooltip(CTextControl *text) {
text->setText(_tooltip);
}
@@ -216,7 +216,7 @@ bool CTelevisionControlGlyph::MouseButtonUpMsg(const Point &pt) {
return false;
}
-void CTelevisionControlGlyph::getTooltip(CPetText *text) {
+void CTelevisionControlGlyph::getTooltip(CTextControl *text) {
text->setText(TELEVISION_CONTROL);
}
@@ -280,7 +280,7 @@ bool CEntertainmentDeviceGlyph::MouseButtonUpMsg(const Point &pt) {
return false;
}
-void CEntertainmentDeviceGlyph::getTooltip(CPetText *text) {
+void CEntertainmentDeviceGlyph::getTooltip(CTextControl *text) {
text->setText(OPERATE_ENTERTAINMENT);
}
@@ -334,7 +334,7 @@ bool COperateLightsGlyph::MouseButtonUpMsg(const Point &pt) {
return true;
}
-void COperateLightsGlyph::getTooltip(CPetText *text) {
+void COperateLightsGlyph::getTooltip(CTextControl *text) {
text->setText(OPERATE_LIGHTS);
}
@@ -346,7 +346,7 @@ bool CDeployFloralGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
return true;
}
-void CDeployFloralGlyph::getTooltip(CPetText *text) {
+void CDeployFloralGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_FLORAL_ENHANCEMENT);
}
@@ -359,7 +359,7 @@ bool CDeployFullyRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *own
return true;
}
-void CDeployFullyRelaxationGlyph::getTooltip(CPetText *text) {
+void CDeployFullyRelaxationGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_FULLY_RELAXATION);
}
@@ -371,7 +371,7 @@ bool CDeployComfortGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
return true;
}
-void CDeployComfortGlyph::getTooltip(CPetText *text) {
+void CDeployComfortGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_COMFORT_WORKSTATION);
}
@@ -383,7 +383,7 @@ bool CDeployMinorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner)
return true;
}
-void CDeployMinorStorageGlyph::getTooltip(CPetText *text) {
+void CDeployMinorStorageGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_MINOR_STORAGE);
}
@@ -395,7 +395,7 @@ bool CDeployMajorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *own
return true;
}
-void CDeployMajorRelaxationGlyph::getTooltip(CPetText *text) {
+void CDeployMajorRelaxationGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_MAJOR_RELAXATION);
}
@@ -407,7 +407,7 @@ bool CInflateRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner)
return true;
}
-void CInflateRelaxationGlyph::getTooltip(CPetText *text) {
+void CInflateRelaxationGlyph::getTooltip(CTextControl *text) {
text->setText(INFLATE_RELAXATION_DEVICE);
}
@@ -419,7 +419,7 @@ bool CDeployMaintenanceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner)
return true;
}
-void CDeployMaintenanceGlyph::getTooltip(CPetText *text) {
+void CDeployMaintenanceGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_MAINTENANCE_HUB);
}
@@ -431,7 +431,7 @@ bool CDeployWorkSurfaceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner)
return true;
}
-void CDeployWorkSurfaceGlyph::getTooltip(CPetText *text) {
+void CDeployWorkSurfaceGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_EXECUTIVE_SURFACE);
}
@@ -443,7 +443,7 @@ bool CDeployMinorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *own
return true;
}
-void CDeployMinorRelaxationGlyph::getTooltip(CPetText *text) {
+void CDeployMinorRelaxationGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_MINOR_RELAXATION);
}
@@ -455,7 +455,7 @@ bool CDeploySinkGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) {
return true;
}
-void CDeploySinkGlyph::getTooltip(CPetText *text) {
+void CDeploySinkGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_SINK);
}
@@ -467,7 +467,7 @@ bool CDeployMajorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner)
return true;
}
-void CDeployMajorStorageGlyph::getTooltip(CPetText *text) {
+void CDeployMajorStorageGlyph::getTooltip(CTextControl *text) {
text->setText(DEPLOY_MAJOR_STORAGE);
}
@@ -515,7 +515,7 @@ bool CSuccubusDeliveryGlyph::MouseButtonUpMsg(const Point &pt) {
return true;
}
-void CSuccubusDeliveryGlyph::getTooltip(CPetText *text) {
+void CSuccubusDeliveryGlyph::getTooltip(CTextControl *text) {
text->setText(SUCCUBUS_DELIVERY_SYSTEM);
}
@@ -554,7 +554,7 @@ bool CNavigationControllerGlyph::MouseButtonUpMsg(const Point &pt) {
return true;
}
-void CNavigationControllerGlyph::getTooltip(CPetText *text) {
+void CNavigationControllerGlyph::getTooltip(CTextControl *text) {
text->setText(NAVIGATION_CONTROLLER);
}
diff --git a/engines/titanic/pet_control/pet_remote_glyphs.h b/engines/titanic/pet_control/pet_remote_glyphs.h
index 691a70f..0a035ec 100644
--- a/engines/titanic/pet_control/pet_remote_glyphs.h
+++ b/engines/titanic/pet_control/pet_remote_glyphs.h
@@ -116,7 +116,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CToggleRemoteGlyph : public CPetRemoteGlyph {
@@ -181,7 +181,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CSummonElevatorGlyph : public CBasicRemoteGlyph {
@@ -225,7 +225,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CEntertainmentDeviceGlyph : public CToggleRemoteGlyph {
@@ -259,7 +259,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
@@ -293,7 +293,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployFloralGlyph : public CToggleRemoteGlyph {
@@ -320,7 +320,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployFullyRelaxationGlyph : public CToggleRemoteGlyph {
@@ -347,7 +347,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployComfortGlyph : public CToggleRemoteGlyph {
@@ -374,7 +374,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployMinorStorageGlyph : public CToggleRemoteGlyph {
@@ -401,7 +401,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployMajorRelaxationGlyph : public CToggleRemoteGlyph {
@@ -428,7 +428,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CInflateRelaxationGlyph : public CToggleRemoteGlyph {
@@ -455,7 +455,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployMaintenanceGlyph : public CToggleRemoteGlyph {
@@ -482,7 +482,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployWorkSurfaceGlyph : public CToggleRemoteGlyph {
@@ -509,7 +509,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployMinorRelaxationGlyph : public CToggleRemoteGlyph {
@@ -536,7 +536,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeploySinkGlyph : public CToggleRemoteGlyph {
@@ -563,7 +563,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CDeployMajorStorageGlyph : public CToggleRemoteGlyph {
@@ -590,7 +590,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CSuccubusDeliveryGlyph : public CPetRemoteGlyph {
@@ -623,7 +623,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CNavigationControllerGlyph : public CPetRemoteGlyph {
@@ -657,7 +657,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
class CGotoBottomOfWellGlyph : public CRemoteGotoGlyph {
diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp
index c00a7ca..88d9df1 100644
--- a/engines/titanic/pet_control/pet_rooms.cpp
+++ b/engines/titanic/pet_control/pet_rooms.cpp
@@ -170,7 +170,7 @@ void CPetRooms::enterRoom(CRoomItem *room) {
resetHighlight();
}
-CPetText *CPetRooms::getText() {
+CTextControl *CPetRooms::getText() {
return &_text;
}
diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h
index 19c97c0..6b71359 100644
--- a/engines/titanic/pet_control/pet_rooms.h
+++ b/engines/titanic/pet_control/pet_rooms.h
@@ -24,7 +24,7 @@
#define TITANIC_PET_ROOMS_H
#include "titanic/pet_control/pet_section.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
#include "titanic/pet_control/pet_rooms_glyphs.h"
#include "titanic/game_location.h"
@@ -43,7 +43,7 @@ private:
CGameObject *_chevRightOnLit;
CGameObject *_chevRightOffLit;
CPetGfxElement _plinth;
- CPetText _text;
+ CTextControl _text;
int _floorNum;
int _elevatorNum;
int _roomNum;
@@ -141,7 +141,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText();
+ virtual CTextControl *getText();
/**
* Special retrieval of glyph background image
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
index 2197713..a69704c 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
@@ -141,7 +141,7 @@ bool CPetRoomsGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) {
return false;
}
-void CPetRoomsGlyph::getTooltip(CPetText *text) {
+void CPetRoomsGlyph::getTooltip(CTextControl *text) {
CRoomFlags roomFlags(_roomFlags);
CPetRooms *owner = static_cast<CPetRooms *>(getPetSection());
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h
index 6c51b6f..3a43bdc 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.h
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.h
@@ -89,7 +89,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
/**
* Saves the data for the glyph
diff --git a/engines/titanic/pet_control/pet_save.cpp b/engines/titanic/pet_control/pet_save.cpp
index 60afa11..00dbfa6 100644
--- a/engines/titanic/pet_control/pet_save.cpp
+++ b/engines/titanic/pet_control/pet_save.cpp
@@ -64,7 +64,7 @@ void CPetSave::highlightCurrent(const Point &pt) {
highlightSave(_savegameSlotNum);
}
-void CPetSave::getTooltip(CPetText *text) {
+void CPetSave::getTooltip(CTextControl *text) {
text->setText("Save the game.");
}
diff --git a/engines/titanic/pet_control/pet_save.h b/engines/titanic/pet_control/pet_save.h
index 39a25eb..9b3c115 100644
--- a/engines/titanic/pet_control/pet_save.h
+++ b/engines/titanic/pet_control/pet_save.h
@@ -57,7 +57,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
/**
* Called on a highlighted item when PET area is entered
diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp
index aced697..2c2238e 100644
--- a/engines/titanic/pet_control/pet_section.cpp
+++ b/engines/titanic/pet_control/pet_section.cpp
@@ -39,7 +39,7 @@ static const uint PALETTE3[5] = {
};
void CPetSection::displayMessage(const CString &msg) {
- CPetText *text = getText();
+ CTextControl *text = getText();
if (text) {
text->setColor(getColor(1));
@@ -64,7 +64,7 @@ void CPetSection::removeText(int duration) {
}
void CPetSection::removeText() {
- CPetText *text = getText();
+ CTextControl *text = getText();
if (text)
text->setup();
}
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index c68aa90..e245d51 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -35,7 +35,7 @@ enum PetArea {
class CPetControl;
class CPetElement;
-class CPetText;
+class CTextControl;
class CScreenManager;
class CRoomItem;
@@ -170,7 +170,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText() { return nullptr; }
+ virtual CTextControl *getText() { return nullptr; }
/**
* Removes text after a given duration
diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp
index e9958c6..f4d4503 100644
--- a/engines/titanic/pet_control/pet_sound.cpp
+++ b/engines/titanic/pet_control/pet_sound.cpp
@@ -275,7 +275,7 @@ bool CPetSound::MouseButtonUpMsg(const Point &pt) {
return true;
}
-void CPetSound::getTooltip(CPetText *text) {
+void CPetSound::getTooltip(CTextControl *text) {
text->setText("Change the volume settings.");
}
diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h
index c4b663a..fed4f43 100644
--- a/engines/titanic/pet_control/pet_sound.h
+++ b/engines/titanic/pet_control/pet_sound.h
@@ -25,7 +25,7 @@
#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/pet_control/pet_gfx_element.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
#include "titanic/pet_control/pet_slider.h"
namespace Titanic {
@@ -39,10 +39,10 @@ private:
CPetSlider _musicVolume;
CPetSlider _parrotVolume;
CPetSlider _speechVolume;
- CPetText _textMasterVolume;
- CPetText _textMusicVolume;
- CPetText _textParrotVolume;
- CPetText _textSpeechVolume;
+ CTextControl _textMasterVolume;
+ CTextControl _textMusicVolume;
+ CTextControl _textParrotVolume;
+ CTextControl _textSpeechVolume;
CPetSlider *_draggingSlider;
int _draggingSliderNum;
private:
@@ -96,7 +96,7 @@ public:
/**
* Returns the tooltip text for when the glyph is selected
*/
- virtual void getTooltip(CPetText *text);
+ virtual void getTooltip(CTextControl *text);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_starfield.h b/engines/titanic/pet_control/pet_starfield.h
index 6c47f47..ec96fb9 100644
--- a/engines/titanic/pet_control/pet_starfield.h
+++ b/engines/titanic/pet_control/pet_starfield.h
@@ -24,7 +24,7 @@
#define TITANIC_PET_STARFIELD_H
#include "titanic/pet_control/pet_section.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
#include "titanic/pet_control/pet_gfx_element.h"
namespace Titanic {
@@ -39,7 +39,7 @@ private:
CPetGfxElement _leds[6];
Rect _rect1;
int _field18C;
- CPetText _text;
+ CTextControl _text;
bool _photoOn;
bool _hasReference;
private:
diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp
deleted file mode 100644
index 05038d2..0000000
--- a/engines/titanic/pet_control/pet_text.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software(0), you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation(0), either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY(0), without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program(0), if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "titanic/pet_control/pet_text.h"
-#include "titanic/titanic.h"
-
-namespace Titanic {
-
-CPetText::CPetText(uint count) :
- _stringsMerged(false), _maxCharsPerLine(-1), _lineCount(0),
- _displayEndCharIndex(-1), _unused1(0), _unused2(0), _unused3(0),
- _backR(0xff), _backG(0xff), _backB(0xff),
- _textR(0), _textG(0), _textB(200),
- _fontNumber(0), _npcFlag(0), _npcId(0), _hasBorder(true),
- _scrollTop(0), _textCursor(nullptr) {
- setupArrays(count);
-}
-
-void CPetText::setupArrays(int count) {
- freeArrays();
- if (count < 10 || count > 60)
- count = 10;
- _array.resize(count);
-}
-
-void CPetText::freeArrays() {
- _array.clear();
-}
-
-void CPetText::setup() {
- for (int idx = 0; idx < (int)_array.size(); ++idx) {
- _array[idx]._line.clear();
- setLineColor(idx, _textR, _textG, _textB);
- _array[idx]._string3.clear();
- }
-
- _lineCount = 0;
- _stringsMerged = false;
-}
-
-void CPetText::setLineColor(uint lineNum, uint col) {
- setLineColor(lineNum, col & 0xff, (col >> 8) & 0xff, (col >> 16) & 0xff);
-}
-
-void CPetText::setLineColor(uint lineNum, byte r, byte g, byte b) {
- _array[lineNum]._rgb = getColorText(r, g, b);
- _stringsMerged = false;
-}
-
-CString CPetText::getColorText(byte r, byte g, byte b) {
- char buffer[6];
- if (!r)
- r = 1;
- if (!g)
- g = 1;
- if (!b)
- b = 1;
-
- buffer[0] = TEXTCMD_SET_COLOR;
- buffer[1] = r;
- buffer[2] = g;
- buffer[3] = b;
- buffer[4] = TEXTCMD_SET_COLOR;
- buffer[5] = '\0';
-
- return CString(buffer);
-}
-
-void CPetText::load(SimpleFile *file, int param) {
- if (!param) {
- uint numLines = file->readNumber();
- int charsPerLine = file->readNumber();
- uint count = file->readNumber();
- _bounds = file->readRect();
- _unused1 = file->readNumber();
- _unused2 = file->readNumber();
- _unused3 = file->readNumber();
- _backR = file->readNumber();
- _backG = file->readNumber();
- _backB = file->readNumber();
- _textR = file->readNumber();
- _textG = file->readNumber();
- _textB = file->readNumber();
- _hasBorder = file->readNumber() != 0;
- _scrollTop = file->readNumber();
-
- setMaxCharsPerLine(charsPerLine);
- resize(numLines);
- _lineCount = (count == 0) ? 0 : count - 1;
-
- assert(_array.size() >= count);
- for (uint idx = 0; idx < count; ++idx) {
- _array[idx]._line = file->readString();
- _array[idx]._rgb = file->readString();
- _array[idx]._string3 = file->readString();
- }
- }
-}
-
-void CPetText::save(SimpleFile *file, int indent) {
- int numLines = _lineCount + 1;
-
- file->writeNumberLine(_array.size(), indent);
- file->writeNumberLine(_maxCharsPerLine, indent);
- file->writeNumberLine(numLines, indent);
-
- file->writeRect(_bounds, indent);
- file->writeNumberLine(_unused1, indent);
- file->writeNumberLine(_unused2, indent);
- file->writeNumberLine(_unused3, indent);
- file->writeNumberLine(_backR, indent);
- file->writeNumberLine(_backG, indent);
- file->writeNumberLine(_backB, indent);
- file->writeNumberLine(_textR, indent);
- file->writeNumberLine(_textG, indent);
- file->writeNumberLine(_textB, indent);
- file->writeNumberLine(_hasBorder, indent);
- file->writeNumberLine(_scrollTop, indent);
-
- for (int idx = 0; idx < numLines; ++idx) {
- file->writeQuotedLine(_array[idx]._line, indent);
- file->writeQuotedLine(_array[idx]._rgb, indent);
- file->writeQuotedLine(_array[idx]._string3, indent);
- }
-}
-
-void CPetText::draw(CScreenManager *screenManager) {
- Rect tempRect = _bounds;
-
- if (_hasBorder) {
- // Create border effect
- // Top edge
- tempRect.bottom = tempRect.top + 1;
- screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
-
- // Bottom edge
- tempRect.top = _bounds.bottom - 1;
- tempRect.bottom = _bounds.bottom;
- screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
-
- // Left edge
- tempRect = _bounds;
- tempRect.right = tempRect.left + 1;
- screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
-
- // Right edge
- tempRect = _bounds;
- tempRect.left = tempRect.right - 1;
- screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB);
- }
-
- getTextHeight(screenManager);
-
- tempRect = _bounds;
- tempRect.grow(-2);
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
-
- _displayEndCharIndex = screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor);
-
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::mergeStrings() {
- if (!_stringsMerged) {
- _lines.clear();
-
- for (int idx = 0; idx <= _lineCount; ++idx) {
- CString line = _array[idx]._rgb + _array[idx]._string3 +
- _array[idx]._line + "\n";
- _lines += line;
- }
-
- _stringsMerged = true;
- }
-}
-
-void CPetText::resize(uint count) {
- if (!count || _array.size() == count)
- return;
- _array.clear();
- _array.resize(count);
-}
-
-CString CPetText::getText() const {
- CString result = "";
- for (int idx = 0; idx <= _lineCount; ++idx)
- result += _array[idx]._line;
-
- return result;
-}
-
-void CPetText::setText(const CString &str) {
- setup();
- appendText(str);
-}
-
-void CPetText::setText(StringId stringId) {
- setText(g_vm->_strings[stringId]);
-}
-
-void CPetText::appendText(const CString &str) {
- int lineSize = _array[_lineCount]._line.size();
- int strSize = str.size();
-
- if (_maxCharsPerLine == -1) {
- // No limit on horizontal characters, so append string to current line
- _array[_lineCount]._line += str;
- } else if ((lineSize + strSize) <= _maxCharsPerLine) {
- // New string fits into line, so add it on
- _array[_lineCount]._line += str;
- } else {
- // Only add part of the str up to the maximum allowed limit for line
- _array[_lineCount]._line += str.left(_maxCharsPerLine - lineSize);
- }
-
- updateStr3(_lineCount);
- _stringsMerged = false;
-}
-
-void CPetText::setColor(uint col) {
- _textR = col & 0xff;
- _textG = (col >> 8) & 0xff;
- _textB = (col >> 16) & 0xff;
-}
-
-void CPetText::setColor(byte r, byte g, byte b) {
- _textR = r;
- _textG = g;
- _textB = b;
-}
-
-void CPetText::remapColors(uint count, uint *srcColors, uint *destColors) {
- for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) {
- if (_array[lineNum]._rgb.empty())
- continue;
-
- // Get the rgb values
- uint r = _array[lineNum]._rgb[1];
- uint g = _array[lineNum]._rgb[2];
- uint b = _array[lineNum]._rgb[3];
- uint color = r | (g << 8) | (b << 16);
-
- for (uint index = 0; index < count; ++index) {
- if (color == srcColors[index]) {
- // Found a match, so replace the color
- setLineColor(lineNum, destColors[lineNum]);
- break;
- }
- }
- }
-
- _stringsMerged = false;
-}
-
-void CPetText::setMaxCharsPerLine(int maxChars) {
- if (maxChars >= -1 && maxChars < 257)
- _maxCharsPerLine = maxChars;
-}
-
-void CPetText::updateStr3(int lineNum) {
- if (_npcFlag > 0 && _npcId > 0) {
- char line[5];
- line[0] = line[3] = TEXTCMD_NPC;
- line[1] = _npcFlag;
- line[2] = _npcId;
- line[4] = '\0';
- _array[lineNum]._string3 = CString(line);
-
- _stringsMerged = false;
- _npcFlag = _npcId = 0;
- }
-}
-
-int CPetText::getTextWidth(CScreenManager *screenManager) {
- mergeStrings();
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- int textWidth = screenManager->stringWidth(_lines);
- screenManager->setFontNumber(oldFontNumber);
-
- return textWidth;
-}
-
-int CPetText::getTextHeight(CScreenManager *screenManager) {
- mergeStrings();
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- int textHeight = screenManager->getTextBounds(_lines, _bounds.width() - 4);
- screenManager->setFontNumber(oldFontNumber);
-
- return textHeight;
-}
-
-void CPetText::deleteLastChar() {
- if (!_array[_lineCount]._line.empty()) {
- _array[_lineCount]._line.deleteLastChar();
- _stringsMerged = false;
- }
-}
-
-void CPetText::setNPC(int npcFlag, int npcId) {
- _npcFlag = npcFlag;
- _npcId = npcId;
-}
-
-void CPetText::scrollUp(CScreenManager *screenManager) {
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- _scrollTop -= screenManager->getFontHeight();
- constrainScrollUp(screenManager);
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::scrollDown(CScreenManager *screenManager) {
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- _scrollTop += screenManager->getFontHeight();
- constrainScrollDown(screenManager);
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::scrollUpPage(CScreenManager *screenManager) {
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- _scrollTop -= getPageHeight(screenManager);
- constrainScrollUp(screenManager);
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::scrollDownPage(CScreenManager *screenManager) {
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- _scrollTop += getPageHeight(screenManager);
- constrainScrollDown(screenManager);
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::scrollToTop(CScreenManager *screenManager) {
- _scrollTop = 0;
-}
-
-void CPetText::scrollToBottom(CScreenManager *screenManager) {
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- _scrollTop = getTextHeight(screenManager);
- constrainScrollDown(screenManager);
- screenManager->setFontNumber(oldFontNumber);
-}
-
-void CPetText::constrainScrollUp(CScreenManager *screenManager) {
- if (_scrollTop < 0)
- _scrollTop = 0;
-}
-
-void CPetText::constrainScrollDown(CScreenManager *screenManager) {
- // Figure out the maximum scroll amount allowed
- int maxScroll = getTextHeight(screenManager) - _bounds.height() - 4;
- if (maxScroll < 0)
- maxScroll = 0;
-
- if (_scrollTop > maxScroll)
- _scrollTop = maxScroll;
-}
-
-int CPetText::getPageHeight(CScreenManager *screenManager) {
- int textHeight = _bounds.height();
- int oldFontNumber = screenManager->setFontNumber(_fontNumber);
- int fontHeight = screenManager->getFontHeight();
- screenManager->setFontNumber(oldFontNumber);
-
- if (fontHeight) {
- int lines = textHeight / fontHeight;
- if (lines > 1)
- --lines;
- return lines * fontHeight;
- } else {
- return 0;
- }
-}
-
-void CPetText::addLine(const CString &str) {
- addLine(str, _textR, _textG, _textB);
-}
-
-void CPetText::addLine(const CString &str, uint color) {
- addLine(str, color & 0xff, (color >> 8) & 0xff,
- (color >> 16) & 0xff);
-}
-
-void CPetText::addLine(const CString &str, byte r, byte g, byte b) {
- if (_lineCount == ((int)_array.size() - 1)) {
- // Lines array is full
- if (_array.size() > 1) {
- // Delete the oldest line, and add a new entry at the end
- _array.remove_at(0);
- _array.resize(_array.size() + 1);
- }
-
- --_lineCount;
- }
-
- setLineColor(_lineCount, r, g, b);
- appendText(str);
- ++_lineCount;
-}
-
-bool CPetText::handleKey(char c) {
- switch (c) {
- case (char)Common::KEYCODE_BACKSPACE:
- deleteLastChar();
- break;
-
- case (char)Common::KEYCODE_RETURN:
- return true;
-
- default:
- if ((byte)c >= 32 && (byte)c <= 127)
- appendText(CString(c, 1));
- break;
- }
-
- return false;
-}
-
-void CPetText::showCursor(int mode) {
- CScreenManager *screenManager = CScreenManager::setCurrent();
- _textCursor = screenManager->_textCursor;
- if (_textCursor) {
- _textCursor->setPos(Point(0, 0));
- _textCursor->setSize(Point(2, 10));
- _textCursor->setColor(0, 0, 0);
- _textCursor->setBlinkRate(300);
- _textCursor->setMode(mode);
- _textCursor->setBounds(_bounds);
- _textCursor->show();
- }
-}
-
-void CPetText::hideCursor() {
- if (_textCursor) {
- _textCursor->setMode(-1);
- _textCursor->hide();
- _textCursor = nullptr;
- }
-}
-
-int CPetText::getNPCNum(uint ident, uint startIndex) {
- if (!_stringsMerged) {
- mergeStrings();
- if (!_stringsMerged)
- return -1;
- }
-
- uint size = _lines.size();
- if (startIndex < 5 || startIndex >= size)
- return -1;
-
- // Loop backwards from the starting index to find an NPC ident sequence
- for (const char *strP = _lines.c_str() + startIndex;
- strP >= (_lines.c_str() + 5); --strP) {
- if (*strP == 26) {
- byte id = *(strP - 2);
- if (id == ident)
- return *(strP - 1);
- strP -= 3;
- } else if (*strP == 27) {
- strP -= 4;
- }
- }
-
- return -1;
-}
-
-void CPetText::setFontNumber(int fontNumber) {
- if (fontNumber >= 0 && fontNumber <= 2)
- _fontNumber = fontNumber;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h
deleted file mode 100644
index 9b2f472..0000000
--- a/engines/titanic/pet_control/pet_text.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TITANIC_PET_TEXT_H
-#define TITANIC_PET_TEXT_H
-
-#include "common/keyboard.h"
-#include "titanic/support/simple_file.h"
-#include "titanic/support/screen_manager.h"
-#include "titanic/support/text_cursor.h"
-
-namespace Titanic {
-
-class CPetText {
- struct ArrayEntry {
- CString _line;
- CString _rgb;
- CString _string3;
- };
-private:
- Common::Array<ArrayEntry> _array;
- CString _lines;
- bool _stringsMerged;
- Rect _bounds;
- int _maxCharsPerLine;
- int _lineCount;
- int _displayEndCharIndex;
- int _unused1;
- int _unused2;
- int _unused3;
- int _backR;
- int _backG;
- int _backB;
- int _textR;
- int _textG;
- int _textB;
- int _fontNumber;
- int _npcFlag;
- int _npcId;
- bool _hasBorder;
- int _scrollTop;
- CTextCursor *_textCursor;
-private:
- void setupArrays(int count);
-
- void freeArrays();
-
- /**
- * Merges the strings in the strings array
- */
- void mergeStrings();
-
- /**
- * Append text to the current text line
- */
- void appendText(const CString &str);
-
- void updateStr3(int lineNum);
-
- /**
- * Ensures the Y scrolling for the text is in the valid range
- */
- void constrainScrollUp(CScreenManager *screenManager);
-
- /**
- * Ensures the Y scrolling for the text is in the valid range
- */
- void constrainScrollDown(CScreenManager *screenManager);
-
- /**
- * Get the page height for paging up and down
- */
- int getPageHeight(CScreenManager *screenManager);
-public:
- CPetText(uint count = 10);
-
- /**
- * Set up the control
- */
- void setup();
-
- /**
- * Load the data for the control
- */
- void load(SimpleFile *file, int param);
-
- /**
- * Save the data for the control
- */
- void save(SimpleFile *file, int indent);
-
- /**
- * Set the bounds for the control
- */
- void setBounds(const Rect &bounds) { _bounds = bounds; }
-
- /**
- * Sets the flag for whether to draw a frame border around the control
- */
- void setHasBorder(bool val) { _hasBorder = val; }
-
- /**
- * Draw the control
- */
- void draw(CScreenManager *screenManager);
-
- void resize(uint count);
-
- /**
- * Returns the text from all the lines as a single string
- */
- CString getText() const;
-
- /**
- * Set the text
- */
- void setText(const CString &str);
-
- /**
- * Set the text
- */
- void setText(StringId stringId);
-
- /**
- * Set text color
- */
- void setColor(uint col);
-
- /**
- * Set text color
- */
- void setColor(byte r, byte g, byte b);
-
- /**
- * Set the color for a line
- */
- void setLineColor(uint lineNum, byte r, byte g, byte b);
-
- /**
- * Gets the text string representing a color encoding
- */
- static CString getColorText(byte r, byte g, byte b);
-
- /**
- * Set the color for a line
- */
- void setLineColor(uint lineNum, uint col);
-
- /**
- * Sets the maximum number of characters per line
- */
- void setMaxCharsPerLine(int maxChars);
-
- /**
- * Delete the last character from the last line
- */
- void deleteLastChar();
-
- /**
- * Sets the current NPC text is being added for
- */
- void setNPC(int npcFlag, int npcId);
-
- /**
- * Returns the character index into _lines of the last
- * character to be displayed on-screen
- */
- int displayEndIndex() const { return _displayEndCharIndex; }
-
- /**
- * Scroll the text up
- */
- void scrollUp(CScreenManager *screenManager);
-
- /**
- * Scroll the text down
- */
- void scrollDown(CScreenManager *screenManager);
-
- /**
- * Scroll the text up one page
- */
- void scrollUpPage(CScreenManager *screenManager);
-
- /**
- * Scroll the text down one page
- */
- void scrollDownPage(CScreenManager *screenManager);
-
- /**
- * Scroll to the top of the text
- */
- void scrollToTop(CScreenManager *screenManager);
-
- /**
- * Scroll to the bottom of the text
- */
- void scrollToBottom(CScreenManager *screenManager);
-
- /**
- * Add a line to the text
- */
- void addLine(const CString &str);
-
- /**
- * Add a line to the text
- */
- void addLine(const CString &str, uint color);
-
- /**
- * Add a line to the text
- */
- void addLine(const CString &str, byte r, byte g, byte b);
-
- /**
- * Handles character processing to add or remove characters to
- * the current text line
- * @returns True if the Enter key was pressed
- */
- bool handleKey(char c);
-
- /**
- * Attaches the current system cursor to the text control,
- * and give it suitable defaults
- */
- void showCursor(int mode);
-
- /**
- * Removes the cursor attached to the text
- */
- void hideCursor();
-
- /**
- * Get an NPC Number embedded within on-screen text.
- * Used by the PET log to encode which NPC spoke
- * @param ident Npc Type. Always passed as 1
- * @param startIndex Starting index to scan backwards
- * through the log text to find an NPC ident sequence
- */
- int getNPCNum(uint ident, uint startIndex);
-
- /**
- * Replaces any occurances of line colors that appear in the
- * first list with the entry at the same index in the dest list
- */
- void remapColors(uint count, uint *srcColors, uint *destColors);
-
- /**
- * Set the font number to use
- */
- void setFontNumber(int fontNumber);
-
- /**
- * Get the width of the text
- */
- int getTextWidth(CScreenManager *screenManager);
-
- /**
- * Get the required height to draw the text
- */
- int getTextHeight(CScreenManager *screenManager);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_PET_TEXT_H */
diff --git a/engines/titanic/pet_control/pet_translation.cpp b/engines/titanic/pet_control/pet_translation.cpp
index fe6c37c..9509047 100644
--- a/engines/titanic/pet_control/pet_translation.cpp
+++ b/engines/titanic/pet_control/pet_translation.cpp
@@ -61,8 +61,8 @@ void CPetTranslation::clearTranslation() {
void CPetTranslation::addTranslation(const CString &str1, const CString &str2) {
CString msg = CString::format("%s%s - %s%s",
- CPetText::getColorText(0, 0x80, 0).c_str(), str1.c_str(),
- CPetText::getColorText(0, 0, 0).c_str(), str2.c_str());
+ CTextControl::getColorText(0, 0x80, 0).c_str(), str1.c_str(),
+ CTextControl::getColorText(0, 0, 0).c_str(), str2.c_str());
_message.addLine(msg);
_petControl->makeDirty();
}
diff --git a/engines/titanic/pet_control/pet_translation.h b/engines/titanic/pet_control/pet_translation.h
index 26070d6..ce12be4 100644
--- a/engines/titanic/pet_control/pet_translation.h
+++ b/engines/titanic/pet_control/pet_translation.h
@@ -24,14 +24,14 @@
#define TITANIC_PET_TRANSLATION_H
#include "titanic/pet_control/pet_section.h"
-#include "titanic/pet_control/pet_text.h"
+#include "titanic/gfx/text_control.h"
namespace Titanic {
class CPetTranslation : public CPetSection {
private:
- CPetText _message;
- CPetText _tooltip;
+ CTextControl _message;
+ CTextControl _tooltip;
private:
/**
* Setup the control
@@ -87,7 +87,7 @@ public:
/**
* Get a reference to the tooltip text associated with the section
*/
- virtual CPetText *getText() { return &_tooltip; }
+ virtual CTextControl *getText() { return &_tooltip; }
/**
* Clear any current translation text
More information about the Scummvm-git-logs
mailing list