TITANIC: Implemented more game classes

This commit is contained in:
Paul Gilbert 2016-08-25 20:46:33 -04:00
parent db179c11bb
commit 1f0b9cb68d
16 changed files with 215 additions and 13 deletions

View File

@ -21,9 +21,16 @@
*/
#include "titanic/carry/mouth.h"
#include "titanic/game/head_slot.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CMouth, CHeadPiece)
ON_MESSAGE(UseWithOtherMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(PETGainedObjectMsg)
END_MESSAGE_MAP()
CMouth::CMouth() : CHeadPiece() {
}
@ -37,4 +44,37 @@ void CMouth::load(SimpleFile *file) {
CHeadPiece::load(file);
}
bool CMouth::UseWithOtherMsg(CUseWithOtherMsg *msg) {
CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other);
if (!slot)
return CHeadPiece::UseWithOtherMsg(msg);
_flag = true;
setVisible(false);
setPosition(Point(0, 0));
petMoveToHiddenRoom();
CAddHeadPieceMsg addMsg(getName());
if (addMsg._value != "NULL")
addMsg.execute("MouthSlot");
return true;
}
bool CMouth::MovieEndMsg(CMovieEndMsg *msg) {
return true;
}
bool CMouth::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
_visibleFrame = 2;
loadFrame(2);
setVisible(true);
if (!_field13C) {
stateInc38();
_field13C = true;
}
return true;
}
} // End of namespace Titanic

View File

@ -28,6 +28,10 @@
namespace Titanic {
class CMouth : public CHeadPiece {
DECLARE_MESSAGE_MAP;
bool UseWithOtherMsg(CUseWithOtherMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
public:
CLASSDEF;
CMouth();

View File

@ -21,9 +21,14 @@
*/
#include "titanic/core/multi_drop_target.h"
#include "titanic/support/string_parser.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CMultiDropTarget, CDropTarget)
ON_MESSAGE(DropObjectMsg)
END_MESSAGE_MAP()
void CMultiDropTarget::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_string5, indent);
@ -40,4 +45,21 @@ void CMultiDropTarget::load(SimpleFile *file) {
CDropTarget::load(file);
}
bool CMultiDropTarget::DropObjectMsg(CDropObjectMsg *msg) {
CStringParser parser1(_string5);
CStringParser parser2(_string6);
CString seperatorChars = ",";
int dropFrame = _dropFrame;
while (parser2.parse(_itemMatchName, seperatorChars)) {
_dropFrame = parser1.readInt();
CDropTarget::DropObjectMsg(msg);
parser1.skipSeperators(seperatorChars);
parser2.skipSeperators(seperatorChars);
}
return true;
}
} // End of namespace Titanic

View File

@ -28,6 +28,8 @@
namespace Titanic {
class CMultiDropTarget : public CDropTarget {
DECLARE_MESSAGE_MAP;
bool DropObjectMsg(CDropObjectMsg *msg);
public:
CString _string5;
CString _string6;

View File

@ -21,21 +21,47 @@
*/
#include "titanic/game/missiveomat_button.h"
#include "titanic/core/room_item.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CMissiveOMatButton, CEditControl)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(VisibleMsg)
ON_MESSAGE(MouseDoubleClickMsg)
END_MESSAGE_MAP()
void CMissiveOMatButton::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_fieldFC, indent);
file->writeNumberLine(_buttonId, indent);
CEditControl::save(file, indent);
}
void CMissiveOMatButton::load(SimpleFile *file) {
file->readNumber();
_fieldFC = file->readNumber();
_buttonId = file->readNumber();
CEditControl::load(file);
}
bool CMissiveOMatButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
CMissiveOMatActionMsg actionMsg;
actionMsg._action = _buttonId;
actionMsg.execute(findRoom()->findByName("MissiveOMat"));
return true;
}
bool CMissiveOMatButton::VisibleMsg(CVisibleMsg *msg) {
setVisible(msg->_visible);
return true;
}
bool CMissiveOMatButton::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
CMissiveOMatActionMsg actionMsg;
actionMsg._action = _buttonId;
actionMsg.execute(findRoom()->findByName("MissiveOMat"));
return true;
}
} // End of namespace Titanic

View File

@ -28,11 +28,15 @@
namespace Titanic {
class CMissiveOMatButton : public CEditControl {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool VisibleMsg(CVisibleMsg *msg);
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
public:
int _fieldFC;
int _buttonId;
public:
CLASSDEF;
CMissiveOMatButton() : CEditControl(), _fieldFC(2) {}
CMissiveOMatButton() : CEditControl(), _buttonId(2) {}
/**
* Save the data for the class to file

View File

@ -24,18 +24,36 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CMovieTester, CGameObject)
ON_MESSAGE(MouseButtonDownMsg)
END_MESSAGE_MAP()
void CMovieTester::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_value1, indent);
file->writeNumberLine(_value2, indent);
file->writeNumberLine(_movieNumFrames, indent);
file->writeNumberLine(_movieFrameNum, indent);
CGameObject::save(file, indent);
}
void CMovieTester::load(SimpleFile *file) {
file->readNumber();
_value1 = file->readNumber();
_value2 = file->readNumber();
_movieNumFrames = file->readNumber();
_movieFrameNum = file->readNumber();
CGameObject::load(file);
}
bool CMovieTester::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (msg->_buttons == MB_RIGHT) {
if (--_movieFrameNum < 0) {
_movieFrameNum = _movieNumFrames - 1;
}
} else {
if (++_movieFrameNum >= _movieNumFrames)
_movieFrameNum = 0;
}
loadFrame(_movieFrameNum);
return true;
}
} // End of namespace Titanic

View File

@ -28,11 +28,13 @@
namespace Titanic {
class CMovieTester : public CGameObject {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
public:
int _value1, _value2;
int _movieNumFrames, _movieFrameNum;
public:
CLASSDEF;
CMovieTester() : CGameObject(), _value1(0), _value2(0) {}
CMovieTester() : CGameObject(), _movieNumFrames(0), _movieFrameNum(0) {}
/**
* Save the data for the class to file

View File

@ -21,9 +21,14 @@
*/
#include "titanic/gfx/move_object_button.h"
#include "titanic/core/project_item.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CMoveObjectButton, CSTButton)
ON_MESSAGE(MouseButtonUpMsg)
END_MESSAGE_MAP()
CMoveObjectButton::CMoveObjectButton() : CSTButton(), _field11C(1) {
}
@ -43,4 +48,14 @@ void CMoveObjectButton::load(SimpleFile *file) {
CSTButton::load(file);
}
bool CMoveObjectButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
CGameObject *obj = dynamic_cast<CGameObject *>(getRoot()->findByName(_actionTarget));
if (obj) {
obj->petAddToInventory();
obj->setVisible(_field11C);
}
return true;
}
} // End of namespace Titanic

View File

@ -28,6 +28,8 @@
namespace Titanic {
class CMoveObjectButton : public CSTButton {
DECLARE_MESSAGE_MAP;
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
private:
Point _pos1;
int _field11C;

View File

@ -24,6 +24,11 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CMovePlayerInParrotRoom, CMovePlayerTo)
ON_MESSAGE(ActMsg)
ON_MESSAGE(MouseButtonDownMsg)
END_MESSAGE_MAP()
CMovePlayerInParrotRoom::CMovePlayerInParrotRoom() : CMovePlayerTo() {
}
@ -37,4 +42,20 @@ void CMovePlayerInParrotRoom::load(SimpleFile *file) {
CMovePlayerTo::load(file);
}
bool CMovePlayerInParrotRoom::ActMsg(CActMsg *msg) {
if (msg->_action == "PanAwayFromParrot") {
unlockMouse();
changeView(_destination);
}
return true;
}
bool CMovePlayerInParrotRoom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
lockMouse();
CPanningAwayFromParrotMsg awayMsg(this);
awayMsg.execute("PerchedParrot");
return true;
}
} // End of namespace Titanic

View File

@ -28,6 +28,9 @@
namespace Titanic {
class CMovePlayerInParrotRoom : public CMovePlayerTo {
DECLARE_MESSAGE_MAP;
bool ActMsg(CActMsg *msg);
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
public:
CLASSDEF;
CMovePlayerInParrotRoom();

View File

@ -21,9 +21,15 @@
*/
#include "titanic/moves/move_player_to.h"
#include "titanic/game_manager.h"
namespace Titanic {
BEGIN_MESSAGE_MAP(CMovePlayerTo, CGameObject)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(ActMsg)
END_MESSAGE_MAP()
CMovePlayerTo::CMovePlayerTo() : CGameObject() {
}
@ -41,4 +47,17 @@ void CMovePlayerTo::load(SimpleFile *file) {
CGameObject::load(file);
}
bool CMovePlayerTo::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
CGameManager *gameManager = getGameManager();
if (gameManager)
changeView(_destination);
return true;
}
bool CMovePlayerTo::ActMsg(CActMsg *msg) {
_destination = msg->_action;
return true;
}
} // End of namespace Titanic

View File

@ -28,6 +28,9 @@
namespace Titanic {
class CMovePlayerTo : public CGameObject {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool ActMsg(CActMsg *msg);
protected:
CString _destination;
public:

View File

@ -21,10 +21,16 @@
*/
#include "titanic/moves/move_player_to_from.h"
#include "titanic/core/view_item.h"
#include "titanic/core/link_item.h"
namespace Titanic {
CMovePlayerToFrom::CMovePlayerToFrom() : CGameObject() {
BEGIN_MESSAGE_MAP(CMovePlayerToFrom, CMovePlayerTo)
ON_MESSAGE(MouseButtonDownMsg)
END_MESSAGE_MAP()
CMovePlayerToFrom::CMovePlayerToFrom() : CMovePlayerTo() {
}
void CMovePlayerToFrom::save(SimpleFile *file, int indent) {
@ -41,4 +47,17 @@ void CMovePlayerToFrom::load(SimpleFile *file) {
CGameObject::load(file);
}
bool CMovePlayerToFrom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (_string2.empty()) {
changeView(_destination);
} else {
CViewItem *view = parseView(_string2);
CViewItem *destView = parseView(_destination);
CLinkItem *link = view->findLink(destView);
changeView(_destination, link->getName());
}
return true;
}
} // End of namespace Titanic

View File

@ -23,11 +23,13 @@
#ifndef TITANIC_MOVE_PLAYER_TO_FROM_H
#define TITANIC_MOVE_PLAYER_TO_FROM_H
#include "titanic/core/game_object.h"
#include "titanic/moves/move_player_to.h"
namespace Titanic {
class CMovePlayerToFrom : public CGameObject {
class CMovePlayerToFrom : public CMovePlayerTo {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
private:
CString _string2;
public: