diff options
author | Paul Gilbert | 2016-03-17 23:58:24 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-03-17 23:58:24 -0400 |
commit | 8b9f3dc0b8929d920cb101a06cef8ba14fee59f0 (patch) | |
tree | 275a8504fa977e4fc7e78f316681b51ca2f5b69e /engines/titanic | |
parent | ea585b0aa53544e114cdb0080cacbcb324e6e1ff (diff) | |
download | scummvm-rg350-8b9f3dc0b8929d920cb101a06cef8ba14fee59f0.tar.gz scummvm-rg350-8b9f3dc0b8929d920cb101a06cef8ba14fee59f0.tar.bz2 scummvm-rg350-8b9f3dc0b8929d920cb101a06cef8ba14fee59f0.zip |
TITANIC: Fleshing out CLinkItem class
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/link_item.cpp | 66 | ||||
-rw-r--r-- | engines/titanic/core/link_item.h | 43 | ||||
-rw-r--r-- | engines/titanic/core/named_item.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/core/named_item.h | 6 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_val.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_val.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_val_base.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_val_base.h | 2 |
10 files changed, 112 insertions, 32 deletions
diff --git a/engines/titanic/core/link_item.cpp b/engines/titanic/core/link_item.cpp index 9a895b774b..175c11f8d0 100644 --- a/engines/titanic/core/link_item.cpp +++ b/engines/titanic/core/link_item.cpp @@ -21,10 +21,13 @@ */ #include "titanic/core/link_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" +#include "titanic/core/view_item.h" namespace Titanic { -void CLinkItemSub::clear() { +void CLinkItemHotspot::clear() { _field0 = 0; _field4 = 0; _field8 = 0; @@ -34,28 +37,33 @@ void CLinkItemSub::clear() { /*------------------------------------------------------------------------*/ CLinkItem::CLinkItem() : CNamedItem() { - _field24 = -1; - _field28 = -1; - _field2C = -1; + _roomNumber = -1; + _nodeNumber = -1; + _viewNumber = -1; _field30 = 0; _field34 = 1; _name = "Link"; } +CString CLinkItem::formName() { + warning("TODO: CLinkItem::formName"); + return ""; +} + void CLinkItem::save(SimpleFile *file, int indent) const { file->writeNumberLine(2, indent); file->writeQuotedLine("L", indent); file->writeNumberLine(_field34, indent + 1); file->writeNumberLine(_field30, indent + 1); - file->writeNumberLine(_field24, indent + 1); - file->writeNumberLine(_field28, indent + 1); - file->writeNumberLine(_field2C, indent + 1); + file->writeNumberLine(_roomNumber, indent + 1); + file->writeNumberLine(_nodeNumber, indent + 1); + file->writeNumberLine(_viewNumber, indent + 1); file->writeQuotedLine("Hotspot", indent + 1); - file->writeNumberLine(_sub._field0, indent + 2); - file->writeNumberLine(_sub._field4, indent + 2); - file->writeNumberLine(_sub._field8, indent + 2); - file->writeNumberLine(_sub._fieldC, indent + 2); + file->writeNumberLine(_hotspot._field0, indent + 2); + file->writeNumberLine(_hotspot._field4, indent + 2); + file->writeNumberLine(_hotspot._field8, indent + 2); + file->writeNumberLine(_hotspot._fieldC, indent + 2); CNamedItem::save(file, indent); } @@ -74,15 +82,15 @@ void CLinkItem::load(SimpleFile *file) { // Deliberate fall-through case 0: - _field24 = file->readNumber(); - _field28 = file->readNumber(); - _field2C = file->readNumber(); + _roomNumber = file->readNumber(); + _nodeNumber = file->readNumber(); + _viewNumber = file->readNumber(); file->readBuffer(); - _sub._field0 = file->readNumber(); - _sub._field4 = file->readNumber(); - _sub._field8 = file->readNumber(); - _sub._fieldC = file->readNumber(); + _hotspot._field0 = file->readNumber(); + _hotspot._field4 = file->readNumber(); + _hotspot._field8 = file->readNumber(); + _hotspot._fieldC = file->readNumber(); break; default: @@ -109,4 +117,26 @@ void CLinkItem::load(SimpleFile *file) { } } +void CLinkItem::setDestination(int roomNumber, int nodeNumber, + int viewNumber, int v) { + _roomNumber = roomNumber; + _nodeNumber = nodeNumber; + _viewNumber = viewNumber; + _field30 = v; + + _name = formName(); +} + +CViewItem *CLinkItem::getDestView() const { + return getRoot()->findView(_roomNumber, _nodeNumber, _viewNumber); +} + +CNodeItem *CLinkItem::getDestNode() const { + return getDestView()->findNode(); +} + +CRoomItem *CLinkItem::getDestRoom() const { + return getDestNode()->findRoom(); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/link_item.h b/engines/titanic/core/link_item.h index f46f8d3ba0..06d55f3f44 100644 --- a/engines/titanic/core/link_item.h +++ b/engines/titanic/core/link_item.h @@ -27,26 +27,36 @@ namespace Titanic { -class CLinkItemSub { +class CViewItem; +class CNodeItem; +class CRoomItem; + +class CLinkItemHotspot { public: int _field0; int _field4; int _field8; int _fieldC; public: - CLinkItemSub() { clear(); } + CLinkItemHotspot() { clear(); } void clear(); }; class CLinkItem : public CNamedItem { +private: + /** + * Returns a new name for the link item, based on the + * current values for it's destination + */ + CString formName(); protected: - int _field24; - int _field28; - int _field2C; + int _roomNumber; + int _nodeNumber; + int _viewNumber; int _field30; int _field34; - CLinkItemSub _sub; + CLinkItemHotspot _hotspot; public: CLASSDEF CLinkItem(); @@ -60,6 +70,27 @@ public: * Load the data for the class from file */ virtual void load(SimpleFile *file); + + /** + * Set the destination for the link item + */ + virtual void setDestination(int roomNumber, int nodeNumber, + int viewNumber, int v); + + /** + * Get the destination view for the link item + */ + virtual CViewItem *getDestView() const; + + /** + * Get the destination node for the link item + */ + virtual CNodeItem *getDestNode() const; + + /** + * Get the destination view for the link item + */ + virtual CRoomItem *getDestRoom() const; }; } // End of namespace Titanic diff --git a/engines/titanic/core/named_item.cpp b/engines/titanic/core/named_item.cpp index 49cfdb4622..02e75044aa 100644 --- a/engines/titanic/core/named_item.cpp +++ b/engines/titanic/core/named_item.cpp @@ -23,6 +23,7 @@ #include "titanic/core/named_item.h" #include "titanic/core/node_item.h" #include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" namespace Titanic { @@ -56,6 +57,16 @@ int CNamedItem::compareTo(const CString &name, int maxLen) const { } } +CViewItem *CNamedItem::findView() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CViewItem *view = dynamic_cast<CViewItem *>(parent); + if (view) + return view; + } + + error("Couldn't find parent view"); +} + CNodeItem *CNamedItem::findNode() const { for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { CNodeItem *node = dynamic_cast<CNodeItem *>(parent); diff --git a/engines/titanic/core/named_item.h b/engines/titanic/core/named_item.h index aac81ec209..6ee11e960e 100644 --- a/engines/titanic/core/named_item.h +++ b/engines/titanic/core/named_item.h @@ -27,6 +27,7 @@ namespace Titanic { +class CViewItem; class CNodeItem; class CRoomItem; @@ -64,6 +65,11 @@ public: /** * Find a parent node for the item */ + virtual CViewItem *findView() const; + + /** + * Find a parent node for the item + */ virtual CNodeItem *findNode() const; /** diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index 39c3fe1f10..72c158d103 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -28,6 +28,7 @@ #include "titanic/core/link_item.h" #include "titanic/core/named_item.h" #include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" #include "titanic/core/view_item.h" #include "titanic/core/room_item.h" @@ -104,7 +105,7 @@ CGameManager *CTreeItem::getGameManager() const { return _parent ? _parent->getGameManager() : nullptr; } -CTreeItem *CTreeItem::getRoot() const { +CProjectItem *CTreeItem::getRoot() const { CTreeItem *parent = getParent(); if (parent) { @@ -113,7 +114,7 @@ CTreeItem *CTreeItem::getRoot() const { } while (parent->getParent()); } - return parent; + return dynamic_cast<CProjectItem *>(parent); } CTreeItem *CTreeItem::getLastSibling() { diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index be381c55c1..aea22ffa40 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -30,6 +30,7 @@ namespace Titanic { class CGameManager; class CDontSaveFileItem; class CNamedItem; +class CProjectItem; class CTreeItem: public CMessageTarget { private: @@ -124,9 +125,9 @@ public: CTreeItem *getParent() const { return _parent; } /** - * Jumps up through the parents to find the sub-root item + * Jumps up through the parents to find the root item */ - CTreeItem *getRoot() const; + CProjectItem *getRoot() const; /** * Get the next sibling diff --git a/engines/titanic/pet_control/pet_val.cpp b/engines/titanic/pet_control/pet_val.cpp index f0b9b92cde..31494e1033 100644 --- a/engines/titanic/pet_control/pet_val.cpp +++ b/engines/titanic/pet_control/pet_val.cpp @@ -41,7 +41,7 @@ void CPetVal::proc4() { error("TODO"); } -void CPetVal::proc5(CLinkItemSub *linkItem) { +void CPetVal::proc5(CLinkItemHotspot *linkItem) { error("TODO"); } diff --git a/engines/titanic/pet_control/pet_val.h b/engines/titanic/pet_control/pet_val.h index f1f9bd1f3c..2bf082fbc8 100644 --- a/engines/titanic/pet_control/pet_val.h +++ b/engines/titanic/pet_control/pet_val.h @@ -40,7 +40,7 @@ public: virtual void proc3(); virtual void proc4(); - virtual void proc5(CLinkItemSub *linkItem); + virtual void proc5(CLinkItemHotspot *linkItem); virtual int proc16(); }; diff --git a/engines/titanic/pet_control/pet_val_base.cpp b/engines/titanic/pet_control/pet_val_base.cpp index c1d2fa7d4f..2eb93394a9 100644 --- a/engines/titanic/pet_control/pet_val_base.cpp +++ b/engines/titanic/pet_control/pet_val_base.cpp @@ -28,7 +28,7 @@ namespace Titanic { CPetValBase::CPetValBase() : _field4(0), _field8(0), _fieldC(0), _field10(0), _field14(0) {} -void CPetValBase::proc5(CLinkItemSub *linkItem) { +void CPetValBase::proc5(CLinkItemHotspot *linkItem) { if (linkItem) linkItem->clear(); } diff --git a/engines/titanic/pet_control/pet_val_base.h b/engines/titanic/pet_control/pet_val_base.h index f5f6e58387..e6e78ae4b0 100644 --- a/engines/titanic/pet_control/pet_val_base.h +++ b/engines/titanic/pet_control/pet_val_base.h @@ -44,7 +44,7 @@ public: virtual void proc3() {} virtual void proc4() {} - virtual void proc5(CLinkItemSub *linkItem); + virtual void proc5(CLinkItemHotspot *linkItem); virtual int proc6(); virtual int proc7(); |