aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/carry/carry.cpp84
-rw-r--r--engines/titanic/carry/carry.h12
-rw-r--r--engines/titanic/core/game_object.cpp20
-rw-r--r--engines/titanic/core/game_object.h17
-rw-r--r--engines/titanic/events.cpp8
-rw-r--r--engines/titanic/events.h5
-rw-r--r--engines/titanic/game_state.cpp4
-rw-r--r--engines/titanic/game_state.h7
-rw-r--r--engines/titanic/messages/messages.h14
-rw-r--r--engines/titanic/messages/mouse_messages.h5
10 files changed, 134 insertions, 42 deletions
diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index dbb7189781..cc12fd1a72 100644
--- a/engines/titanic/carry/carry.cpp
+++ b/engines/titanic/carry/carry.cpp
@@ -23,6 +23,7 @@
#include "titanic/carry/carry.h"
#include "titanic/messages/messages.h"
#include "titanic/npcs/character.h"
+#include "titanic/npcs/succubus.h"
namespace Titanic {
@@ -43,9 +44,9 @@ END_MESSAGE_MAP()
CCarry::CCarry() : CGameObject(), _fieldDC(0), _fieldE0(1),
_field100(0), _field104(0), _field108(0), _field10C(0),
- _field110(0), _field120(0), _field124(0), _field128(0),
+ _itemFrame(0), _enterFrame(0), _enterFrameSet(false), _visibleFrame(0),
_string1("None"),
- _string2("NULL"),
+ _fullViewName("NULL"),
_string3("That doesn't seem to do anything."),
_string4("It doesn't seem to want this.") {
}
@@ -53,8 +54,8 @@ CCarry::CCarry() : CGameObject(), _fieldDC(0), _fieldE0(1),
void CCarry::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_string1, indent);
- file->writePoint(_pos1, indent);
- file->writeQuotedLine(_string2, indent);
+ file->writePoint(_origPos, indent);
+ file->writeQuotedLine(_fullViewName, indent);
file->writeNumberLine(_fieldDC, indent);
file->writeNumberLine(_fieldE0, indent);
file->writeQuotedLine(_string3, indent);
@@ -63,11 +64,11 @@ void CCarry::save(SimpleFile *file, int indent) const {
file->writeNumberLine(_field104, indent);
file->writeNumberLine(_field108, indent);
file->writeNumberLine(_field10C, indent);
- file->writeNumberLine(_field110, indent);
+ file->writeNumberLine(_itemFrame, indent);
file->writeQuotedLine(_string5, indent);
- file->writeNumberLine(_field120, indent);
- file->writeNumberLine(_field124, indent);
- file->writeNumberLine(_field128, indent);
+ file->writeNumberLine(_enterFrame, indent);
+ file->writeNumberLine(_enterFrameSet, indent);
+ file->writeNumberLine(_visibleFrame, indent);
CGameObject::save(file, indent);
}
@@ -75,8 +76,8 @@ void CCarry::save(SimpleFile *file, int indent) const {
void CCarry::load(SimpleFile *file) {
file->readNumber();
_string1 = file->readString();
- _pos1 = file->readPoint();
- _string2 = file->readString();
+ _origPos = file->readPoint();
+ _fullViewName = file->readString();
_fieldDC = file->readNumber();
_fieldE0 = file->readNumber();
_string3 = file->readString();
@@ -85,11 +86,11 @@ void CCarry::load(SimpleFile *file) {
_field104 = file->readNumber();
_field108 = file->readNumber();
_field10C = file->readNumber();
- _field110 = file->readNumber();
+ _itemFrame = file->readNumber();
_string5 = file->readString();
- _field120 = file->readNumber();
- _field124 = file->readNumber();
- _field128 = file->readNumber();
+ _enterFrame = file->readNumber();
+ _enterFrameSet = file->readNumber();
+ _visibleFrame = file->readNumber();
CGameObject::load(file);
}
@@ -142,12 +143,30 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) {
return true;
}
- // TODO
+ CString viewName = getViewFullName();
+ if (viewName.empty() || msg->_mousePos.y >= 360) {
+ sleep(250);
+ dropOnPet();
+ } else {
+ setPosition(_origPos);
+ loadFrame(_itemFrame);
+ }
return true;
}
bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) {
+ CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character);
+ if (succubus) {
+ CSubAcceptCCarryMsg carryMsg;
+ carryMsg._item = this;
+ carryMsg.execute(succubus);
+ } else {
+ CShowTextMsg textMsg(_string4);
+ textMsg.execute("PET");
+ dropOnPet();
+ }
+
return true;
}
@@ -156,10 +175,25 @@ bool CCarry::LeaveViewMsg(CLeaveViewMsg *msg) {
}
bool CCarry::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ CShowTextMsg textMsg(_string3);
+ textMsg.execute("PET");
+
+ _fullViewName = getViewFullName();
+ if (_fullViewName.empty() || _bounds.top >= 360) {
+ sleep(250);
+ dropOnPet();
+ } else {
+ setPosition(_origPos);
+ }
+
return true;
}
bool CCarry::VisibleMsg(CVisibleMsg *msg) {
+ setVisible(msg->_visible);
+ if (msg->_visible && _visibleFrame != -1)
+ loadFrame(_visibleFrame);
+
return true;
}
@@ -168,18 +202,38 @@ bool CCarry::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
}
bool CCarry::RemoveFromGameMsg(CRemoveFromGameMsg *msg) {
+ setPosition(Point(0, 0));
+ setVisible(false);
+
return true;
}
bool CCarry::MoveToStartPosMsg(CMoveToStartPosMsg *msg) {
+ setPosition(_origPos);
return true;
}
bool CCarry::EnterViewMsg(CEnterViewMsg *msg) {
+ if (!_enterFrameSet) {
+ loadFrame(_enterFrame);
+ _enterFrameSet = true;
+ }
+
return true;
}
bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
+ if (_visibleFrame != -1)
+ loadFrame(_visibleFrame);
+
+ if (msg->_value3) {
+ _tempPos.x = _bounds.width() / 2;
+ _tempPos.y = _bounds.height() / 2;
+ } else {
+ _tempPos = msg->_mousePos - _bounds;
+ }
+
+ setPosition(_tempPos - getMousePos());
return true;
}
diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h
index 33e3ac369d..e292eb2897 100644
--- a/engines/titanic/carry/carry.h
+++ b/engines/titanic/carry/carry.h
@@ -45,8 +45,8 @@ class CCarry : public CGameObject {
bool PassOnDragStartMsg(CPassOnDragStartMsg *msg);
private:
CString _string1;
- Point _pos1;
- CString _string2;
+ Point _origPos;
+ CString _fullViewName;
int _fieldDC;
int _fieldE0;
CString _string3;
@@ -56,11 +56,11 @@ private:
int _field104;
int _field108;
int _field10C;
- int _field110;
+ int _itemFrame;
CString _string5;
- int _field120;
- int _field124;
- int _field128;
+ int _enterFrame;
+ bool _enterFrameSet;
+ int _visibleFrame;
protected:
/**
* Called when an item is dropped onto the PET
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 7e731bdbe7..0bd246d529 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -405,7 +405,7 @@ void CGameObject::resetPosition() {
setPosition(_savedPos);
}
-void CGameObject::setPosition(const Common::Point &newPos) {
+void CGameObject::setPosition(const Point &newPos) {
makeDirty();
_bounds.moveTo(newPos);
makeDirty();
@@ -540,4 +540,22 @@ CViewItem *CGameObject::parseView(const CString &viewString) {
return view;
}
+CString CGameObject::getViewFullName() const {
+ CGameManager *gameManager = getGameManager();
+ CViewItem *view = gameManager->getView();
+ CNodeItem *node = view->findNode();
+ CRoomItem *room = node->findRoom();
+
+ return CString::format("%s.%s.%s", room->getName().c_str(),
+ node->getName().c_str(), view->getName().c_str());
+}
+
+void CGameObject::sleep(uint milli) {
+ g_vm->_events->sleep(milli);
+}
+
+Point CGameObject::getMousePos() const {
+ return getGameManager()->_gameState.getMousePos();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index bc1020d03f..9e84a453c7 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -145,6 +145,16 @@ protected:
* Adds a timer
*/
int addTimer(int endVal, uint firstDuration, uint duration);
+
+ /**
+ * Causes the game to sleep for the specified time
+ */
+ void sleep(uint milli);
+
+ /**
+ * Get the current mouse cursor position
+ */
+ Point getMousePos() const;
public:
int _field60;
CursorId _cursorId;
@@ -191,7 +201,7 @@ public:
/**
* Set the position of the object
*/
- void setPosition(const Common::Point &newPos);
+ void setPosition(const Point &newPos);
/**
* Returns true if the object has a currently active movie
@@ -215,6 +225,11 @@ public:
* Play the movie specified in _resource
*/
void playMovie(uint startFrame, uint endFrame, int val3);
+
+ /**
+ * Return the current view/node/room as a single string
+ */
+ CString getViewFullName() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp
index 480cc91578..590107336c 100644
--- a/engines/titanic/events.cpp
+++ b/engines/titanic/events.cpp
@@ -227,4 +227,12 @@ void Events::handleKbdSpecial(Common::KeyState keyState) {
_specialButtons &= ~MK_SHIFT;
}
+void Events::sleep(uint time) {
+ uint32 delayEnd = g_system->getMillis() + time;
+
+ while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
+ pollEventsAndWait();
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/events.h b/engines/titanic/events.h
index f85a3d9272..4cbba178ad 100644
--- a/engines/titanic/events.h
+++ b/engines/titanic/events.h
@@ -103,6 +103,11 @@ public:
* Return whether a given special key is currently pressed
*/
bool isSpecialPressed(SpecialButtons btn) const { return _specialButtons; }
+
+ /**
+ * Sleep for a specified period of time
+ */
+ void sleep(uint time);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index fab7d1165b..7c59aaf5c1 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -96,10 +96,6 @@ void CGameState::setMode(GameStateMode newMode) {
_mode = newMode;
}
-void CGameState::setMousePos(const Point &pt) {
- _mousePos = pt;
-}
-
void CGameState::enterNode() {
++_nodeChangeCtr;
_nodeEnterTicks = g_vm->_events->getTicksCount();
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index 5d4b686bf4..0fe8e6ad14 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -87,7 +87,12 @@ public:
/**
* Sets the current mouse position
*/
- void setMousePos(const Point &pt);
+ void setMousePos(const Point &pt) { _mousePos = pt; }
+
+ /**
+ * Gets the current mouse position
+ */
+ Point getMousePos() const { return _mousePos; }
/**
* Called by the PET when a new node is entered
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 474565a69c..ab3078dd56 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -198,19 +198,6 @@ public:
}
};
-class CSubAcceptCCarryMsg : public CMessage {
-public:
- CString _string1;
- int _value1, _value2, _value3;
-public:
- CLASSDEF
- CSubAcceptCCarryMsg() : _value1(0), _value2(0), _value3(0) {}
-
- static bool isSupportedBy(const CTreeItem *item) {
- return supports(item, _type);
- }
-};
-
class CTransportMsg : public CMessage {
public:
CString _string;
@@ -366,6 +353,7 @@ MESSAGE2(CSpeechFallsFromTreeMsg, int, value1, 0, int, value2, 0);
MESSAGE1(CStartMusicMsg, int, value, 0);
MESSAGE3(CStatusChangeMsg, int, oldStatus, 0, int, newStatus, 0, bool, success, false);
MESSAGE1(CStopMusicMsg, int, value, 0);
+MESSAGE4(CSubAcceptCCarryMsg, CString, string1, "", int, value1, 0, int, value2, 0, CCarry *, item, nullptr);
MESSAGE0(CSubDeliverCCarryMsg);
MESSAGE0(CSubSendCCarryMsg);
MESSAGE0(CSUBTransition);
diff --git a/engines/titanic/messages/mouse_messages.h b/engines/titanic/messages/mouse_messages.h
index 705247a2dc..ce02e1df73 100644
--- a/engines/titanic/messages/mouse_messages.h
+++ b/engines/titanic/messages/mouse_messages.h
@@ -142,10 +142,13 @@ public:
class CPassOnDragStartMsg : public CMessage {
public:
Point _mousePos;
+ int _value3;
+ int _value4;
public:
CLASSDEF
CPassOnDragStartMsg() : CMessage() {}
- CPassOnDragStartMsg(const Point &pt) : CMessage(), _mousePos(pt) {}
+ CPassOnDragStartMsg(const Point &pt, int v3 = 0, int v4 = 0) :
+ CMessage(), _mousePos(pt), _value3(v3), _value4(v4) {}
static bool isSupportedBy(const CTreeItem *item) {
return supports(item, _type);