aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/background.cpp12
-rw-r--r--engines/titanic/core/background.h10
-rw-r--r--engines/titanic/core/game_object.cpp38
-rw-r--r--engines/titanic/core/game_object.h28
-rw-r--r--engines/titanic/core/saveable_object.cpp2
-rw-r--r--engines/titanic/core/tree_item.cpp5
-rw-r--r--engines/titanic/core/tree_item.h5
-rw-r--r--engines/titanic/game/cdrom.cpp42
-rw-r--r--engines/titanic/game/cdrom.h15
-rw-r--r--engines/titanic/game/cdrom_tray.cpp6
-rw-r--r--engines/titanic/game/cdrom_tray.h4
-rw-r--r--engines/titanic/game/television.cpp12
-rw-r--r--engines/titanic/messages/messages.h1
-rw-r--r--engines/titanic/messages/mouse_messages.h6
14 files changed, 155 insertions, 31 deletions
diff --git a/engines/titanic/core/background.cpp b/engines/titanic/core/background.cpp
index 63aaf30ae0..ea3bdb01a8 100644
--- a/engines/titanic/core/background.cpp
+++ b/engines/titanic/core/background.cpp
@@ -49,4 +49,16 @@ void CBackground::load(SimpleFile *file) {
CGameObject::load(file);
}
+bool CBackground::handleMessage(CStatusChangeMsg &msg) {
+ error("TODO: CBackground::handleMessage");
+}
+
+bool CBackground::handleMessage(CSetFrameMsg &msg) {
+ error("TODO: CBackground::handleMessage");
+}
+
+bool CBackground::handleMessage(CVisibleMsg &msg) {
+ error("TODO: CBackground::handleMessage");
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/background.h b/engines/titanic/core/background.h
index 4ce5651fc4..bd8f94987e 100644
--- a/engines/titanic/core/background.h
+++ b/engines/titanic/core/background.h
@@ -24,16 +24,24 @@
#define TITANIC_BACKGROUND_H
#include "titanic/core/game_object.h"
+#include "titanic/messages/messages.h"
namespace Titanic {
-class CBackground : public CGameObject {
+class CBackground : public CGameObject,
+ public CStatusChangeMsgTarget,
+ public CSetFrameMsgTarget,
+ public CVisibleMsgTarget {
protected:
int _fieldBC;
int _fieldC0;
CString _string1;
CString _string2;
int _fieldDC;
+protected:
+ virtual bool handleMessage(CStatusChangeMsg &msg);
+ virtual bool handleMessage(CSetFrameMsg &msg);
+ virtual bool handleMessage(CVisibleMsg &msg);
public:
CLASSDEF
CBackground();
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index a215633932..834364591d 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -45,7 +45,7 @@ CGameObject::CGameObject(): CNamedItem() {
_field50 = 0;
_field54 = 0;
_field58 = 0;
- _field5C = true;
+ _visible = true;
_field60 = 0;
_cursorId = CURSOR_1;
_field78 = 0;
@@ -54,8 +54,6 @@ CGameObject::CGameObject(): CNamedItem() {
_field94 = 0;
_field98 = 0;
_field9C = 0;
- _fieldA0 = 0;
- _fieldA4 = 0;
_surface = nullptr;
_fieldB8 = 0;
}
@@ -106,7 +104,7 @@ void CGameObject::load(SimpleFile *file) {
_field48 = file->readNumber();
_field4C = file->readNumber();
_fieldB8 = file->readNumber();
- _field5C = file->readNumber() != 0;
+ _visible = file->readNumber() != 0;
_field50 = file->readNumber();
_field54 = file->readNumber();
_field58 = file->readNumber();
@@ -137,7 +135,7 @@ bool CGameObject::checkPoint(const Point &pt, int v0, int v1) {
}
void CGameObject::draw(CScreenManager *screenManager) {
- if (!_field5C)
+ if (!_visible)
return;
if (_v1) {
error("TODO: Block in CGameObject::draw");
@@ -276,9 +274,9 @@ void CGameObject::soundFn2(int val, int val2) {
}
}
-void CGameObject::set5C(bool val) {
- if (val != _field5C) {
- _field5C = val;
+void CGameObject::setVisible(bool val) {
+ if (val != _visible) {
+ _visible = val;
makeDirty();
}
}
@@ -320,4 +318,28 @@ void CGameObject::changeStatus(int newStatus) {
}
}
+void CGameObject::savePosition() {
+ _savedPos = _bounds;
+}
+
+void CGameObject::resetPosition() {
+ setPosition(_savedPos);
+}
+
+void CGameObject::setPosition(const Common::Point &newPos) {
+ makeDirty();
+ _bounds.moveTo(newPos);
+ makeDirty();
+}
+
+bool CGameObject::checkStartDragging(CMouseDragStartMsg *msg) {
+ if (_visible && checkPoint(msg->_mousePos, msg->_field14, 1)) {
+ savePosition();
+ msg->_dragItem = this;
+ return true;
+ } else {
+ return false;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 2f56f599a0..ced8663ed3 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -31,6 +31,7 @@
namespace Titanic {
class CVideoSurface;
+class CMouseDragStartMsg;
class CGameObject : public CNamedItem {
public:
@@ -74,7 +75,7 @@ protected:
int _field50;
int _field54;
int _field58;
- bool _field5C;
+ bool _visible;
CMovieClipList _clipList1;
int _field78;
CMovieClipList _clipList2;
@@ -83,8 +84,7 @@ protected:
int _field94;
int _field98;
int _field9C;
- int _fieldA0;
- int _fieldA4;
+ Common::Point _savedPos;
CVideoSurface *_surface;
CString _resource;
int _fieldB8;
@@ -94,9 +94,24 @@ protected:
*/
void loadFrame(int frameNumber);
+ /**
+ * Saves the current position the object is located at
+ */
+ void savePosition();
+
+ /**
+ * Resets the object back to the previously saved starting position
+ */
+ void resetPosition();
+
+ /**
+ * Check for starting to drag the object
+ */
+ bool checkStartDragging(CMouseDragStartMsg *msg);
+
bool soundFn1(int val);
void soundFn2(int val, int val2);
- void set5C(bool val);
+ void setVisible(bool val);
bool petFn1(int val);
void petFn2(int val);
void petFn3(int val);
@@ -135,6 +150,11 @@ public:
* Change the object's status
*/
void changeStatus(int newStatus);
+
+ /**
+ * Set the position of the object
+ */
+ void setPosition(const Common::Point &newPos);
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index f7c715fd66..022a72b33a 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -897,6 +897,7 @@ DEFFN(CSetChevLiftBits)
DEFFN(CSetChevPanelBitMsg)
DEFFN(CSetChevPanelButtonsMsg)
DEFFN(CSetChevRoomBits)
+DEFFN(CSetFrameMsg);
DEFFN(CSetMusicControlsMsg)
DEFFN(CSetVarMsg)
DEFFN(CSetVolumeMsg)
@@ -1479,6 +1480,7 @@ void CSaveableObject::initClassList() {
ADDFN(CSetChevPanelBitMsg, CMessage);
ADDFN(CSetChevPanelButtonsMsg, CMessage);
ADDFN(CSetChevRoomBits, CMessage);
+ ADDFN(CSetFrameMsg, CMessage);
ADDFN(CSetMusicControlsMsg, CMessage);
ADDFN(CSetVarMsg, CMessage);
ADDFN(CSetVolumeMsg, CMessage);
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index 2c985bf34e..081c5806b6 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -284,4 +284,9 @@ CTreeItem *CTreeItem::getDontSaveChild(ClassDef *classDef) const {
return dontSave->findChildInstanceOf(classDef);
}
+CRoomItem *CTreeItem::getRoom() const {
+ CGameManager *gameManager = getGameManager();
+ return gameManager ? gameManager->getRoom() : nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index a6c09b8126..f5e28f1056 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -33,6 +33,7 @@ class CNamedItem;
class CPetControl;
class CProjectItem;
class CScreenManager;
+class CRoomItem;
class CTreeItem: public CMessageTarget {
private:
@@ -242,6 +243,10 @@ public:
*/
CTreeItem *getDontSaveChild(ClassDef *classDef) const;
+ /**
+ * Return the current room
+ */
+ CRoomItem *getRoom() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/game/cdrom.cpp b/engines/titanic/game/cdrom.cpp
index 40e8ed05d8..d4e4eac4d1 100644
--- a/engines/titanic/game/cdrom.cpp
+++ b/engines/titanic/game/cdrom.cpp
@@ -21,6 +21,8 @@
*/
#include "titanic/game/cdrom.h"
+#include "titanic/core/room_item.h"
+#include "titanic/game/cdrom_tray.h"
namespace Titanic {
@@ -29,14 +31,50 @@ CCDROM::CCDROM() : CGameObject() {
void CCDROM::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
- file->writePoint(_pos1, indent);
+ file->writePoint(_tempPos, indent);
CGameObject::save(file, indent);
}
void CCDROM::load(SimpleFile *file) {
file->readNumber();
- _pos1 = file->readPoint();
+ _tempPos = file->readPoint();
CGameObject::load(file);
}
+bool CCDROM::handleMessage(CMouseDragStartMsg &msg) {
+ if (checkStartDragging(&msg)) {
+ _tempPos = msg._mousePos - _bounds;
+ setPosition(msg._mousePos - _tempPos);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool CCDROM::handleMessage(CMouseDragEndMsg &msg) {
+ if (msg._dropTarget && msg._dropTarget->getName() == "newComputer") {
+ CCDROMTray *newTray = dynamic_cast<CCDROMTray *>(getRoom()->findByName("newTray"));
+
+ if (newTray->_state && newTray->_string1 == "None") {
+ CActMsg actMsg(getName());
+ actMsg.execute(newTray);
+ }
+ }
+
+ resetPosition();
+ return true;
+}
+
+bool CCDROM::handleMessage(CMouseDragMoveMsg &msg) {
+ setPosition(msg._mousePos - _tempPos);
+ return true;
+}
+
+bool CCDROM::handleMessage(CActMsg &msg) {
+ if (msg._action == "Ejected")
+ setVisible(true);
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/cdrom.h b/engines/titanic/game/cdrom.h
index c1280f6712..61bada0b74 100644
--- a/engines/titanic/game/cdrom.h
+++ b/engines/titanic/game/cdrom.h
@@ -24,12 +24,23 @@
#define TITANIC_CDROM_H
#include "titanic/core/game_object.h"
+#include "titanic/messages/messages.h"
+#include "titanic/messages/mouse_messages.h"
namespace Titanic {
-class CCDROM : public CGameObject {
+class CCDROM : public CGameObject,
+ public CMouseDragStartMsgTarget,
+ public CMouseDragEndMsgTarget,
+ public CMouseDragMoveMsgTarget,
+ public CActMsgTarget {
private:
- Point _pos1;
+ Point _tempPos;
+protected:
+ virtual bool handleMessage(CMouseDragStartMsg &msg);
+ virtual bool handleMessage(CMouseDragEndMsg &msg);
+ virtual bool handleMessage(CMouseDragMoveMsg &msg);
+ virtual bool handleMessage(CActMsg &msg);
public:
CLASSDEF
CCDROM();
diff --git a/engines/titanic/game/cdrom_tray.cpp b/engines/titanic/game/cdrom_tray.cpp
index 32eea0648b..fcb65fd42d 100644
--- a/engines/titanic/game/cdrom_tray.cpp
+++ b/engines/titanic/game/cdrom_tray.cpp
@@ -24,12 +24,12 @@
namespace Titanic {
-CCDROMTray::CCDROMTray() : CGameObject(), _fieldBC(0) {
+CCDROMTray::CCDROMTray() : CGameObject(), _state(0) {
}
void CCDROMTray::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_fieldBC, indent);
+ file->writeNumberLine(_state, indent);
file->writeQuotedLine(_string1, indent);
CGameObject::save(file, indent);
@@ -37,7 +37,7 @@ void CCDROMTray::save(SimpleFile *file, int indent) const {
void CCDROMTray::load(SimpleFile *file) {
file->readNumber();
- _fieldBC = file->readNumber();
+ _state = file->readNumber();
_string1 = file->readString();
CGameObject::load(file);
diff --git a/engines/titanic/game/cdrom_tray.h b/engines/titanic/game/cdrom_tray.h
index 85d26c5a1d..b5c4b375fe 100644
--- a/engines/titanic/game/cdrom_tray.h
+++ b/engines/titanic/game/cdrom_tray.h
@@ -28,8 +28,8 @@
namespace Titanic {
class CCDROMTray : public CGameObject {
-private:
- int _fieldBC;
+public:
+ int _state;
CString _string1;
public:
CLASSDEF
diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp
index 8149b8d017..ffec1bcdb8 100644
--- a/engines/titanic/game/television.cpp
+++ b/engines/titanic/game/television.cpp
@@ -90,7 +90,7 @@ bool CTelevision::handleMessage(CLeaveViewMsg &msg) {
loadFrame(622);
stopMovie();
- set5C(0);
+ setVisible(0);
_isOn = false;
if (compareRoomNameTo("CSGState")) {
@@ -124,7 +124,7 @@ bool CTelevision::handleMessage(CEnterViewMsg &msg) {
petFn1(2);
petFn2(2);
petFn3(0);
- set5C(0);
+ setVisible(0);
_fieldE0 = 1;
return true;
@@ -175,12 +175,12 @@ bool CTelevision::handleMessage(CActMsg &msg) {
if (msg._action == "TurnTVOnOff") {
_isOn = !_isOn;
if (_isOn) {
- set5C(true);
+ setVisible(true);
CStatusChangeMsg changeMsg;
changeMsg.execute(this);
} else {
// TODO: Should 5C be a boolean?
- set5C(_isOn);
+ setVisible(_isOn);
stopMovie();
}
}
@@ -194,7 +194,7 @@ bool CTelevision::handleMessage(CPETActivateMsg &msg) {
_isOn = !_isOn;
if (_isOn) {
- set5C(true);
+ setVisible(true);
fn1(0, 55, 0);
_fieldE0 = 1;
} else {
@@ -202,7 +202,7 @@ bool CTelevision::handleMessage(CPETActivateMsg &msg) {
if (soundFn1(_fieldF0))
soundFn2(_fieldF0, 0);
- set5C(false);
+ setVisible(false);
}
if (compareRoomNameTo("SGTState"))
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 77d53f21a6..99df239eda 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -366,6 +366,7 @@ MESSAGE1(CSetChevLiftBits, int, value, 0);
MESSAGE2(CSetChevPanelBitMsg, int, value1, 0, int, value2, 0);
MESSAGE1(CSetChevPanelButtonsMsg, int, value, 0);
MESSAGE1(CSetChevRoomBits, int, value, 0);
+MESSAGE1(CSetFrameMsg, int, frameNumber, 0);
MESSAGE0(CSetMusicControlsMsg);
MESSAGE2(CSetVarMsg, CString, varName, "", int, value, 0);
MESSAGE2(CSetVolumeMsg, int, value1, 70, int, value2, 0);
diff --git a/engines/titanic/messages/mouse_messages.h b/engines/titanic/messages/mouse_messages.h
index 7fe7ef960f..41943818e2 100644
--- a/engines/titanic/messages/mouse_messages.h
+++ b/engines/titanic/messages/mouse_messages.h
@@ -179,12 +179,12 @@ public:
MSGTARGET(CMouseDragEndMsg);
class CMouseDragEndMsg : public CMouseDragMsg {
public:
- CTreeItem *_dragItem;
+ CTreeItem *_dropTarget;
public:
CLASSDEF
- CMouseDragEndMsg() : CMouseDragMsg(), _dragItem(nullptr) {}
+ CMouseDragEndMsg() : CMouseDragMsg(), _dropTarget(nullptr) {}
CMouseDragEndMsg(const Point &pt, CTreeItem *dragItem = nullptr) :
- CMouseDragMsg(pt), _dragItem(dragItem) {}
+ CMouseDragMsg(pt), _dropTarget(dragItem) {}
static bool isSupportedBy(const CTreeItem *item) {
return dynamic_cast<const CMouseDragEndMsgTarget *>(item) != nullptr;