aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-31 19:55:45 -0400
committerPaul Gilbert2016-03-31 19:55:45 -0400
commitd94b1dc7bb68ee1641edcbbd31fd40ef7e5dc442 (patch)
tree335be85de12421d523785ef718ae101404ae8032
parent5c902685fc2f3f97ee3fd9250480801ac849bf02 (diff)
downloadscummvm-rg350-d94b1dc7bb68ee1641edcbbd31fd40ef7e5dc442.tar.gz
scummvm-rg350-d94b1dc7bb68ee1641edcbbd31fd40ef7e5dc442.tar.bz2
scummvm-rg350-d94b1dc7bb68ee1641edcbbd31fd40ef7e5dc442.zip
TITANIC: Implemented CPetGfxElement setup method
-rw-r--r--engines/titanic/core/tree_item.cpp10
-rw-r--r--engines/titanic/core/tree_item.h3
-rw-r--r--engines/titanic/pet_control/pet_element.h2
-rw-r--r--engines/titanic/pet_control/pet_gfx_element.cpp19
-rw-r--r--engines/titanic/pet_control/pet_gfx_element.h7
-rw-r--r--engines/titanic/string.cpp6
-rw-r--r--engines/titanic/string.h2
7 files changed, 44 insertions, 5 deletions
diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp
index 61fcf97183..55deee07df 100644
--- a/engines/titanic/core/tree_item.cpp
+++ b/engines/titanic/core/tree_item.cpp
@@ -289,4 +289,14 @@ CRoomItem *CTreeItem::getRoom() const {
return gameManager ? gameManager->getRoom() : nullptr;
}
+int CTreeItem::getState8() const {
+ CGameManager *gameManager = getGameManager();
+ return gameManager ? gameManager->_gameState._field8 : 3;
+}
+
+int CTreeItem::getStateC() const {
+ CGameManager *gameManager = getGameManager();
+ return gameManager ? gameManager->_gameState._fieldC : 3;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h
index f5e28f1056..d710fcf0b8 100644
--- a/engines/titanic/core/tree_item.h
+++ b/engines/titanic/core/tree_item.h
@@ -247,6 +247,9 @@ public:
* Return the current room
*/
CRoomItem *getRoom() const;
+
+ int getState8() const;
+ int getStateC() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
index e5ab8d3fdd..c6b0054ca6 100644
--- a/engines/titanic/pet_control/pet_element.h
+++ b/engines/titanic/pet_control/pet_element.h
@@ -51,7 +51,7 @@ public:
/**
* Sets up the element
*/
- virtual void setup() {}
+ virtual void setup(int val, const CString &name, CPetControl *petControl) {}
/**
* Draw the item
diff --git a/engines/titanic/pet_control/pet_gfx_element.cpp b/engines/titanic/pet_control/pet_gfx_element.cpp
index bec54b9c28..5f2f05e6c3 100644
--- a/engines/titanic/pet_control/pet_gfx_element.cpp
+++ b/engines/titanic/pet_control/pet_gfx_element.cpp
@@ -44,8 +44,23 @@ void CPetGfxElement::setup(PetElementMode mode, const CString &name,
}
}
-void CPetGfxElement::setup() {
- error("TODO");
+void CPetGfxElement::setup(const CString &name, CPetControl *petControl) {
+ if (!petControl)
+ return;
+
+ CString numString(3);
+ int state8 = petControl->getState8();
+
+ if (state8 >= 1 && state8 <= 3) {
+ numString = CString(state8);
+ } else if (state8 == 4) {
+ int stateC = petControl->getStateC();
+ if (stateC == 1)
+ numString = CString(stateC);
+ }
+
+ CString resName = numString + name;
+ setup(resName, petControl);
}
void CPetGfxElement::draw(CScreenManager *screenManager) {
diff --git a/engines/titanic/pet_control/pet_gfx_element.h b/engines/titanic/pet_control/pet_gfx_element.h
index 47720cf81a..b0bf6e4abe 100644
--- a/engines/titanic/pet_control/pet_gfx_element.h
+++ b/engines/titanic/pet_control/pet_gfx_element.h
@@ -37,12 +37,15 @@ public:
_object2(nullptr) {}
/**
- * Load an object into the element
+ * Setup the element
*/
virtual void setup(PetElementMode mode, const CString &name,
CPetControl *petControl);
- virtual void setup();
+ /**
+ * Setup the element
+ */
+ virtual void setup(const CString &name, CPetControl *petControl);
/**
* Draw the item
diff --git a/engines/titanic/string.cpp b/engines/titanic/string.cpp
index 5831b7dc3a..f29d2c7938 100644
--- a/engines/titanic/string.cpp
+++ b/engines/titanic/string.cpp
@@ -25,6 +25,12 @@
namespace Titanic {
+CString::CString(char c, uint32 len) : Common::String() {
+ ensureCapacity(len, false);
+ for (uint idx = 0; idx < len; ++idx)
+ (*this) += c;
+}
+
CString CString::left(uint count) const {
return (count > size()) ? CString() : CString(c_str(), c_str() + count);
}
diff --git a/engines/titanic/string.h b/engines/titanic/string.h
index 08b5649dc9..0c0c64e0be 100644
--- a/engines/titanic/string.h
+++ b/engines/titanic/string.h
@@ -44,7 +44,9 @@ public:
CString(const char *str, uint32 len) : Common::String(str, len) {}
CString(const char *beginP, const char *endP) : Common::String(beginP, endP) {}
CString(const String &str) : Common::String(str) {}
+ CString(char c, uint32 len);
explicit CString(char c) : Common::String(c) {}
+ explicit CString(int val) : Common::String(Common::String::format("%d", val)) {}
/**
* Returns the left n characters of the string