From 8acf716d6554fdd7209ba6bb575891019941931e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 24 Feb 2016 20:39:12 -0500 Subject: TITANIC: Implemented CNodeItem class --- engines/titanic/module.mk | 1 + engines/titanic/objects/node_item.cpp | 54 ++++++++++++++++++++++++++++ engines/titanic/objects/node_item.h | 56 +++++++++++++++++++++++++++++ engines/titanic/objects/saveable_object.cpp | 19 +++++----- 4 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 engines/titanic/objects/node_item.cpp create mode 100644 engines/titanic/objects/node_item.h (limited to 'engines/titanic') diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 848c737b62..9dfbb2fd74 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -22,6 +22,7 @@ MODULE_OBJS := \ objects/message_target.o \ objects/movie_clip.o \ objects/named_item.o \ + objects/node_item.o \ objects/pet_control.o \ objects/project_item.o \ objects/resource_key.o \ diff --git a/engines/titanic/objects/node_item.cpp b/engines/titanic/objects/node_item.cpp new file mode 100644 index 0000000000..f2a55cf240 --- /dev/null +++ b/engines/titanic/objects/node_item.cpp @@ -0,0 +1,54 @@ +/* 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/node_item.h" + +namespace Titanic { + +CNodeItem::CNodeItem() : CNamedItem(), _field24(0), _field28(0), _field2C(0) { +} + +void CNodeItem::save(SimpleFile *file, int indent) const { + file->writeNumberLine(0, indent); + file->writeQuotedLine("N", indent); + file->writeNumberLine(_field24, indent + 1); + file->writeNumberLine(_field28, indent + 1); + + file->writeQuotedLine("N", indent); + file->writeNumberLine(_field2C, indent + 1); + + CNamedItem::save(file, indent); +} + +void CNodeItem::load(SimpleFile *file) { + file->readNumber(); + file->readBuffer(); + _field24 = file->readNumber(); + _field28 = file->readNumber(); + + file->readBuffer(); + _field2C = file->readNumber(); + + CNamedItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/objects/node_item.h b/engines/titanic/objects/node_item.h new file mode 100644 index 0000000000..bfb534881f --- /dev/null +++ b/engines/titanic/objects/node_item.h @@ -0,0 +1,56 @@ +/* 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_NODE_ITEM_H +#define TITANIC_NODE_ITEM_H + +#include "titanic/objects/named_item.h" + +namespace Titanic { + +class CNodeItem : public CNamedItem { +private: + int _field24; + int _field28; + int _field2C; +public: + CNodeItem(); + + /** + * Return the class name + */ + virtual const char *getClassName() const { return "CNodeItem"; } + + /** + * 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_FILE_ITEM_H */ diff --git a/engines/titanic/objects/saveable_object.cpp b/engines/titanic/objects/saveable_object.cpp index 45161be277..7e9aa4b9ab 100644 --- a/engines/titanic/objects/saveable_object.cpp +++ b/engines/titanic/objects/saveable_object.cpp @@ -25,6 +25,7 @@ #include "titanic/objects/list.h" #include "titanic/objects/message_target.h" #include "titanic/objects/movie_clip.h" +#include "titanic/objects/node_item.h" #include "titanic/objects/project_item.h" #include "titanic/objects/tree_item.h" #include "titanic/rooms/room_item.h" @@ -37,25 +38,27 @@ Common::HashMap * #define DEFFN(T) CSaveableObject *Function##T() { return new T(); } #define ADDFN(T) (*_classList)[#T] = Function##T +DEFFN(CFileItem); DEFFN(CFileListItem); DEFFN(CMessageTarget); -DEFFN(CTreeItem); -DEFFN(CFileItem); -DEFFN(CProjectItem); -DEFFN(CRoomItem); DEFFN(CMovieClip); DEFFN(CMovieClipList); +DEFFN(CNodeItem); +DEFFN(CProjectItem); +DEFFN(CRoomItem); +DEFFN(CTreeItem); void CSaveableObject::initClassList() { _classList = new Common::HashMap(); + ADDFN(CFileItem); ADDFN(CFileListItem); ADDFN(CMessageTarget); - ADDFN(CTreeItem); - ADDFN(CFileItem); - ADDFN(CProjectItem); - ADDFN(CRoomItem); ADDFN(CMovieClip); ADDFN(CMovieClipList); + ADDFN(CNodeItem); + ADDFN(CProjectItem); + ADDFN(CRoomItem); + ADDFN(CTreeItem); } void CSaveableObject::freeClassList() { -- cgit v1.2.3