diff options
| author | Paul Gilbert | 2016-02-23 22:52:02 -0500 | 
|---|---|---|
| committer | Paul Gilbert | 2016-02-23 22:52:02 -0500 | 
| commit | 4126cf4fb0a4a30e5abfbef9ae3ce46bce3fd620 (patch) | |
| tree | ac523a3805633603f95f48c932375c124030e852 | |
| parent | a0dbab62b99afa331b5162a8c81a4db391cbd09e (diff) | |
| download | scummvm-rg350-4126cf4fb0a4a30e5abfbef9ae3ce46bce3fd620.tar.gz scummvm-rg350-4126cf4fb0a4a30e5abfbef9ae3ce46bce3fd620.tar.bz2 scummvm-rg350-4126cf4fb0a4a30e5abfbef9ae3ce46bce3fd620.zip | |
TITANIC: Implemented CRoomItem class
| -rw-r--r-- | engines/titanic/module.mk | 4 | ||||
| -rw-r--r-- | engines/titanic/objects/named_item.cpp | 14 | ||||
| -rw-r--r-- | engines/titanic/objects/named_item.h | 17 | ||||
| -rw-r--r-- | engines/titanic/objects/resource_key.cpp | 47 | ||||
| -rw-r--r-- | engines/titanic/objects/resource_key.h | 54 | ||||
| -rw-r--r-- | engines/titanic/objects/saveable_object.cpp | 7 | ||||
| -rw-r--r-- | engines/titanic/rooms/room_item.cpp | 105 | ||||
| -rw-r--r-- | engines/titanic/rooms/room_item.h | 80 | 
8 files changed, 327 insertions, 1 deletions
| diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index 6d1e5461f5..6ddb96a8e5 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -23,8 +23,10 @@ MODULE_OBJS := \  	objects/named_item.o \  	objects/pet_control.o \  	objects/project_item.o \ +	objects/resource_key.o \  	objects/saveable_object.o \ -	objects/tree_item.o +	objects/tree_item.o \ +	rooms/room_item.o  # This module can be built as a plugin  ifeq ($(ENABLE_TITANIC), DYNAMIC_PLUGIN) diff --git a/engines/titanic/objects/named_item.cpp b/engines/titanic/objects/named_item.cpp index 34db645590..f7d7c7b75d 100644 --- a/engines/titanic/objects/named_item.cpp +++ b/engines/titanic/objects/named_item.cpp @@ -24,5 +24,19 @@  namespace Titanic { +void CNamedItem::save(SimpleFile *file, int indent) const { +	file->writeNumberLine(0, indent); +	file->writeQuotedLine(_name, indent); + +	CTreeItem::save(file, indent); +} + +void CNamedItem::load(SimpleFile *file) { +	int val = file->readNumber(); +	if (!val) +		_name = file->readString(); + +	CTreeItem::load(file); +}  } // End of namespace Titanic diff --git a/engines/titanic/objects/named_item.h b/engines/titanic/objects/named_item.h index ee4ad352ed..d59b73065b 100644 --- a/engines/titanic/objects/named_item.h +++ b/engines/titanic/objects/named_item.h @@ -28,6 +28,23 @@  namespace Titanic {  class CNamedItem: public CTreeItem { +public: +	CString _name; +public: +	/** +	 * 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 diff --git a/engines/titanic/objects/resource_key.cpp b/engines/titanic/objects/resource_key.cpp new file mode 100644 index 0000000000..612014bb37 --- /dev/null +++ b/engines/titanic/objects/resource_key.cpp @@ -0,0 +1,47 @@ +/* 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/simple_file.h" +#include "titanic/objects/resource_key.h" + +namespace Titanic { + +void CResourceKey::save(SimpleFile *file, int indent) const { +	file->writeNumberLine(1, indent); +	file->writeQuotedLine("Resource Key...", indent); +	file->writeQuotedLine(_key, indent); + +	CSaveableObject::save(file, indent); +} + +void CResourceKey::load(SimpleFile *file) { +	int val = file->readNumber(); +	 +	if (val == 1) { +		file->readBuffer(); +		_value = file->readString(); +	} + +	CSaveableObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/objects/resource_key.h b/engines/titanic/objects/resource_key.h new file mode 100644 index 0000000000..4cb40cd568 --- /dev/null +++ b/engines/titanic/objects/resource_key.h @@ -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. + * + */ + +#ifndef TITANIC_RESOURCE_KEY_H +#define TITANIC_RESOURCE_KEY_H + +#include "titanic/string.h" +#include "titanic/objects/saveable_object.h" + +namespace Titanic { + +class CResourceKey: public CSaveableObject { +private: +	CString _key; +	CString _value; +public: +	/** +	 * Return the class name +	 */ +	virtual const char *getClassName() const { return "CResourceKey"; } + +	/** +	 * 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_RESOURCE_KEY_H */ diff --git a/engines/titanic/objects/saveable_object.cpp b/engines/titanic/objects/saveable_object.cpp index 45f9e132d9..f2f38f3dfb 100644 --- a/engines/titanic/objects/saveable_object.cpp +++ b/engines/titanic/objects/saveable_object.cpp @@ -26,6 +26,7 @@  #include "titanic/objects/message_target.h"  #include "titanic/objects/project_item.h"  #include "titanic/objects/tree_item.h" +#include "titanic/rooms/room_item.h"  namespace Titanic { @@ -40,6 +41,9 @@ DEFFN(CMessageTarget);  DEFFN(CTreeItem);  DEFFN(CFileItem);  DEFFN(CProjectItem); +DEFFN(CRoomItem); +DEFFN(CMovieClipItem); +DEFFN(CMovieClipList);  void CSaveableObject::initClassList() {  	_classList = new Common::HashMap<Common::String, CreateFunction>(); @@ -48,6 +52,9 @@ void CSaveableObject::initClassList() {  	ADDFN(CTreeItem);  	ADDFN(CFileItem);  	ADDFN(CProjectItem); +	ADDFN(CRoomItem); +	ADDFN(CMovieClipItem); +	ADDFN(CMovieClipList);  }  void CSaveableObject::freeClassList() { diff --git a/engines/titanic/rooms/room_item.cpp b/engines/titanic/rooms/room_item.cpp new file mode 100644 index 0000000000..9e0c699cc6 --- /dev/null +++ b/engines/titanic/rooms/room_item.cpp @@ -0,0 +1,105 @@ +/* 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/rooms/room_item.h" + +namespace Titanic { + +CRoomItem::CRoomItem() : CNamedItem(), _roomNumber(0), +		_roomDimensionX(0.0), _roomDimensionY(0.0) { +} + +void CRoomItem::save(SimpleFile *file, int indent) const { +	file->writeNumberLine(3, indent); +	file->writeQuotedLine("Exit Movies", indent); +	_exitMovieKey.save(file, indent); + +	file->writeNumberLine(_roomDimensionX * 1000.0, indent + 1); +	file->writeNumberLine(_roomDimensionY * 1000.0, indent + 1); + +	file->writeQuotedLine("Transition Movie", indent); +	_transitionMovieKey.save(file, indent); + +	file->writeQuotedLine("Movie Clip list", indent); +	_clipList.save(file, indent + 1); + +	file->writeQuotedLine("Room Rect", indent); +	file->writeNumberLine(_roomRect.left, indent + 1); +	file->writeNumberLine(_roomRect.top, indent + 1); +	file->writeNumberLine(_roomRect.right, indent + 1); +	file->writeNumberLine(_roomRect.bottom, indent + 1); + +	file->writeQuotedLine("Room Number", indent); +	file->writeNumberLine(_roomNumber, indent); + +	CNamedItem::save(file, indent); +} + +void CRoomItem::load(SimpleFile *file) { +	int val = file->readNumber(); +	 +	switch (val) { +	case 3: +		// Read exit movie +		file->readBuffer(); +		_exitMovieKey.load(file); +		// Deliberate fall-through + +	case 2: +		// Read room dimensions +		file->readBuffer(); +		_roomDimensionX = (double)file->readNumber() / 1000.0; +		_roomDimensionY = (double)file->readNumber() / 1000.0; +		// Deliberate fall-through + +	case 1: +		// Read transition movie key and clip list +		file->readBuffer(); +		_transitionMovieKey.load(file); + +		file->readBuffer(); +		_clipList.load(file); +		loading(); +		// Deliberate fall-through + +	case 0: +		// Read room rect +		file->readBuffer(); +		_roomRect.left = file->readNumber(); +		_roomRect.top = file->readNumber(); +		_roomRect.right = file->readNumber(); +		_roomRect.bottom = file->readNumber(); +		file->readBuffer(); +		break; + +	default: +		break; +	} + +	CNamedItem::load(file); +} + +void CRoomItem::loading() { +	// TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/rooms/room_item.h b/engines/titanic/rooms/room_item.h new file mode 100644 index 0000000000..bb8bbb8619 --- /dev/null +++ b/engines/titanic/rooms/room_item.h @@ -0,0 +1,80 @@ +/* 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_ROOM_ITEM_H +#define TITANIC_ROOM_ITEM_H + +#include "common/rect.h" +#include "titanic/objects/list.h" +#include "titanic/objects/resource_key.h" +#include "titanic/objects/named_item.h" + +namespace Titanic { + +/** + * Movie clip item + */ +class CMovieClipItem : public ListItem { +public: +	virtual const char *getClassName() const { return "CMovieClipItem"; } +}; + +/** + * Movie clip list + */ +class CMovieClipList: public List<CMovieClipItem> { +public: +	virtual const char *getClassName() const { return "CMovieClipList"; } +}; + +class CRoomItem : public CNamedItem { +private: +	Common::Rect _roomRect; +	CMovieClipList _clipList; +	int _roomNumber; +	CResourceKey _transitionMovieKey; +	CResourceKey _exitMovieKey; +	double _roomDimensionX, _roomDimensionY; + +	void loading(); +public: +	CRoomItem(); + +	/** +	 * Return the class name +	 */ +	virtual const char *getClassName() const { return "CRoomItem"; } + +	/** +	 * 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_ROOM_ITEM_H */ | 
