aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-30 14:55:15 -0400
committerPaul Gilbert2016-07-10 16:37:44 -0400
commitb11033800d1455bd4c35af1126bd4f0cf6b2fb77 (patch)
tree51798f1e90cf65b73e3bae936b9a157360f6c6c5
parent01989265aa6abd68f2aa5d799d867886c8ed3799 (diff)
downloadscummvm-rg350-b11033800d1455bd4c35af1126bd4f0cf6b2fb77.tar.gz
scummvm-rg350-b11033800d1455bd4c35af1126bd4f0cf6b2fb77.tar.bz2
scummvm-rg350-b11033800d1455bd4c35af1126bd4f0cf6b2fb77.zip
TITANIC: Implementing PET support widgets
-rw-r--r--engines/titanic/core/game_object.cpp9
-rw-r--r--engines/titanic/core/game_object.h5
-rw-r--r--engines/titanic/pet_control/pet_control.cpp12
-rw-r--r--engines/titanic/pet_control/pet_control.h12
-rw-r--r--engines/titanic/pet_control/pet_drag_chev.cpp37
-rw-r--r--engines/titanic/pet_control/pet_drag_chev.h5
-rw-r--r--engines/titanic/pet_control/pet_graphic.cpp3
-rw-r--r--engines/titanic/pet_control/pet_graphic.h1
-rw-r--r--engines/titanic/pet_control/pet_graphic2.cpp3
-rw-r--r--engines/titanic/pet_control/pet_graphic2.h1
-rw-r--r--engines/titanic/pet_control/pet_section.h5
11 files changed, 86 insertions, 7 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index d2af519fcd..6d9f60d306 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -721,4 +721,13 @@ bool CGameObject::changeView(const CString &viewName, const CString &clipName) {
return true;
}
+void CGameObject::dragMove(const Point &pt) {
+ if (_surface) {
+ _bounds.setWidth(_surface->getWidth());
+ _bounds.setHeight(_surface->getHeight());
+ }
+
+ setPosition(Point(pt.x - _bounds.width() / 2, pt.y - _bounds.height() / 2));
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 94c3e5418d..847d6cd484 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -215,6 +215,11 @@ protected:
* Change the view
*/
bool changeView(const CString &viewName, const CString &clipName);
+
+ /**
+ * Support function for drag moving
+ */
+ void dragMove(const Point &pt);
public:
int _field60;
CursorId _cursorId;
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index d67ce543fe..6be026167a 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -348,8 +348,16 @@ void CPetControl::drawSquares(CScreenManager *screenManager, int count) {
_frame.drawSquares(screenManager, count);
}
-void CPetControl::displayMessage(const CString &msg) {
- error("TODO: CPetControl::displayMessage");
+CGameObject *CPetControl::dragEnd(const Point &pt) const {
+ return _currentArea == PET_INVENTORY ? _inventory.dragEnd(pt) : nullptr;
+}
+
+bool CPetControl::checkDragEnd(CGameObject *item) const {
+ return _sections[_currentArea]->checkDragEnd(item);
+}
+
+void CPetControl::displayMessage(const CString &msg) const {
+ _sections[_currentArea]->displayMessage(msg);
}
CGameObject *CPetControl::getFirstObject() const {
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 5fbd8a0107..b4c460e8bb 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -207,14 +207,17 @@ public:
/**
* Handles drag ends within the PET
*/
- CGameObject *dragEnd(const Point &pt) const {
- return _currentArea == PET_INVENTORY ? _inventory.dragEnd(pt) : nullptr;
- }
+ CGameObject *dragEnd(const Point &pt) const;
+
+ /**
+ * Handles checking when a drag-drop operation ends
+ */
+ bool checkDragEnd(CGameObject *item) const;
/**
* Display a message
*/
- void displayMessage(const CString &msg);
+ void displayMessage(const CString &msg) const;
/**
* Get the first game object stored in the PET
@@ -284,6 +287,7 @@ public:
* Stop a timer
*/
void stopPetTimer(uint timerIndex);
+
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp
index 3c1569856e..32acf72795 100644
--- a/engines/titanic/pet_control/pet_drag_chev.cpp
+++ b/engines/titanic/pet_control/pet_drag_chev.cpp
@@ -21,9 +21,16 @@
*/
#include "titanic/pet_control/pet_drag_chev.h"
+#include "titanic/pet_control/pet_control.h"
+#include "titanic/messages/messages.h"
+#include "titanic/npcs/succubus.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CPetDragChev, CPetGraphic2)
+
+END_MESSAGE_MAP()
+
void CPetDragChev::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
CPetGraphic2::save(file, indent);
@@ -34,4 +41,34 @@ void CPetDragChev::load(SimpleFile *file) {
CPetGraphic2::load(file);
}
+bool CPetDragChev::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ getName();
+ return checkStartDragging(msg);
+}
+
+bool CPetDragChev::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
+ dragMove(msg->_mousePos);
+ return true;
+}
+
+bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) {
+ if (msg->_dropTarget) {
+ CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_dropTarget);
+
+ if (succubus) {
+ CSetChevRoomBits msg(_field54);
+ msg.execute(succubus);
+ } else {
+ CPetControl *petControl = getPetControl();
+ if (petControl && petControl->contains(msg->_mousePos)
+ && msg->_mousePos.x < 528) {
+ if (petControl->checkDragEnd(this))
+ moveToHiddenRoom();
+ }
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_drag_chev.h b/engines/titanic/pet_control/pet_drag_chev.h
index 92f3883711..4e671ceff2 100644
--- a/engines/titanic/pet_control/pet_drag_chev.h
+++ b/engines/titanic/pet_control/pet_drag_chev.h
@@ -28,6 +28,11 @@
namespace Titanic {
class CPetDragChev : public CPetGraphic2 {
+ DECLARE_MESSAGE_MAP
+protected:
+ bool MouseDragStartMsg(CMouseDragStartMsg *msg);
+ bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
+ bool MouseDragEndMsg(CMouseDragEndMsg *msg);
public:
CLASSDEF
diff --git a/engines/titanic/pet_control/pet_graphic.cpp b/engines/titanic/pet_control/pet_graphic.cpp
index 3586c4de67..797c560ab0 100644
--- a/engines/titanic/pet_control/pet_graphic.cpp
+++ b/engines/titanic/pet_control/pet_graphic.cpp
@@ -24,6 +24,9 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CPetGraphic, CGameObject)
+END_MESSAGE_MAP()
+
void CPetGraphic::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
CGameObject::save(file, indent);
diff --git a/engines/titanic/pet_control/pet_graphic.h b/engines/titanic/pet_control/pet_graphic.h
index 112d75a870..d49d0d4a1a 100644
--- a/engines/titanic/pet_control/pet_graphic.h
+++ b/engines/titanic/pet_control/pet_graphic.h
@@ -28,6 +28,7 @@
namespace Titanic {
class CPetGraphic : public CGameObject {
+ DECLARE_MESSAGE_MAP
public:
CLASSDEF
diff --git a/engines/titanic/pet_control/pet_graphic2.cpp b/engines/titanic/pet_control/pet_graphic2.cpp
index d4871e8c78..ef898194e8 100644
--- a/engines/titanic/pet_control/pet_graphic2.cpp
+++ b/engines/titanic/pet_control/pet_graphic2.cpp
@@ -24,6 +24,9 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CPetGraphic2, CGameObject)
+END_MESSAGE_MAP()
+
void CPetGraphic2::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
CGameObject::save(file, indent);
diff --git a/engines/titanic/pet_control/pet_graphic2.h b/engines/titanic/pet_control/pet_graphic2.h
index d9bb514915..d10dd102a0 100644
--- a/engines/titanic/pet_control/pet_graphic2.h
+++ b/engines/titanic/pet_control/pet_graphic2.h
@@ -28,6 +28,7 @@
namespace Titanic {
class CPetGraphic2 : public CGameObject {
+ DECLARE_MESSAGE_MAP
public:
CLASSDEF
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 692c8b9100..faefb994cc 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -90,7 +90,10 @@ public:
virtual bool KeyCharMsg(CKeyCharMsg *msg) { return false; }
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; }
- virtual bool proc14(void *v1) { return false; }
+ /**
+ * Check whether a drag drop can occur
+ */
+ virtual bool checkDragEnd(CGameObject *item) { return false; }
/**
* Returns item a drag-drop operation has dropped on, if any