diff options
author | Paul Gilbert | 2016-03-13 15:07:27 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-03-13 15:07:27 -0400 |
commit | c92bf22f0331fbdbc7e440b43ae1973b679befb3 (patch) | |
tree | d51ee3848bb6606cf8a99421d257ad0bca641828 /engines/titanic/core | |
parent | f0d992d8548ee8bacae72ecc15e69f9de4187549 (diff) | |
download | scummvm-rg350-c92bf22f0331fbdbc7e440b43ae1973b679befb3.tar.gz scummvm-rg350-c92bf22f0331fbdbc7e440b43ae1973b679befb3.tar.bz2 scummvm-rg350-c92bf22f0331fbdbc7e440b43ae1973b679befb3.zip |
TITANIC: Changed CGameStateSub to CGameLocation, properly implemented it
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/named_item.cpp | 22 | ||||
-rw-r--r-- | engines/titanic/core/named_item.h | 18 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 2 | ||||
-rw-r--r-- | engines/titanic/core/room_item.cpp | 106 | ||||
-rw-r--r-- | engines/titanic/core/room_item.h | 61 | ||||
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 2 |
7 files changed, 207 insertions, 10 deletions
diff --git a/engines/titanic/core/named_item.cpp b/engines/titanic/core/named_item.cpp index 641efbd249..cd798a297e 100644 --- a/engines/titanic/core/named_item.cpp +++ b/engines/titanic/core/named_item.cpp @@ -21,6 +21,8 @@ */ #include "titanic/core/named_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" namespace Titanic { @@ -47,4 +49,24 @@ int CNamedItem::compareTo(const CString &name, int maxLen) const { } } +CNodeItem *CNamedItem::findNode() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CNodeItem *node = dynamic_cast<CNodeItem *>(parent); + if (node) + return node; + } + + error("Couldn't find parent node"); +} + +CRoomItem *CNamedItem::findRoom() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CRoomItem *room = dynamic_cast<CRoomItem *>(parent); + if (room) + return room; + } + + error("Couldn't find parent node"); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/named_item.h b/engines/titanic/core/named_item.h index 0afbf709c5..6e6178edd4 100644 --- a/engines/titanic/core/named_item.h +++ b/engines/titanic/core/named_item.h @@ -27,6 +27,9 @@ namespace Titanic { +class CNodeItem; +class CRoomItem; + class CNamedItem: public CTreeItem { public: CString _name; @@ -44,11 +47,6 @@ public: virtual void load(SimpleFile *file); /** - * Returns true if the item is a named item - */ - virtual bool isNamedItem() const { return true; } - - /** * Gets the name of the item, if any */ virtual const CString getName() const { return _name; } @@ -57,6 +55,16 @@ public: * Compares the name of the item to a passed name */ virtual int compareTo(const CString &name, int maxLen) const; + + /** + * Find a parent node for the item + */ + virtual CNodeItem *findNode() const; + + /** + * Find a parent room item for the item + */ + virtual CRoomItem *findRoom() const; }; } // End of namespace Titanic diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 65fe8b88bd..bb96f81245 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -28,7 +28,7 @@ #include "titanic/core/dont_save_file_item.h" #include "titanic/core/file_item.h" #include "titanic/core/list.h" -#include "titanic/game/room_item.h" +#include "titanic/core/room_item.h" namespace Titanic { diff --git a/engines/titanic/core/room_item.cpp b/engines/titanic/core/room_item.cpp new file mode 100644 index 0000000000..b0cefcaf74 --- /dev/null +++ b/engines/titanic/core/room_item.cpp @@ -0,0 +1,106 @@ +/* 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/core/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(); + _roomNumber = file->readNumber(); + break; + + default: + break; + } + + CNamedItem::load(file); +} + +void CRoomItem::loading() { + // TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/room_item.h b/engines/titanic/core/room_item.h new file mode 100644 index 0000000000..2235f6a5d2 --- /dev/null +++ b/engines/titanic/core/room_item.h @@ -0,0 +1,61 @@ +/* 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/core/list.h" +#include "titanic/core/movie_clip.h" +#include "titanic/core/named_item.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +class CRoomItem : public CNamedItem { +public: + Common::Rect _roomRect; + CMovieClipList _clipList; + int _roomNumber; + CResourceKey _transitionMovieKey; + CResourceKey _exitMovieKey; + double _roomDimensionX, _roomDimensionY; + + void loading(); +public: + CLASSDEF + 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 */ diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 95175ca174..449eb9a5fb 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -73,6 +73,7 @@ #include "titanic/core/multi_drop_target.h" #include "titanic/core/node_item.h" #include "titanic/core/project_item.h" +#include "titanic/core/room_item.h" #include "titanic/core/saveable_object.h" #include "titanic/core/static_image.h" #include "titanic/core/turn_on_object.h" @@ -181,7 +182,6 @@ #include "titanic/game/reserved_table.h" #include "titanic/game/restaurant_cylinder_holder.h" #include "titanic/game/restaurant_phonograph.h" -#include "titanic/game/room_item.h" #include "titanic/game/sauce_dispensor.h" #include "titanic/game/search_point.h" #include "titanic/game/season_background.h" @@ -479,6 +479,7 @@ DEFFN(CNamedItem) DEFFN(CNodeItem) DEFFN(CProjectItem) DEFFN(CResourceKey) +DEFFN(CRoomItem) DEFFN(CSaveableObject) DEFFN(CStaticImage) DEFFN(CTurnOnObject) @@ -587,7 +588,6 @@ DEFFN(CReplacementEar) DEFFN(CReservedTable) DEFFN(CRestaurantCylinderHolder) DEFFN(CRestaurantPhonograph) -DEFFN(CRoomItem) DEFFN(CSauceDispensor) DEFFN(CSearchPoint) DEFFN(CSeasonBackground) @@ -1044,6 +1044,7 @@ void CSaveableObject::initClassList() { ADDFN(CNodeItem, CNamedItem); ADDFN(CProjectItem, CFileItem); ADDFN(CResourceKey, CSaveableObject); + ADDFN(CRoomItem, CNamedItem); ADDFN(CSaveableObject, CSaveableObject); ADDFN(CStaticImage, CGameObject); ADDFN(CTurnOnObject, CBackground); @@ -1153,7 +1154,6 @@ void CSaveableObject::initClassList() { ADDFN(CReservedTable, CGameObject); ADDFN(CRestaurantCylinderHolder, CDropTarget); ADDFN(CRestaurantPhonograph, CPhonograph); - ADDFN(CRoomItem, CNamedItem); ADDFN(CSauceDispensor, CBackground); ADDFN(CSearchPoint, CGameObject); ADDFN(CSeasonBackground, CBackground); diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index 127a95071a..3599732080 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -29,7 +29,7 @@ #include "titanic/core/named_item.h" #include "titanic/core/node_item.h" #include "titanic/core/view_item.h" -#include "titanic/game/room_item.h" +#include "titanic/core/room_item.h" namespace Titanic { |