diff options
author | Paul Gilbert | 2016-04-29 18:19:03 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:22:42 -0400 |
commit | 5d087a8fcd709550ec14fc6b01acf045f8d6614b (patch) | |
tree | 715f364762e16984a3810208d3db7275ed683bc9 | |
parent | 6fa57389a2711a83103ebde63779743f7ac2b96d (diff) | |
download | scummvm-rg350-5d087a8fcd709550ec14fc6b01acf045f8d6614b.tar.gz scummvm-rg350-5d087a8fcd709550ec14fc6b01acf045f8d6614b.tar.bz2 scummvm-rg350-5d087a8fcd709550ec14fc6b01acf045f8d6614b.zip |
TITANIC: Implement PET Conversations & Text saving
-rw-r--r-- | engines/titanic/pet_control/pet_conversations.cpp | 45 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_conversations.h | 39 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.cpp | 32 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_text.h | 5 |
4 files changed, 95 insertions, 26 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp index ae5bbd6e24..d21380c28f 100644 --- a/engines/titanic/pet_control/pet_conversations.cpp +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -29,18 +29,6 @@ CPetConversations::CPetConversations() : CPetSection(), _logScrolled(false), _field418(0) { } -void CPetConversations::save(SimpleFile *file, int indent) const { - -} - -void CPetConversations::load(SimpleFile *file, int param) { - _textInput.load(file, param); - _log.load(file, param); - - for (int idx = 0; idx < 3; ++idx) - _valArray3[idx] = file->readNumber(); -} - bool CPetConversations::isValid(CPetControl *petControl) { return setupControl(petControl); } @@ -110,6 +98,39 @@ bool CPetConversations::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return handleKey(msg->_keyState); } +void CPetConversations::displayMessage(const CString &msg) { + _log.addLine(msg, getColor(1)); + scrollToBottom(); +} + +void CPetConversations::load(SimpleFile *file, int param) { + _textInput.load(file, param); + _log.load(file, param); + + for (int idx = 0; idx < 3; ++idx) + _valArray3[idx] = file->readNumber(); +} + +void CPetConversations::postLoad() { + reset(); +} + +void CPetConversations::save(SimpleFile *file, int indent) const { + _textInput.save(file, indent); + _log.save(file, indent); + + for (int idx = 0; idx < 3; ++idx) + file->writeNumberLine(_valArray3[idx], indent); +} + +void CPetConversations::enter(PetArea oldArea) { + +} + +void CPetConversations::leave() { + +} + bool CPetConversations::setupControl(CPetControl *petControl) { if (petControl) { _petControl = petControl; diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h index f7541eda46..9247b44a42 100644 --- a/engines/titanic/pet_control/pet_conversations.h +++ b/engines/titanic/pet_control/pet_conversations.h @@ -109,16 +109,6 @@ public: CPetConversations(); /** - * Save the data for the class to file - */ - virtual void save(SimpleFile *file, int indent) const; - - /** - * Load the data for the class from file - */ - virtual void load(SimpleFile *file, int param); - - /** * Returns true if the object is in a valid state */ virtual bool isValid(CPetControl *petControl); @@ -132,6 +122,35 @@ public: virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); virtual bool KeyCharMsg(CKeyCharMsg *msg); virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Display a message + */ + virtual void displayMessage(const CString &msg); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) const; + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave(); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp index 349e419513..87a6868d92 100644 --- a/engines/titanic/pet_control/pet_text.cpp +++ b/engines/titanic/pet_control/pet_text.cpp @@ -83,10 +83,7 @@ void CPetText::load(SimpleFile *file, int param) { int var1 = file->readNumber(); int var2 = file->readNumber(); uint count = file->readNumber(); - _bounds.left = file->readNumber(); - _bounds.top = file->readNumber(); - _bounds.right = file->readNumber(); - _bounds.bottom = file->readNumber(); + _bounds = file->readRect(); _field3C = file->readNumber(); _field40 = file->readNumber(); _field44 = file->readNumber(); @@ -109,6 +106,33 @@ void CPetText::load(SimpleFile *file, int param) { } } +void CPetText::save(SimpleFile *file, int indent) const { + int numLines = _lineCount + 1; + + file->writeNumberLine(_array.size(), indent); + file->writeNumberLine(_maxCharsPerLine, indent); + file->writeNumberLine(numLines, indent); + + file->writeRect(_bounds, indent); + file->writeNumberLine(_field3C, indent); + file->writeNumberLine(_field40, indent); + file->writeNumberLine(_field44, 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; diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h index a3d136a2d4..dd1547bff4 100644 --- a/engines/titanic/pet_control/pet_text.h +++ b/engines/titanic/pet_control/pet_text.h @@ -111,6 +111,11 @@ public: void load(SimpleFile *file, int param); /** + * Save the data for the control + */ + void save(SimpleFile *file, int indent) const; + + /** * Set the bounds for the control */ void setBounds(const Rect &bounds) { _bounds = bounds; } |