Skip to content

Commit

Permalink
TITANIC: Implemented CCage class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 17, 2016
1 parent 75f6d1f commit c628f72
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
2 changes: 1 addition & 1 deletion engines/titanic/carry/carry_parrot.cpp
Expand Up @@ -111,7 +111,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) {

if (compareViewNameTo("ParrotLobby.Node 1.N")) {
if (msg->_mousePos.x >= 75 && msg->_mousePos.x <= 565 &&
!CParrot::_v2 && !CCage::_v2) {
!CParrot::_v2 && !CCage::_open) {
setVisible(false);
_fieldE0 = 0;
CTreeItem *perchedParrot = findUnder(getRoot(), "PerchedParrot");
Expand Down
70 changes: 67 additions & 3 deletions engines/titanic/game/cage.cpp
Expand Up @@ -21,26 +21,90 @@
*/

#include "titanic/game/cage.h"
#include "titanic/npcs/parrot.h"

namespace Titanic {

BEGIN_MESSAGE_MAP(CCage, CBackground)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(ActMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(PreEnterViewMsg)
ON_MESSAGE(MouseMoveMsg)
END_MESSAGE_MAP()

int CCage::_v1;
int CCage::_v2;
bool CCage::_open;

void CCage::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_v1, indent);
file->writeNumberLine(_v2, indent);
file->writeNumberLine(_open, indent);

CBackground::save(file, indent);
}

void CCage::load(SimpleFile *file) {
file->readNumber();
_v1 = file->readNumber();
_v2 = file->readNumber();
_open = file->readNumber();

CBackground::load(file);
}

bool CCage::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (CParrot::_v4 && !CParrot::_v5) {
CActMsg actMsg(_open ? "Open" : "Shut");
actMsg.execute(this);
}

return true;
}

bool CCage::ActMsg(CActMsg *msg) {
if (msg->_action == "Shut") {
if (!_open) {
playClip("Shut", MOVIE_STOP_PREVIOUS | MOVIE_NOTIFY_OBJECT);
disableMouse();
}
} else if (msg->_action == "Open") {
if (_open) {
playClip("Open", MOVIE_STOP_PREVIOUS | MOVIE_NOTIFY_OBJECT);
disableMouse();
}
} else if (msg->_action == "CoreReplaced") {
CActMsg actMsg("Shut");
actMsg.execute(this);
} else if (msg->_action == "OpenNow") {
loadFrame(0);
_open = false;
}

return true;
}

bool CCage::MovieEndMsg(CMovieEndMsg *msg) {
enableMouse();
_open = clipExistsByEnd("Shut", msg->_endFrame);

CStatusChangeMsg statusMsg;
statusMsg._newStatus = _open ? 1 : (CParrot::_v4 == 0 ? 1 : 0);
statusMsg.execute("PerchCoreHolder");

return true;
}

bool CCage::PreEnterViewMsg(CPreEnterViewMsg *msg) {
loadSurface();
_open = CParrot::_v4 != 0;
loadFrame(_open ? 8 : 0);

return true;
}

bool CCage::MouseMoveMsg(CMouseMoveMsg *msg) {
_cursorId = CParrot::_v4 && !CParrot::_v5 ? CURSOR_ACTIVATE : CURSOR_ARROW;
return true;
}

} // End of namespace Titanic
8 changes: 7 additions & 1 deletion engines/titanic/game/cage.h
Expand Up @@ -28,9 +28,15 @@
namespace Titanic {

class CCage : public CBackground {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool ActMsg(CActMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
bool PreEnterViewMsg(CPreEnterViewMsg *msg);
bool MouseMoveMsg(CMouseMoveMsg *msg);
public:
static int _v1;
static int _v2;
static bool _open;
public:
CLASSDEF;

Expand Down

0 comments on commit c628f72

Please sign in to comment.