TITANIC: Implemented CCage class

This commit is contained in:
Paul Gilbert 2016-08-17 19:00:18 -04:00
parent 75f6d1fa5b
commit c628f7224f
3 changed files with 75 additions and 5 deletions

View File

@ -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");

View File

@ -21,16 +21,25 @@
*/
#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);
}
@ -38,9 +47,64 @@ void CCage::save(SimpleFile *file, int 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

View File

@ -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;