aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-28 19:10:18 -0400
committerPaul Gilbert2016-07-10 16:22:33 -0400
commitb7ad513b0f0c99bc670546dbb3483e93d59652ee (patch)
tree82b392afae383fba2fffe5b2016fcceb21240432 /engines/titanic
parentb324d2ea6cd422bafd846642ed54620abe7e32ea (diff)
downloadscummvm-rg350-b7ad513b0f0c99bc670546dbb3483e93d59652ee.tar.gz
scummvm-rg350-b7ad513b0f0c99bc670546dbb3483e93d59652ee.tar.bz2
scummvm-rg350-b7ad513b0f0c99bc670546dbb3483e93d59652ee.zip
TITANIC: Implement PET Text scrolling
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/pet_control/pet_conversations.cpp29
-rw-r--r--engines/titanic/pet_control/pet_conversations.h20
-rw-r--r--engines/titanic/pet_control/pet_text.cpp35
-rw-r--r--engines/titanic/pet_control/pet_text.h22
4 files changed, 96 insertions, 10 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp
index 3afd5ee380..d2c891efb8 100644
--- a/engines/titanic/pet_control/pet_conversations.cpp
+++ b/engines/titanic/pet_control/pet_conversations.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/pet_control/pet_conversations.h"
+#include "titanic/pet_control/pet_control.h"
namespace Titanic {
@@ -44,6 +45,14 @@ bool CPetConversations::isValid(CPetControl *petControl) {
return setupControl(petControl);
}
+bool CPetConversations::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ return
+ _scrollUp.MouseButtonDownMsg(msg->_mousePos) ||
+ _scrollDown.MouseButtonDownMsg(msg->_mousePos) ||
+ _val7.MouseButtonDownMsg(msg->_mousePos) ||
+ _val8.MouseButtonDownMsg(msg->_mousePos);
+}
+
bool CPetConversations::setupControl(CPetControl *petControl) {
if (petControl) {
_petControl = petControl;
@@ -60,10 +69,10 @@ bool CPetConversations::setupControl(CPetControl *petControl) {
_gfxList[2].translate(20, 434);
const Rect rect2(0, 0, 11, 24);
- _val1.setBounds(rect2);
- _val1.translate(87, 374);
- _val2.setBounds(rect2);
- _val2.translate(87, 421);
+ _scrollUp.setBounds(rect2);
+ _scrollUp.translate(87, 374);
+ _scrollDown.setBounds(rect2);
+ _scrollDown.translate(87, 421);
const Rect rect3(0, 0, 39, 39);
_val7.setBounds(rect3);
@@ -86,4 +95,16 @@ bool CPetConversations::setupControl(CPetControl *petControl) {
return true;
}
+void CPetConversations::scrollDown() {
+ _log.scrollDown(CScreenManager::_screenManagerPtr);
+ if (_petControl)
+ _petControl->makeDirty();
+}
+
+void CPetConversations::scrollUp() {
+ _log.scrollUp(CScreenManager::_screenManagerPtr);
+ if (_petControl)
+ _petControl->makeDirty();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index 89dbc5eb96..8a3ca886a5 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -31,8 +31,8 @@ namespace Titanic {
class CPetConversations : public CPetSection {
private:
- CPetGfxElement _val1;
- CPetGfxElement _val2;
+ CPetGfxElement _scrollUp;
+ CPetGfxElement _scrollDown;
CPetGfxElement _val3;
CPetGfxElement _gfxList[3];
CPetGfxElement _val4;
@@ -55,6 +55,16 @@ private:
* Sets up the control
*/
bool setupControl(CPetControl *petControl);
+
+ /**
+ * Scroll down the conversation log
+ */
+ void scrollDown();
+
+ /**
+ * Scroll up the conversation log
+ */
+ void scrollUp();
public:
CPetConversations();
@@ -72,6 +82,12 @@ public:
* Returns true if the object is in a valid state
*/
virtual bool isValid(CPetControl *petControl);
+
+ /**
+ * Following are handlers for the various messages that the PET can
+ * pass onto the currently active section/area
+ */
+ virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp
index 3a10ab4c87..9a895de36b 100644
--- a/engines/titanic/pet_control/pet_text.cpp
+++ b/engines/titanic/pet_control/pet_text.cpp
@@ -30,7 +30,7 @@ CPetText::CPetText(uint count) :
_backR(0xff), _backG(0xff), _backB(0xff),
_textR(0), _textG(0), _textB(200),
_fontNumber2(0), _field64(0), _field68(0), _field6C(0),
- _hasBorder(true), _field74(0), _textCursor(nullptr), _field7C(0) {
+ _hasBorder(true), _scrollTop(0), _textCursor(nullptr), _field7C(0) {
setupArrays(count);
}
@@ -97,7 +97,7 @@ void CPetText::load(SimpleFile *file, int param) {
_textG = file->readNumber();
_textB = file->readNumber();
_hasBorder = file->readNumber() != 0;
- _field74 = file->readNumber();
+ _scrollTop = file->readNumber();
warning("TODO: CPetText::load %d,%d", var1, var2);
assert(_array.size() >= count);
@@ -140,7 +140,7 @@ void CPetText::draw(CScreenManager *screenManager) {
tempRect.grow(-2);
screenManager->setFontNumber(_fontNumber2);
- screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _field74, _lines, _textCursor);
+ screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor);
screenManager->setFontNumber(_fontNumber1);
}
@@ -250,4 +250,33 @@ void CPetText::setNPC(int val1, int npcId) {
_field68 = npcId;
}
+void CPetText::scrollUp(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber2);
+ _scrollTop -= screenManager->getFontHeight();
+ constrainScrollUp(screenManager);
+ screenManager->setFontNumber(oldFontNumber);
+}
+
+void CPetText::scrollDown(CScreenManager *screenManager) {
+ int oldFontNumber = screenManager->setFontNumber(_fontNumber2);
+ _scrollTop += screenManager->getFontHeight();
+ 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 = _bounds.height() - getTextHeight(screenManager) - 4;
+ if (maxScroll < 0)
+ maxScroll = 0;
+
+ if (_scrollTop > maxScroll)
+ _scrollTop = maxScroll;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h
index 6ce1903166..36d098f141 100644
--- a/engines/titanic/pet_control/pet_text.h
+++ b/engines/titanic/pet_control/pet_text.h
@@ -57,7 +57,7 @@ private:
int _field68;
int _field6C;
bool _hasBorder;
- int _field74;
+ int _scrollTop;
CTextCursor *_textCursor;
int _field7C;
private:
@@ -81,6 +81,16 @@ private:
* Get the required height to draw the text
*/
int getTextHeight(CScreenManager *screenManager);
+
+ /**
+ * 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);
public:
CPetText(uint count = 10);
@@ -157,6 +167,16 @@ public:
* Get the font
*/
int getFontNumber() const { return _fontNumber1; }
+
+ /**
+ * Scroll the text up
+ */
+ void scrollUp(CScreenManager *screenManager);
+
+ /**
+ * Scroll the text down
+ */
+ void scrollDown(CScreenManager *screenManager);
};
} // End of namespace Titanic