aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-02-24 23:51:32 -0500
committerPaul Gilbert2016-02-24 23:51:32 -0500
commit45043cc6e1da458a16e64e55ef5bed624421794d (patch)
tree80263202c0edaafc90b6e5f05484d65ae9d9374b
parent25422a6520615cf5c5467654790e658085f28d95 (diff)
downloadscummvm-rg350-45043cc6e1da458a16e64e55ef5bed624421794d.tar.gz
scummvm-rg350-45043cc6e1da458a16e64e55ef5bed624421794d.tar.bz2
scummvm-rg350-45043cc6e1da458a16e64e55ef5bed624421794d.zip
TITANIC: Added CViewItem class
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/objects/saveable_object.cpp4
-rw-r--r--engines/titanic/objects/view_item.cpp70
-rw-r--r--engines/titanic/objects/view_item.h62
-rw-r--r--engines/titanic/simple_file.cpp11
-rw-r--r--engines/titanic/simple_file.h10
6 files changed, 157 insertions, 1 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 5dc7195426..b14ec0f601 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -29,6 +29,7 @@ MODULE_OBJS := \
objects/resource_key.o \
objects/saveable_object.o \
objects/tree_item.o \
+ objects/view_item.o \
rooms/door_auto_sound_event.o \
rooms/room_item.o \
rooms/service_elevator_door.o
diff --git a/engines/titanic/objects/saveable_object.cpp b/engines/titanic/objects/saveable_object.cpp
index 555394d45e..cd5f7eba6e 100644
--- a/engines/titanic/objects/saveable_object.cpp
+++ b/engines/titanic/objects/saveable_object.cpp
@@ -28,6 +28,7 @@
#include "titanic/objects/node_item.h"
#include "titanic/objects/project_item.h"
#include "titanic/objects/tree_item.h"
+#include "titanic/objects/view_item.h"
#include "titanic/rooms/room_item.h"
#include "titanic/rooms/service_elevator_door.h"
@@ -49,6 +50,7 @@ DEFFN(CProjectItem);
DEFFN(CRoomItem);
DEFFN(CServiceElevatorDoor);
DEFFN(CTreeItem);
+DEFFN(CViewItem);
void CSaveableObject::initClassList() {
_classList = new Common::HashMap<Common::String, CreateFunction>();
@@ -62,6 +64,7 @@ void CSaveableObject::initClassList() {
ADDFN(CRoomItem);
ADDFN(CServiceElevatorDoor);
ADDFN(CTreeItem);
+ ADDFN(CViewItem);
}
void CSaveableObject::freeClassList() {
@@ -69,7 +72,6 @@ void CSaveableObject::freeClassList() {
}
CSaveableObject *CSaveableObject::createInstance(const Common::String &name) {
-warning("%s", name.c_str());
return (*_classList)[name]();
}
diff --git a/engines/titanic/objects/view_item.cpp b/engines/titanic/objects/view_item.cpp
new file mode 100644
index 0000000000..1199ba9a62
--- /dev/null
+++ b/engines/titanic/objects/view_item.cpp
@@ -0,0 +1,70 @@
+/* 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 "titanic/objects/view_item.h"
+
+namespace Titanic {
+
+CViewItem::CViewItem() : CNamedItem() {
+ _field24 = 0;
+ _field28 = 0.0;
+ _field30 = 0;
+ _field50 = 0;
+ _field54 = 0;
+ setData(0.0);
+}
+
+void CViewItem::setData(double v) {
+ _field28 = v;
+ _field50 = cos(_field28) * 30.0;
+ _field54 = sin(_field28) * -30.0;
+}
+
+void CViewItem::save(SimpleFile *file, int indent) const {
+ file->writeNumberLine(1, indent);
+ _resourceKey.save(file, indent);
+ file->writeQuotedLine("V", indent);
+ file->writeFloatLine(_field28, indent + 1);
+ file->writeNumberLine(_field30, indent + 1);
+
+ CNamedItem::save(file, indent);
+}
+
+void CViewItem::load(SimpleFile *file) {
+ int val = file->readNumber();
+
+ switch (val) {
+ case 1:
+ _resourceKey.load(file);
+ // Deliberate fall-through
+
+ default:
+ file->readBuffer();
+ setData(file->readFloat());
+ _field30 = file->readNumber();
+ break;
+ }
+
+ CNamedItem::load(file);
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/objects/view_item.h b/engines/titanic/objects/view_item.h
new file mode 100644
index 0000000000..1bd2d6d268
--- /dev/null
+++ b/engines/titanic/objects/view_item.h
@@ -0,0 +1,62 @@
+/* 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_VIEW_ITEM_H
+#define TITANIC_VIEW_ITEM_H
+
+#include "titanic/objects/named_item.h"
+#include "titanic/objects/resource_key.h"
+
+namespace Titanic {
+
+class CViewItem : public CNamedItem {
+private:
+ void setData(double v);
+protected:
+ int _field24;
+ double _field28;
+ int _field30;
+ CResourceKey _resourceKey;
+ int _field50;
+ int _field54;
+public:
+ CViewItem();
+
+ /**
+ * Return the class name
+ */
+ virtual const char *getClassName() const { return "CNamedItem"; }
+
+ /**
+ * Save the data for the class to file
+ */
+ virtual void save(SimpleFile *file, int indent) const;
+
+ /**
+ * Load the data for the class from file
+ */
+ virtual void load(SimpleFile *file);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_NAMED_ITEM_H */
diff --git a/engines/titanic/simple_file.cpp b/engines/titanic/simple_file.cpp
index 045de1fe07..9bc365bf33 100644
--- a/engines/titanic/simple_file.cpp
+++ b/engines/titanic/simple_file.cpp
@@ -282,6 +282,17 @@ void SimpleFile::writeNumberLine(int val, int indent) {
write("\n", 1);
}
+void SimpleFile::writeFloat(double val) {
+ Common::String valStr = Common::String::format("%f ", val);
+ write(valStr.c_str(), valStr.size());
+}
+
+void SimpleFile::writeFloatLine(double val, int indent) {
+ writeIndent(indent);
+ writeFloat(val);
+ write("\n", 1);
+}
+
void SimpleFile::writePoint(const Common::Point &pt, int indent) {
writeIndent(indent);
writeNumber(pt.x);
diff --git a/engines/titanic/simple_file.h b/engines/titanic/simple_file.h
index c5ca7016e7..8ea2b5a35d 100644
--- a/engines/titanic/simple_file.h
+++ b/engines/titanic/simple_file.h
@@ -141,6 +141,16 @@ public:
void writeNumberLine(int val, int indent);
/**
+ * Write a floating point number
+ */
+ void writeFloat(double val);
+
+ /**
+ * Write a floating point number as a line
+ */
+ void writeFloatLine(double val, int indent);
+
+ /**
* Write out a point line
*/
void writePoint(const Common::Point &pt, int indent);