aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/game_object.cpp73
-rw-r--r--engines/titanic/core/game_object.h11
-rw-r--r--engines/titanic/core/link_item.cpp9
-rw-r--r--engines/titanic/core/link_item.h5
-rw-r--r--engines/titanic/core/tree_item.h6
-rw-r--r--engines/titanic/core/view_item.cpp11
-rw-r--r--engines/titanic/core/view_item.h6
-rw-r--r--engines/titanic/game/computer.cpp73
-rw-r--r--engines/titanic/game/computer.h10
-rw-r--r--engines/titanic/support/screen_manager.cpp2
10 files changed, 198 insertions, 8 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 0570008a09..02a64dcad2 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -424,4 +424,77 @@ void CGameObject::soundProximity(const CString &name, CProximity &prox) {
}
}
+void CGameObject::gotoView(const CString &viewName, const CString &clipName) {
+ CViewItem *newView = parseView(viewName);
+ CGameManager *gameManager = getGameManager();
+ CViewItem *oldView = gameManager ? gameManager->getView() : newView;
+ if (!oldView || !newView)
+ return;
+
+ CMovieClip *clip = nullptr;
+ if (clipName.empty()) {
+ CLinkItem *link = oldView->findLink(newView);
+ if (link)
+ clip = link->getClip();
+ } else {
+ clip = oldView->findNode()->findRoom()->findClip(clipName);
+ }
+
+ // Change the view
+ gameManager->_gameState.changeView(newView, clip);
+}
+
+CViewItem *CGameObject::parseView(const CString &viewString) {
+ int firstIndex = viewString.indexOf('.');
+ int lastIndex = viewString.lastIndexOf('.');
+ CString roomName, nodeName, viewName;
+
+ if (firstIndex == -1) {
+ roomName = viewString;
+ } else {
+ roomName = viewString.left(firstIndex);
+
+ if (lastIndex > firstIndex) {
+ nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1);
+ viewName = viewString.mid(lastIndex + 1);
+ } else {
+ nodeName = viewString.mid(firstIndex + 1);
+ }
+ }
+
+ CGameManager *gameManager = getGameManager();
+ if (!gameManager)
+ return nullptr;
+
+ CRoomItem *room = gameManager->getRoom();
+ CProjectItem *project = room->getRoot();
+
+ // Ensure we have the specified room
+ if (project) {
+ if (room->getName() != roomName) {
+ // Scan for the correct room
+ for (room = project->findFirstRoom(); room && room->getName() != roomName;
+ room = project->findNextRoom(room)) ;
+ }
+ }
+ if (!room)
+ return nullptr;
+
+ // Find the designated node within the room
+ CNodeItem *node = static_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type));
+ while (node && node->getName() != nodeName)
+ node = static_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node));
+ if (!node)
+ return nullptr;
+
+ CViewItem *view = static_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type));
+ while (view && view->getName() != viewName)
+ view = static_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view));
+ if (!view)
+ return nullptr;
+
+ // Find the view, so return it
+ return view;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 72192425f4..2fc047e523 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -112,6 +112,17 @@ protected:
*/
void setPetArea(PetArea newArea) const;
+ /**
+ * Goto a new view
+ */
+ void gotoView(const CString &viewName, const CString &clipName);
+
+ /**
+ * Parses a view into it's components of room, node, and view,
+ * and locates the designated view
+ */
+ CViewItem * parseView(const CString &viewString);
+
bool soundFn1(int val);
void soundFn2(int val, int val2);
void setVisible(bool val);
diff --git a/engines/titanic/core/link_item.cpp b/engines/titanic/core/link_item.cpp
index 285838b692..b172b9b4d0 100644
--- a/engines/titanic/core/link_item.cpp
+++ b/engines/titanic/core/link_item.cpp
@@ -108,6 +108,15 @@ void CLinkItem::load(SimpleFile *file) {
}
}
+bool CLinkItem::connectsTo(CViewItem *destView) const {
+ CNodeItem *destNode = destView->findNode();
+ CRoomItem *destRoom = destNode->findRoom();
+
+ return _viewNumber == destView->_viewNumber &&
+ _nodeNumber == destNode->_nodeNumber &&
+ _roomNumber == destRoom->_roomNumber;
+}
+
void CLinkItem::setDestination(int roomNumber, int nodeNumber,
int viewNumber, int v) {
_roomNumber = roomNumber;
diff --git a/engines/titanic/core/link_item.h b/engines/titanic/core/link_item.h
index 72829720d7..25de74104b 100644
--- a/engines/titanic/core/link_item.h
+++ b/engines/titanic/core/link_item.h
@@ -63,6 +63,11 @@ public:
virtual void load(SimpleFile *file);
/**
+ * Returns true if the given item connects to another specified view
+ */
+ virtual bool connectsTo(CViewItem *destView) const;
+
+ /**
* Set the destination for the link item
*/
virtual void setDestination(int roomNumber, int nodeNumber,
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index d34f963584..4de030f387 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -35,6 +35,7 @@ class CPetControl;
class CProjectItem;
class CScreenManager;
class CRoomItem;
+class CViewItem;
class CTreeItem: public CMessageTarget {
friend class CMessage;
@@ -126,6 +127,11 @@ public:
virtual int compareTo(const CString &name, int maxLen) const { return false; }
/**
+ * Returns true if the given item connects to another specified view
+ */
+ virtual bool connectsTo(CViewItem *destView) const { return false; }
+
+ /**
* Allows the item to draw itself
*/
virtual void draw(CScreenManager *screenManager) {}
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp
index 3f6d5d5cff..b829ae5a70 100644
--- a/engines/titanic/core/view_item.cpp
+++ b/engines/titanic/core/view_item.cpp
@@ -168,6 +168,17 @@ void CViewItem::enterView(CViewItem *newView) {
}
}
+CLinkItem *CViewItem::findLink(CViewItem *newView) {
+ for (CTreeItem *treeItem = getFirstChild(); treeItem;
+ treeItem = scan(treeItem)) {
+ CLinkItem *link = static_cast<CLinkItem *>(treeItem);
+ if (link && link->connectsTo(newView))
+ return link;
+ }
+
+ return nullptr;
+}
+
bool CViewItem::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (msg->_buttons & MB_LEFT) {
if (!handleMouseMsg(msg, true)) {
diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h
index 5abcf1d012..67b2113142 100644
--- a/engines/titanic/core/view_item.h
+++ b/engines/titanic/core/view_item.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_VIEW_ITEM_H
#define TITANIC_VIEW_ITEM_H
+#include "titanic/core/link_item.h"
#include "titanic/core/named_item.h"
#include "titanic/core/resource_key.h"
#include "titanic/messages/mouse_messages.h"
@@ -90,6 +91,11 @@ public:
* Called when a new view is being entered
*/
void enterView(CViewItem *newView);
+
+ /**
+ * Finds a link which connects to another designated view
+ */
+ CLinkItem *findLink(CViewItem *newView);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game/computer.cpp b/engines/titanic/game/computer.cpp
index a28292184e..2b0f7767fb 100644
--- a/engines/titanic/game/computer.cpp
+++ b/engines/titanic/game/computer.cpp
@@ -24,18 +24,83 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CComputer, CBackground)
+ ON_MESSAGE(ActMsg)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(MovieEndMsg)
+END_MESSAGE_MAP()
+
void CComputer::save(SimpleFile *file, int indent) const {
file->writeNumberLine(1, indent);
- file->writeQuotedLine(_string3, indent);
- file->writeNumberLine(_fieldEC, indent);
+ file->writeQuotedLine(_currentCD, indent);
+ file->writeNumberLine(_state, indent);
CBackground::save(file, indent);
}
void CComputer::load(SimpleFile *file) {
file->readNumber();
- _string3 = file->readString();
- _fieldEC = file->readNumber();
+ _currentCD = file->readString();
+ _state = file->readNumber();
CBackground::load(file);
}
+bool CComputer::ActMsg(CActMsg *msg) {
+ if (_state) {
+ soundProximity("a#35.wav", 100, 0, 0);
+ fn1(32, 42, 0);
+
+ if (msg->_action == "CD1")
+ fn1(43, 49, 0);
+ else if (msg->_action == "CD2")
+ fn1(50, 79, 0);
+ else if (msg->_action == "STCD")
+ fn1(80, 90, 4);
+
+ _currentCD = msg->_action;
+ _state = 0;
+ }
+
+ return true;
+}
+
+bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ if (_currentCD == "None") {
+ if (_state) {
+ soundProximity("a#35.wav", 100, 0, 0);
+ fn1(11, 21, 0);
+ _state = 0;
+ } else {
+ soundProximity("a#34.wav", 100, 0, 0);
+ fn1(0, 10, 0);
+ _state = 1;
+ }
+ } else {
+ if (_state) {
+ loadFrame(11);
+ CActMsg actMsg("EjectCD");
+ actMsg.execute(_currentCD);
+ _currentCD = "None";
+ } else {
+ soundProximity("a#34.wav", 100, 0, 0);
+ fn1(21, 31, 0);
+ _state = 1;
+ }
+ }
+
+ return true;
+}
+
+bool CComputer::MovieEndMsg(CMovieEndMsg *msg) {
+ if (msg->_value2 == 90) {
+ soundProximity("a#32.wav", 100, 0, 0);
+ soundProximity("a#33.wav", 100, 0, 0);
+ soundProximity("a#31.wav", 100, 0, 0);
+ soundProximity("a#0.wav", 100, 0, 0);
+
+ gotoView("Home.Node 4.E", "_TRACK,3,e-cu,4,E");
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/computer.h b/engines/titanic/game/computer.h
index 793fecc491..3db0ee1979 100644
--- a/engines/titanic/game/computer.h
+++ b/engines/titanic/game/computer.h
@@ -28,12 +28,16 @@
namespace Titanic {
class CComputer : public CBackground {
+ DECLARE_MESSAGE_MAP
+ bool ActMsg(CActMsg *msg);
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool MovieEndMsg(CMovieEndMsg *msg);
public:
- CString _string3;
- int _fieldEC;
+ CString _currentCD;
+ int _state;
public:
CLASSDEF
- CComputer() : CBackground(), _string3("None"), _fieldEC(0) {}
+ CComputer() : CBackground(), _currentCD("None"), _state(0) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp
index 05dfa66854..d2f2468c89 100644
--- a/engines/titanic/support/screen_manager.cpp
+++ b/engines/titanic/support/screen_manager.cpp
@@ -110,7 +110,7 @@ void OSScreenManager::setMode(int width, int height, int bpp, uint numBackSurfac
}
void OSScreenManager::drawCursors() {
- warning("OSScreenManager::drawCursors");
+ // Nothing needed here, since ScummVM handles cursor drawing
}
DirectDrawSurface *OSScreenManager::getDDSurface(SurfaceNum surfaceNum) {