[Scummvm-cvs-logs] scummvm master -> 87d9b6682ac1093995f43444c3d8dd915e968dc2

dreammaster dreammaster at scummvm.org
Tue Aug 16 05:51:39 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
87d9b6682a TITANIC: Implemented CBrainSlot class


Commit: 87d9b6682ac1093995f43444c3d8dd915e968dc2
    https://github.com/scummvm/scummvm/commit/87d9b6682ac1093995f43444c3d8dd915e968dc2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-15T23:51:31-04:00

Commit Message:
TITANIC: Implemented CBrainSlot class

Changed paths:
    engines/titanic/core/named_item.cpp
    engines/titanic/core/named_item.h
    engines/titanic/core/tree_item.h
    engines/titanic/game/brain_slot.cpp
    engines/titanic/game/brain_slot.h
    engines/titanic/support/string.cpp
    engines/titanic/support/string.h



diff --git a/engines/titanic/core/named_item.cpp b/engines/titanic/core/named_item.cpp
index 6eafbf8..9c4c28d 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 acd59f3..9ee3d49 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 45ce516..b2d40da 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 f196314..57521ea 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 94b6d7f..fce9ab0 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 cd39c03..1400c25 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 9550ce8..487c138 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
 	 */






More information about the Scummvm-git-logs mailing list