aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-30 20:11:02 -0400
committerPaul Gilbert2016-03-30 20:11:02 -0400
commit08a801b1128d63e5c2cedee218a6dce7d6f04f28 (patch)
tree6d76d2807bb2a273a1e8c38f0d3415c0ee3ce03f /engines/titanic
parentfee937c6ef5a47d3fdb3dd33af16fee1928c2691 (diff)
downloadscummvm-rg350-08a801b1128d63e5c2cedee218a6dce7d6f04f28.tar.gz
scummvm-rg350-08a801b1128d63e5c2cedee218a6dce7d6f04f28.tar.bz2
scummvm-rg350-08a801b1128d63e5c2cedee218a6dce7d6f04f28.zip
TITANIC: Flesh out the CPETElement class
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/core/game_object.cpp12
-rw-r--r--engines/titanic/core/game_object.h17
-rw-r--r--engines/titanic/game/pet/pet_val_base.h10
-rw-r--r--engines/titanic/module.mk2
-rw-r--r--engines/titanic/movie.cpp15
-rw-r--r--engines/titanic/movie.h8
-rw-r--r--engines/titanic/pet_control/pet_element.cpp100
-rw-r--r--engines/titanic/pet_control/pet_element.h104
-rw-r--r--engines/titanic/pet_control/pet_val.cpp8
-rw-r--r--engines/titanic/pet_control/pet_val.h6
-rw-r--r--engines/titanic/pet_control/pet_val_base.cpp76
-rw-r--r--engines/titanic/pet_control/pet_val_base.h67
12 files changed, 253 insertions, 172 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 1cdc6cde92..759c853759 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -363,4 +363,16 @@ void CGameObject::setPetArea(PetArea newArea) const {
pet->setArea(newArea);
}
+bool CGameObject::hasActiveMovie() const {
+ if (_surface && _surface->_movie)
+ return _surface->_movie->isActive();
+ return false;
+}
+
+int CGameObject::getMovie19() const {
+ if (_surface && _surface->_movie)
+ return _surface->_movie->proc19();
+ return _field78;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 3f12123d1b..68ddf9745d 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -81,11 +81,6 @@ protected:
int _fieldB8;
protected:
/**
- * Loads a frame
- */
- void loadFrame(int frameNumber);
-
- /**
* Saves the current position the object is located at
*/
void savePosition();
@@ -164,6 +159,18 @@ public:
* Set the position of the object
*/
void setPosition(const Common::Point &newPos);
+
+ /**
+ * Returns true if the object has a currently active movie
+ */
+ bool hasActiveMovie() const;
+
+ int getMovie19() const;
+
+ /**
+ * Loads a frame
+ */
+ void loadFrame(int frameNumber);
};
} // End of namespace Titanic
diff --git a/engines/titanic/game/pet/pet_val_base.h b/engines/titanic/game/pet/pet_val_base.h
index 310b0675b1..cdb2808108 100644
--- a/engines/titanic/game/pet/pet_val_base.h
+++ b/engines/titanic/game/pet/pet_val_base.h
@@ -20,12 +20,12 @@
*
*/
-#ifndef TITANIC_PET_VAL_BASE_H
-#define TITANIC_PET_VAL_BASE_H
+#ifndef TITANIC_pet_element_H
+#define TITANIC_pet_element_H
namespace Titanic {
-class CPetValBase {
+class CPetElement {
protected:
int _field4;
int _field8;
@@ -33,7 +33,7 @@ protected:
int _field10;
int _field14;
public:
- CPetValBase();
+ CPetElement();
virtual void proc1() {}
virtual void proc2() {}
@@ -58,4 +58,4 @@ public:
} // End of namespace Titanic
-#endif /* TITANIC_PET_VAL_BASE_H */
+#endif /* TITANIC_pet_element_H */
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index a72e80d408..d0e4164ab2 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -383,6 +383,7 @@ MODULE_OBJS := \
pet_control/pet_control_list_item.o \
pet_control/pet_control_list_item2.o \
pet_control/pet_conversation_section.o \
+ pet_control/pet_element.o \
pet_control/pet_inventory_section.o \
pet_control/pet_rooms_section.o \
pet_control/pet_remote_section.o \
@@ -394,7 +395,6 @@ MODULE_OBJS := \
pet_control/pet_control_sub10.o \
pet_control/pet_control_sub11.o \
pet_control/pet_control_sub12.o \
- pet_control/pet_val_base.o \
pet_control/pet_val.o \
sound/auto_music_player.o \
sound/auto_music_player_base.o \
diff --git a/engines/titanic/movie.cpp b/engines/titanic/movie.cpp
index 09c02a7964..28284f9a78 100644
--- a/engines/titanic/movie.cpp
+++ b/engines/titanic/movie.cpp
@@ -25,6 +25,12 @@
namespace Titanic {
+bool CMovie::isActive() const {
+ return g_vm->_movieList.contains(this);
+}
+
+/*------------------------------------------------------------------------*/
+
OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) : _videoSurface(surface) {
// _aviDecoder.loadFile(name.getString());
}
@@ -79,8 +85,9 @@ void OSMovie::proc18() {
warning("TODO: OSMovie::proc18");
}
-void OSMovie::proc19() {
+int OSMovie::proc19() {
warning("TODO: OSMovie::proc19");
+ return 0;
}
void OSMovie::proc20() {
@@ -92,10 +99,4 @@ void *OSMovie::proc21() {
return nullptr;
}
-bool OSMovie::isInGlobalList() const {
- return g_vm->_movieList.contains(this);
-}
-
-/*------------------------------------------------------------------------*/
-
} // End of namespace Titanic
diff --git a/engines/titanic/movie.h b/engines/titanic/movie.h
index 4a5777aa03..ea0b1ea5e0 100644
--- a/engines/titanic/movie.h
+++ b/engines/titanic/movie.h
@@ -44,9 +44,11 @@ public:
virtual void proc16() = 0;
virtual void proc17() = 0;
virtual void proc18() = 0;
- virtual void proc19() = 0;
+ virtual int proc19() = 0;
virtual void proc20() = 0;
virtual void *proc21() = 0;
+
+ bool isActive() const;
};
class OSMovie : public CMovie {
@@ -72,11 +74,9 @@ public:
virtual void proc16();
virtual void proc17();
virtual void proc18();
- virtual void proc19();
+ virtual int proc19();
virtual void proc20();
virtual void *proc21();
-
- bool isInGlobalList() const;
};
class CGlobalMovies : public List<CMovie> {
diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp
new file mode 100644
index 0000000000..39d8fea7d9
--- /dev/null
+++ b/engines/titanic/pet_control/pet_element.cpp
@@ -0,0 +1,100 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/textconsole.h"
+#include "titanic/pet_control/pet_element.h"
+#include "titanic/core/game_object.h"
+
+namespace Titanic {
+
+CPetElement::CPetElement() : _mode(MODE_0) {}
+
+void CPetElement::getBounds(Rect *rect) {
+ if (rect)
+ *rect = Rect();
+}
+
+bool CPetElement::proc6(const Common::Point &pt) {
+ bool result = _bounds.contains(pt);
+ if (result)
+ setMode(MODE_1);
+ return result;
+}
+
+bool CPetElement::proc7(const Common::Point &pt) {
+ bool result = _bounds.contains(pt);
+ if (result)
+ setMode(MODE_0);
+ return result;
+}
+
+bool CPetElement::contains1(const Common::Point &pt) const {
+ return _bounds.contains(pt);
+}
+
+int CPetElement::proc9(const Common::Point &pt) {
+ bool result = _bounds.contains(pt);
+ if (result)
+ setMode(MODE_2);
+ return result;
+}
+
+bool CPetElement::contains2(const Common::Point &pt) const {
+ return _bounds.contains(pt);
+}
+
+void CPetElement::proc11(int val1, int val2) const {
+ CGameObject *gameObject = getObject();
+
+ if (gameObject)
+ gameObject->fn1(val1, val2, 0);
+}
+
+void CPetElement::changeStatus(int newStatus) const {
+ CGameObject *gameObject = getObject();
+
+ if (gameObject)
+ gameObject->changeStatus(newStatus);
+}
+
+bool CPetElement::hasActiveMovie() const {
+ CGameObject *gameObject = getObject();
+ return gameObject ? gameObject->hasActiveMovie() : false;
+}
+
+void CPetElement::loadFrame(int frameNumber) {
+ CGameObject *gameObject = getObject();
+ if (gameObject)
+ gameObject->loadFrame(frameNumber);
+}
+
+int CPetElement::proc15() {
+ CGameObject *gameObject = getObject();
+ return gameObject ? gameObject->getMovie19() : 0;
+}
+
+void CPetElement::setMode(PetElementMode newMode) {
+ if (newMode >= MODE_0 && newMode <= MODE_2)
+ changeMode(newMode);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h
new file mode 100644
index 0000000000..66f57c44b4
--- /dev/null
+++ b/engines/titanic/pet_control/pet_element.h
@@ -0,0 +1,104 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_PET_ELEMENT_H
+#define TITANIC_PET_ELEMENT_H
+
+#include "titanic/simple_file.h"
+#include "titanic/core/link_item.h"
+
+namespace Titanic {
+
+enum PetElementMode { MODE_0 = 0, MODE_1 = 1, MODE_2 = 2 };
+
+class CGameObject;
+
+class CPetElement {
+protected:
+ Common::Rect _bounds;
+ PetElementMode _mode;
+public:
+ CPetElement();
+ virtual ~CPetElement() {}
+
+ virtual void proc1() {}
+ virtual void proc2() {}
+
+ /**
+ * Draw the item
+ */
+ virtual void draw() {}
+
+ virtual void proc4() {}
+
+ /**
+ * Get the bounds for the element
+ */
+ virtual void getBounds(Rect *rect);
+
+ virtual bool proc6(const Common::Point &pt);
+ virtual bool proc7(const Common::Point &pt);
+
+ /**
+ * Returns whether the passed point falls inside the item
+ */
+ virtual bool contains1(const Common::Point &pt) const;
+
+ virtual int proc9(const Common::Point &pt);
+
+ /**
+ * Returns whether the passed point falls inside the item
+ */
+ virtual bool contains2(const Common::Point &pt) const;
+
+ virtual void proc11(int val1, int val2) const;
+
+ /**
+ * Change the status of the associated object
+ */
+ virtual void changeStatus(int newStatus) const;
+
+ /**
+ * Returns true if the object associated with the item has an active movie
+ */
+ virtual bool hasActiveMovie() const;
+
+ /**
+ * Loads a frame
+ */
+ virtual void loadFrame(int frameNumber);
+
+ virtual int proc15();
+
+ /**
+ * Get the game object associated with this item
+ */
+ virtual CGameObject *getObject() const { return nullptr; }
+
+ virtual void changeMode(PetElementMode newMode) { _mode = newMode; }
+
+ void setMode(PetElementMode mode);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_PET_ELEMENT_H */
diff --git a/engines/titanic/pet_control/pet_val.cpp b/engines/titanic/pet_control/pet_val.cpp
index 5bc237572e..754bda5b7d 100644
--- a/engines/titanic/pet_control/pet_val.cpp
+++ b/engines/titanic/pet_control/pet_val.cpp
@@ -46,12 +46,12 @@ void CPetVal::proc5(Rect *rect) {
}
int CPetVal::proc16() {
- switch (_field14) {
- case 0:
+ switch (_mode) {
+ case MODE_0:
return _field18;
- case 1:
+ case MODE_1:
return _field1C;
- case 2:
+ case MODE_2:
return _field20;
default:
return 0;
diff --git a/engines/titanic/pet_control/pet_val.h b/engines/titanic/pet_control/pet_val.h
index 0e909d485b..6d19ddb961 100644
--- a/engines/titanic/pet_control/pet_val.h
+++ b/engines/titanic/pet_control/pet_val.h
@@ -23,17 +23,17 @@
#ifndef TITANIC_PET_VAL_H
#define TITANIC_PET_VAL_H
-#include "titanic/pet_control/pet_val_base.h"
+#include "titanic/pet_control/pet_element.h"
namespace Titanic {
-class CPetVal: public CPetValBase {
+class CPetVal: public CPetElement {
protected:
int _field18;
int _field1C;
int _field20;
public:
- CPetVal() : CPetValBase(), _field18(0), _field1C(0), _field20(0) {}
+ CPetVal() : CPetElement(), _field18(0), _field1C(0), _field20(0) {}
virtual void proc1();
virtual void proc2();
diff --git a/engines/titanic/pet_control/pet_val_base.cpp b/engines/titanic/pet_control/pet_val_base.cpp
deleted file mode 100644
index 9a23854450..0000000000
--- a/engines/titanic/pet_control/pet_val_base.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "common/textconsole.h"
-#include "titanic/pet_control/pet_val_base.h"
-
-namespace Titanic {
-
-CPetValBase::CPetValBase() : _field4(0), _field8(0), _fieldC(0),
- _field10(0), _field14(0) {}
-
-void CPetValBase::proc5(Rect *rect) {
- if (rect)
- *rect = Rect();
-}
-
-int CPetValBase::proc6() {
- error("TODO");
-}
-
-int CPetValBase::proc7() {
- error("TODO");
-}
-
-void CPetValBase::proc8() {
- error("TODO");
-}
-
-int CPetValBase::proc9() {
- error("TODO");
-}
-
-void CPetValBase::proc10() {
- error("TODO");
-}
-
-void CPetValBase::proc11() {
- error("TODO");
-}
-
-void CPetValBase::proc12() {
- error("TODO");
-}
-
-void CPetValBase::proc13() {
- error("TODO");
-}
-
-void CPetValBase::proc14() {
- error("TODO");
-}
-
-void CPetValBase::proc15() {
- error("TODO");
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_val_base.h b/engines/titanic/pet_control/pet_val_base.h
deleted file mode 100644
index 637e95f22d..0000000000
--- a/engines/titanic/pet_control/pet_val_base.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TITANIC_PET_VAL_BASE_H
-#define TITANIC_PET_VAL_BASE_H
-
-#include "titanic/simple_file.h"
-#include "titanic/core/link_item.h"
-
-namespace Titanic {
-
-class CPetValBase {
-protected:
- int _field4;
- int _field8;
- int _fieldC;
- int _field10;
- int _field14;
-public:
- CPetValBase();
- virtual ~CPetValBase() {}
-
- virtual void proc1() {}
- virtual void proc2() {}
- virtual void proc3() {}
- virtual void proc4() {}
-
- virtual void proc5(Rect *rect);
-
- virtual int proc6();
- virtual int proc7();
- virtual void proc8();
- virtual int proc9();
- virtual void proc10();
- virtual void proc11();
- virtual void proc12();
- virtual void proc13();
- virtual void proc14();
- virtual void proc15();
-
- virtual int proc16() { return 0; }
-
- virtual void proc17(int v) { _field14 = v; }
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_PET_VAL_BASE_H */