diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 5 | ||||
-rw-r--r-- | engines/titanic/core/node_item.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/core/node_item.h | 4 | ||||
-rw-r--r-- | engines/titanic/core/room_item.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/core/room_item.h | 5 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 6 | ||||
-rw-r--r-- | engines/titanic/main_game_window.cpp | 25 |
8 files changed, 63 insertions, 8 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 06f2ce78af..db1e9ef3d6 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -127,4 +127,8 @@ bool CGameObject::checkPoint(const Point &pt, int v0, int v1) { return false; } +void CGameObject::draw(CScreenManager *screenManager) { + warning("TODO: CGameObject::draw"); +} + } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 809f7b8d20..675339e926 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -73,6 +73,11 @@ public: */ virtual void load(SimpleFile *file); + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); + void fn2(); bool checkPoint(const Point &pt, int v0, int v1); diff --git a/engines/titanic/core/node_item.cpp b/engines/titanic/core/node_item.cpp index 22c9b9b37f..6b7d6452cb 100644 --- a/engines/titanic/core/node_item.cpp +++ b/engines/titanic/core/node_item.cpp @@ -24,14 +24,14 @@ namespace Titanic { -CNodeItem::CNodeItem() : CNamedItem(), _field24(0), _field28(0), _nodeNumber(0) { +CNodeItem::CNodeItem() : CNamedItem(), _nodeNumber(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->writeNumberLine(_nodePos.x, indent + 1); + file->writeNumberLine(_nodePos.y, indent + 1); file->writeQuotedLine("N", indent); file->writeNumberLine(_nodeNumber, indent + 1); @@ -42,8 +42,8 @@ void CNodeItem::save(SimpleFile *file, int indent) const { void CNodeItem::load(SimpleFile *file) { file->readNumber(); file->readBuffer(); - _field24 = file->readNumber(); - _field28 = file->readNumber(); + _nodePos.x = file->readNumber(); + _nodePos.y = file->readNumber(); file->readBuffer(); _nodeNumber = file->readNumber(); diff --git a/engines/titanic/core/node_item.h b/engines/titanic/core/node_item.h index 4f0391ae88..32db1c1401 100644 --- a/engines/titanic/core/node_item.h +++ b/engines/titanic/core/node_item.h @@ -28,11 +28,9 @@ namespace Titanic { class CNodeItem : public CNamedItem { -protected: - int _field24; - int _field28; public: int _nodeNumber; + Point _nodePos; public: CLASSDEF CNodeItem(); diff --git a/engines/titanic/core/room_item.cpp b/engines/titanic/core/room_item.cpp index b0cefcaf74..7a6dfd968a 100644 --- a/engines/titanic/core/room_item.cpp +++ b/engines/titanic/core/room_item.cpp @@ -103,4 +103,16 @@ void CRoomItem::loading() { // TODO } +void CRoomItem::calcNodePosition(const Point &nodePos, double &xVal, double &yVal) const { + xVal = yVal = 0.0; + + if (_roomDimensionX >= 0.0 && _roomDimensionY >= 0.0) { + xVal = _roomRect.width() / _roomDimensionX; + yVal = _roomRect.height() / _roomDimensionY; + + xVal = (nodePos.x - _roomRect.left) / xVal; + yVal = (nodePos.y - _roomRect.top) / yVal; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/core/room_item.h b/engines/titanic/core/room_item.h index 7248b4aac3..9e7f553407 100644 --- a/engines/titanic/core/room_item.h +++ b/engines/titanic/core/room_item.h @@ -59,6 +59,11 @@ public: * Return a movie clip for the room by name */ CMovieClip *findClip(const CString &name) { return _clipList.findByName(name); } + + /** + * Calculates the positioning of a node within the overall room + */ + void calcNodePosition(const Point &nodePos, double &xVal, double &yVal) const; }; } // End of namespace Titanic diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index 5669784cd7..e870ad1dc3 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -31,6 +31,7 @@ class CGameManager; class CDontSaveFileItem; class CNamedItem; class CProjectItem; +class CScreenManager; class CTreeItem: public CMessageTarget { private: @@ -120,6 +121,11 @@ public: virtual int compareTo(const CString &name, int maxLen) const { return false; } /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager) {} + + /** * Gets the bounds occupied by the item */ virtual Rect getBounds() { return Rect(); } diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp index 839c2fc684..6fa240dcec 100644 --- a/engines/titanic/main_game_window.cpp +++ b/engines/titanic/main_game_window.cpp @@ -157,7 +157,32 @@ void CMainGameWindow::drawView() { } void CMainGameWindow::drawViewContents(CScreenManager *screenManager) { + // Get a reference to the reference, validating that it's present + if (!screenManager) + return; + CViewItem *view = _gameManager->getView(); + if (!view) + return; + CNodeItem *node = view->findNode(); + if (!node) + return; + CRoomItem *room = node->findRoom(); + if (!room) + return; + + double xVal = 0.0, yVal = 0.0; + room->calcNodePosition(node->_nodePos, xVal, yVal); + + // Iterate through drawing all the items in the scene except any item + // that's currently being dragged + for (CTreeItem *treeItem = view; treeItem; treeItem = treeItem->scan(view)) { + if (treeItem != _gameManager->_dragItem) + treeItem->draw(screenManager); + } + // Finally draw the drag item if there is one + if (_gameManager->_dragItem) + _gameManager->_dragItem->draw(screenManager); } void CMainGameWindow::mouseChanged() { |