diff options
author | Paul Gilbert | 2016-08-02 17:49:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-02 17:49:41 -0400 |
commit | ceb49fc839a28408f24217abaef41d88eace0247 (patch) | |
tree | 0d3e3731f522c50e939b3f88edb09743fa1d65b4 /engines/titanic/core | |
parent | 8cf1688535f5da02157e2d0f10bed2b9e7f3666a (diff) | |
download | scummvm-rg350-ceb49fc839a28408f24217abaef41d88eace0247.tar.gz scummvm-rg350-ceb49fc839a28408f24217abaef41d88eace0247.tar.bz2 scummvm-rg350-ceb49fc839a28408f24217abaef41d88eace0247.zip |
TITANIC: Further work on view and node positioning
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/node_item.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/core/node_item.h | 7 | ||||
-rw-r--r-- | engines/titanic/core/view_item.cpp | 15 | ||||
-rw-r--r-- | engines/titanic/core/view_item.h | 9 |
4 files changed, 30 insertions, 8 deletions
diff --git a/engines/titanic/core/node_item.cpp b/engines/titanic/core/node_item.cpp index 1de065a49d..85d3f548c0 100644 --- a/engines/titanic/core/node_item.cpp +++ b/engines/titanic/core/node_item.cpp @@ -21,6 +21,7 @@ */ #include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" namespace Titanic { @@ -53,4 +54,10 @@ void CNodeItem::load(SimpleFile *file) { CNamedItem::load(file); } +void CNodeItem::getPosition(double &xp, double &yp, double &zp) { + CRoomItem *room = findRoom(); + room->calcNodePosition(_nodePos, xp, yp); + zp = 0.0; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/node_item.h b/engines/titanic/core/node_item.h index 8fda9464ec..ea403ddc3a 100644 --- a/engines/titanic/core/node_item.h +++ b/engines/titanic/core/node_item.h @@ -44,7 +44,12 @@ public: /** * Load the data for the class from file */ - virtual void load(SimpleFile *file); + virtual void load(SimpleFile *file); + + /** + * Gets the relative position of the node within the owning room + */ + void getPosition(double &xp, double &yp, double &zp); }; } // End of namespace Titanic diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 119ffe431c..03e2753839 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -47,8 +47,8 @@ CViewItem::CViewItem() : CNamedItem() { void CViewItem::setAngle(double angle) { _angle = angle; - _position.x = (int16)(cos(_angle) * 30.0); - _position.y = (int16)(sin(_angle) * -30.0); + _viewPos.x = (int16)(cos(_angle) * 30.0); + _viewPos.y = (int16)(sin(_angle) * -30.0); } void CViewItem::save(SimpleFile *file, int indent) { @@ -304,8 +304,15 @@ void CViewItem::handleButtonUpMsg(CMouseButtonUpMsg *msg) { } } -void CViewItem::fn1(double val1, double val2, double val3) { - warning("TODO: CViewItem::fn1"); +void CViewItem::getPosition(double &xp, double &yp, double &zp) { + // Get the position of the owning node within the room + CNodeItem *node = findNode(); + node->getPosition(xp, yp, zp); + + // Adjust the position slightly to compensate for view's angle, + // ensuring different direction views don't all have the same position + xp += cos(_angle) * 0.5; + yp -= sin(_angle) * 0.5; } CString CViewItem::getFullViewName() const { diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h index 9dc6e96768..d653c3a4f3 100644 --- a/engines/titanic/core/view_item.h +++ b/engines/titanic/core/view_item.h @@ -40,7 +40,7 @@ private: CTreeItem *_buttonUpTargets[4]; private: /** - * Sets the angle of the view item + * Sets the angle of the view relative to the node it belongs to */ void setAngle(double angle); @@ -57,7 +57,7 @@ protected: int _field24; CResourceKey _resourceKey; double _angle; - Point _position; + Point _viewPos; public: int _viewNumber; public: @@ -111,7 +111,10 @@ public: */ CString getNodeViewName() const; - void fn1(double val1, double val2, double val3); + /** + * Gets the relative position of the view within the owning room + */ + void getPosition(double &xp, double &yp, double &zp); }; } // End of namespace Titanic |