diff options
author | Paul Gilbert | 2016-08-15 23:51:31 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-15 23:51:31 -0400 |
commit | 87d9b6682ac1093995f43444c3d8dd915e968dc2 (patch) | |
tree | 1b82fc532f10bc13824cad1550625b8d9b08cfc3 /engines/titanic | |
parent | a4885b1d6f783f20716c2d86316946362215bdaa (diff) | |
download | scummvm-rg350-87d9b6682ac1093995f43444c3d8dd915e968dc2.tar.gz scummvm-rg350-87d9b6682ac1093995f43444c3d8dd915e968dc2.tar.bz2 scummvm-rg350-87d9b6682ac1093995f43444c3d8dd915e968dc2.zip |
TITANIC: Implemented CBrainSlot class
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/named_item.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/core/named_item.h | 4 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 5 | ||||
-rw-r--r-- | engines/titanic/game/brain_slot.cpp | 115 | ||||
-rw-r--r-- | engines/titanic/game/brain_slot.h | 10 | ||||
-rw-r--r-- | engines/titanic/support/string.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/support/string.h | 5 |
7 files changed, 146 insertions, 15 deletions
diff --git a/engines/titanic/core/named_item.cpp b/engines/titanic/core/named_item.cpp index 6eafbf8c8b..9c4c28d04d 100644 --- a/engines/titanic/core/named_item.cpp +++ b/engines/titanic/core/named_item.cpp @@ -51,11 +51,11 @@ void CNamedItem::load(SimpleFile *file) { CTreeItem::load(file); } -int CNamedItem::compareTo(const CString &name, int maxLen) const { +bool CNamedItem::isEquals(const CString &name, int maxLen) const { if (maxLen) { - return getName().left(maxLen).compareToIgnoreCase(name); + return getName().left(maxLen).compareToIgnoreCase(name) == 0; } else { - return getName().compareToIgnoreCase(name); + return getName().compareToIgnoreCase(name) == 0; } } diff --git a/engines/titanic/core/named_item.h b/engines/titanic/core/named_item.h index acd59f344e..9ee3d490ae 100644 --- a/engines/titanic/core/named_item.h +++ b/engines/titanic/core/named_item.h @@ -59,9 +59,9 @@ public: virtual const CString getName() const { return _name; } /** - * Compares the name of the item to a passed name + * Returns true if the item's name matches a passed name */ - virtual int compareTo(const CString &name, int maxLen = 0) const; + virtual bool isEquals(const CString &name, int maxLen = 0) const; /** * Find a parent node for the item diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index 45ce5164ac..b2d40daab9 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -125,6 +125,11 @@ public: virtual const CString getName() const { return CString(); } /** + * Returns true if the item's name matches a passed name + */ + virtual bool isEquals(const CString &name, int maxLen = 0) const { return false; } + + /** * Compares the name of the item to a passed name */ virtual int compareTo(const CString &name, int maxLen = 0) const { return false; } diff --git a/engines/titanic/game/brain_slot.cpp b/engines/titanic/game/brain_slot.cpp index f1963142ac..57521ead88 100644 --- a/engines/titanic/game/brain_slot.cpp +++ b/engines/titanic/game/brain_slot.cpp @@ -21,18 +21,27 @@ */ #include "titanic/game/brain_slot.h" +#include "titanic/core/project_item.h" namespace Titanic { -int CBrainSlot::_v1; -int CBrainSlot::_v2; +BEGIN_MESSAGE_MAP(CBrainSlot, CGameObject) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(AddHeadPieceMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + +bool CBrainSlot::_added; +bool CBrainSlot::_woken; void CBrainSlot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value1, indent); - file->writeQuotedLine(_value2, indent); - file->writeNumberLine(_v1, indent); - file->writeNumberLine(_v2, indent); + file->writeQuotedLine(_target, indent); + file->writeNumberLine(_added, indent); + file->writeNumberLine(_woken, indent); CGameObject::save(file, indent); } @@ -40,11 +49,101 @@ void CBrainSlot::save(SimpleFile *file, int indent) { void CBrainSlot::load(SimpleFile *file) { file->readNumber(); _value1 = file->readNumber(); - _value2 = file->readString(); - _v1 = file->readNumber(); - _v2 = file->readNumber(); + _target = file->readString(); + _added = file->readNumber(); + _woken = file->readNumber(); CGameObject::load(file); } +bool CBrainSlot::SetFrameMsg(CSetFrameMsg *msg) { + loadFrame(msg->_frameNumber); + _value1 = 1; + return true; +} + +bool CBrainSlot::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { + _added = true; + _cursorId = CURSOR_HAND; + CAddHeadPieceMsg addMsg("NULL"); + + if (isEquals("AuditoryCentreSlot")) { + if (msg->_value == "AuditoryCentre") + addMsg._value = "AuditoryCentre"; + } else if (isEquals("SpeechCentreSlot")) { + if (msg->_value == "SpeechCentre") + addMsg._value = "SpeechCentre"; + } else if (isEquals("OlfactoryCentreSlot")) { + if (msg->_value == "OlfactoryCentre") + addMsg._value = "OlfactoryCentre"; + } else if (isEquals("VisionCentreSlot")) { + if (msg->_value == "VisionCentre") + addMsg._value = "VisionCentre"; + } else if (isEquals("CentralCoreSlot")) { + if (msg->_value == "CentralCore") + addMsg._value = "CentralCore"; + } + + if (addMsg._value != "NULL") + addMsg.execute("TitaniaControl"); + + if (addMsg._value == "OlfactoryCentre") + loadFrame(2); + else if (addMsg._value == "AuditoryCentre") + loadFrame(1); + else if (addMsg._value == "SpeechCentre") + loadFrame(3); + else if (addMsg._value == "VisionCentre") + loadFrame(4); + else if (addMsg._value == "CentralCore") { + CActMsg actMsg("Insert Central Core"); + actMsg.execute("CentralCoreSlot"); + } + + _target = msg->_value; + _value1 = 1; + return true; +} + +bool CBrainSlot::EnterViewMsg(CEnterViewMsg *msg) { + if (getName() == "CentralCoreSlot") + loadFrame(21); + if (_woken) + _cursorId = CURSOR_ARROW; + + return true; +} + +bool CBrainSlot::ActMsg(CActMsg *msg) { + if (msg->_action == "Insert Central Core") + playMovie(0, 21, 0); + else if (msg->_action == "Woken") + _woken = true; + + return true; +} + +bool CBrainSlot::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!_value1 || _woken || !checkPoint(msg->_mousePos, false, true)) + return false; + + _cursorId = CURSOR_ARROW; + CVisibleMsg visibleMsg(true); + visibleMsg.execute(_target); + CTakeHeadPieceMsg takeMsg(_target); + takeMsg.execute("TitaniaControl"); + + loadFrame(isEquals("CentralCoreSlot") ? 21 : 0); + _value1 = 0; + + CPassOnDragStartMsg passMsg; + passMsg._mousePos = msg->_mousePos; + passMsg.execute(_target); + + msg->_dragItem = getRoot()->findByName(_target); + _added = false; + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/brain_slot.h b/engines/titanic/game/brain_slot.h index 94b6d7f227..fce9ab02c7 100644 --- a/engines/titanic/game/brain_slot.h +++ b/engines/titanic/game/brain_slot.h @@ -28,11 +28,17 @@ namespace Titanic { class CBrainSlot : public CGameObject { + DECLARE_MESSAGE_MAP; + bool SetFrameMsg(CSetFrameMsg *msg); + bool AddHeadPieceMsg(CAddHeadPieceMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ActMsg(CActMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: - static int _v1, _v2; + static bool _added, _woken; public: int _value1; - CString _value2; + CString _target; public: CLASSDEF; CBrainSlot() : CGameObject(), _value1(0) {} diff --git a/engines/titanic/support/string.cpp b/engines/titanic/support/string.cpp index cd39c03861..1400c25733 100644 --- a/engines/titanic/support/string.cpp +++ b/engines/titanic/support/string.cpp @@ -122,4 +122,20 @@ CString CString::format(const char *fmt, ...) { return output; } +bool CString::operator==(const CString &x) const { + return compareToIgnoreCase(x) == 0; +} + +bool CString::operator==(const char *x) const { + return compareToIgnoreCase(x) == 0; +} + +bool CString::operator!=(const CString &x) const { + return compareToIgnoreCase(x) != 0; +} + +bool CString::operator!=(const char *x) const { + return compareToIgnoreCase(x) != 0; +} + } // End of namespace Titanic diff --git a/engines/titanic/support/string.h b/engines/titanic/support/string.h index 9550ce88a7..487c138358 100644 --- a/engines/titanic/support/string.h +++ b/engines/titanic/support/string.h @@ -49,6 +49,11 @@ public: explicit CString(char c) : Common::String(c) {} explicit CString(int val); + bool operator==(const CString &x) const; + bool operator==(const char *x) const; + bool operator!=(const CString &x) const; + bool operator!=(const char *x) const; + /** * Returns the left n characters of the string */ |