Skip to content

Commit

Permalink
TITANIC: Fleshing out cViewItem class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 2, 2016
1 parent efb3970 commit 8cf1688
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
32 changes: 22 additions & 10 deletions engines/titanic/core/view_item.cpp
Expand Up @@ -40,24 +40,22 @@ END_MESSAGE_MAP()
CViewItem::CViewItem() : CNamedItem() {
Common::fill(&_buttonUpTargets[0], &_buttonUpTargets[4], (CTreeItem *)nullptr);
_field24 = 0;
_field28 = 0.0;
_angle = 0.0;
_viewNumber = 0;
_field50 = 0;
_field54 = 0;
setData(0.0);
setAngle(0.0);
}

void CViewItem::setData(double v) {
_field28 = v;
_field50 = cos(_field28) * 30.0;
_field54 = sin(_field28) * -30.0;
void CViewItem::setAngle(double angle) {
_angle = angle;
_position.x = (int16)(cos(_angle) * 30.0);
_position.y = (int16)(sin(_angle) * -30.0);
}

void CViewItem::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
_resourceKey.save(file, indent);
file->writeQuotedLine("V", indent);
file->writeFloatLine(_field28, indent + 1);
file->writeFloatLine(_angle, indent + 1);
file->writeNumberLine(_viewNumber, indent + 1);

CNamedItem::save(file, indent);
Expand All @@ -73,7 +71,7 @@ void CViewItem::load(SimpleFile *file) {

default:
file->readBuffer();
setData(file->readFloat());
setAngle(file->readFloat());
_viewNumber = file->readNumber();
break;
}
Expand Down Expand Up @@ -310,4 +308,18 @@ void CViewItem::fn1(double val1, double val2, double val3) {
warning("TODO: CViewItem::fn1");
}

CString CViewItem::getFullViewName() const {
CNodeItem *node = findNode();
CRoomItem *room = node->findRoom();

return CString::format("%s.%s.%s", room->getName().c_str(),
node->getName().c_str(), getName().c_str());
}

CString CViewItem::getNodeViewName() const {
CNodeItem *node = findNode();

return CString::format("%s.%s", node->getName().c_str(), getName().c_str());
}

} // End of namespace Titanic
22 changes: 18 additions & 4 deletions engines/titanic/core/view_item.h
Expand Up @@ -39,7 +39,10 @@ class CViewItem : public CNamedItem {
private:
CTreeItem *_buttonUpTargets[4];
private:
void setData(double v);
/**
* Sets the angle of the view item
*/
void setAngle(double angle);

/**
* Called to handle mouse messagaes on the view
Expand All @@ -52,10 +55,9 @@ class CViewItem : public CNamedItem {
void handleButtonUpMsg(CMouseButtonUpMsg *msg);
protected:
int _field24;
double _field28;
CResourceKey _resourceKey;
int _field50;
int _field54;
double _angle;
Point _position;
public:
int _viewNumber;
public:
Expand Down Expand Up @@ -97,6 +99,18 @@ class CViewItem : public CNamedItem {
*/
CLinkItem *findLink(CViewItem *newView);

/**
* Return the full Id of the current view in a
* room.node.view tuplet form
*/
CString getFullViewName() const;

/**
* Return the Id of the current view in a
* room.node.view tuplet form
*/
CString getNodeViewName() const;

void fn1(double val1, double val2, double val3);
};

Expand Down

0 comments on commit 8cf1688

Please sign in to comment.