Skip to content

Commit

Permalink
TITANIC: Implemented game pickup classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 27, 2016
1 parent 40ec26b commit c1b6fc3
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 13 deletions.
11 changes: 8 additions & 3 deletions engines/titanic/carry/photograph.cpp
Expand Up @@ -21,6 +21,7 @@
*/

#include "titanic/carry/photograph.h"
#include "titanic/core/dont_save_file_item.h"
#include "titanic/core/room_item.h"

namespace Titanic {
Expand Down Expand Up @@ -59,8 +60,12 @@ bool CPhotograph::MouseDragEndMsg(CMouseDragEndMsg *msg) {
_v1 = 0;
CGameObject *target = msg->_dropTarget;

if (target && target->getName() != "NavigationComputer") {
warning("TODO: CPhotograph::MouseDragEndMsg");
if (target && target->isEquals("NavigationComputer")) {
moveUnder(getDontSave());
makeDirty();
playSound("a#46.wav");
starFn1(14);
showMouse();
return true;
} else {
return CCarry::MouseDragEndMsg(msg);
Expand All @@ -78,7 +83,7 @@ bool CPhotograph::MouseDragStartMsg(CMouseDragStartMsg *msg) {
}

bool CPhotograph::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
if (getRoom()->getName() == "Home") {
if (getRoom()->isEquals("Home")) {
CActMsg actMsg("PlayerPutsPhotoInPET");
actMsg.execute("Doorbot");
}
Expand Down
14 changes: 12 additions & 2 deletions engines/titanic/game/pickup/pick_up.cpp
Expand Up @@ -24,16 +24,26 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CPickUp, CGameObject)
ON_MESSAGE(StatusChangeMsg)
END_MESSAGE_MAP()

void CPickUp::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_fieldBC, indent);
file->writeNumberLine(_enabled, indent);
CGameObject::save(file, indent);
}

void CPickUp::load(SimpleFile *file) {
file->readNumber();
_fieldBC = file->readNumber();
_enabled = file->readNumber();
CGameObject::load(file);
}

bool CPickUp::StatusChangeMsg(CStatusChangeMsg *msg) {
_enabled = msg->_newStatus == 1;
setVisible(_enabled);
return true;
}

} // End of namespace Titanic
8 changes: 5 additions & 3 deletions engines/titanic/game/pickup/pick_up.h
Expand Up @@ -28,11 +28,13 @@
namespace Titanic {

class CPickUp : public CGameObject {
private:
int _fieldBC;
DECLARE_MESSAGE_MAP;
bool StatusChangeMsg(CStatusChangeMsg *msg);
protected:
bool _enabled;
public:
CLASSDEF;
CPickUp() : CGameObject(), _fieldBC(0) {}
CPickUp() : CGameObject(), _enabled(false) {}

/**
* Save the data for the class to file
Expand Down
51 changes: 51 additions & 0 deletions engines/titanic/game/pickup/pick_up_bar_glass.cpp
Expand Up @@ -21,9 +21,16 @@
*/

#include "titanic/game/pickup/pick_up_bar_glass.h"
#include "titanic/core/project_item.h"

namespace Titanic {

BEGIN_MESSAGE_MAP(CPickUpBarGlass, CPickUp)
ON_MESSAGE(StatusChangeMsg)
ON_MESSAGE(MouseDragStartMsg)
ON_MESSAGE(MouseButtonDownMsg)
END_MESSAGE_MAP()

void CPickUpBarGlass::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CPickUp::save(file, indent);
Expand All @@ -34,4 +41,48 @@ void CPickUpBarGlass::load(SimpleFile *file) {
CPickUp::load(file);
}

bool CPickUpBarGlass::StatusChangeMsg(CStatusChangeMsg *msg) {
switch (msg->_newStatus) {
case 0:
setVisible(false);
_enabled = false;
break;
case 1:
setVisible(true);
_enabled = true;
break;
case 2:
setVisible(true);
_enabled = false;
break;
default:
break;
}

return true;
}

bool CPickUpBarGlass::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (checkStartDragging(msg) && _enabled) {
CTurnOn onMsg;
onMsg.execute("BeerGlass");
CVisibleMsg visibleMsg;
visibleMsg.execute("BeerGlass");
CPassOnDragStartMsg passMsg(msg->_mousePos, 1, 3);
passMsg.execute("BeerGlass");

msg->_dragItem = getRoot()->findByName("BeerGlass");

CActMsg actMsg("PlayerTakesGlass");
actMsg.execute("Barbot");
return true;
} else {
return false;
}
}

bool CPickUpBarGlass::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
return true;
}

} // End of namespace Titanic
4 changes: 4 additions & 0 deletions engines/titanic/game/pickup/pick_up_bar_glass.h
Expand Up @@ -28,6 +28,10 @@
namespace Titanic {

class CPickUpBarGlass : public CPickUp {
DECLARE_MESSAGE_MAP;
bool StatusChangeMsg(CStatusChangeMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
public:
CLASSDEF;

Expand Down
67 changes: 64 additions & 3 deletions engines/titanic/game/pickup/pick_up_hose.cpp
Expand Up @@ -21,25 +21,86 @@
*/

#include "titanic/game/pickup/pick_up_hose.h"
#include "titanic/core/project_item.h"
#include "titanic/core/room_item.h"
#include "titanic/core/view_item.h"

namespace Titanic {

int CPickUpHose::_v1;
BEGIN_MESSAGE_MAP(CPickUpHose, CPickUp)
ON_MESSAGE(MouseDragStartMsg)
ON_MESSAGE(StatusChangeMsg)
ON_MESSAGE(EnterViewMsg)
ON_MESSAGE(MouseButtonDownMsg)
END_MESSAGE_MAP()

bool CPickUpHose::_v1;

void CPickUpHose::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_string1, indent);
file->writeQuotedLine(_target, indent);
file->writeNumberLine(_v1, indent);

CPickUp::save(file, indent);
}

void CPickUpHose::load(SimpleFile *file) {
file->readNumber();
_string1 = file->readString();
_target = file->readString();
_v1 = file->readNumber();

CPickUp::load(file);
}

bool CPickUpHose::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (!checkStartDragging(msg))
return true;
if (_v1 || !_enabled)
return false;

CViewItem *view = getView();
if (view) {
_v1 = true;
CRoomItem *room = locateRoom("Arboretum");
CTreeItem *hose = room ? room->findByName("Hose") : nullptr;

if (!hose) {
room = locateRoom("FrozenArboretum");
if (room)
hose = room->findByName("Hose");
}

if (hose) {
CVisibleMsg visibleMsg;
visibleMsg.execute(this);
moveUnder(view);

CPassOnDragStartMsg passMsg(msg->_mousePos, 1);
passMsg.execute("Hose");

msg->_dragItem = getRoot()->findByName("Hose");
_cursorId = CURSOR_IGNORE;

CActMsg actMsg("PlayerGetsHose");
actMsg.execute(_target);
}
}

return true;
}

bool CPickUpHose::StatusChangeMsg(CStatusChangeMsg *msg) {
_cursorId = msg->_newStatus == 1 ? CURSOR_HAND : CURSOR_IGNORE;
return true;
}

bool CPickUpHose::EnterViewMsg(CEnterViewMsg *msg) {
_cursorId = CURSOR_IGNORE;
return true;
}

bool CPickUpHose::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
return _enabled;
}

} // End of namespace Titanic
9 changes: 7 additions & 2 deletions engines/titanic/game/pickup/pick_up_hose.h
Expand Up @@ -28,10 +28,15 @@
namespace Titanic {

class CPickUpHose : public CPickUp {
DECLARE_MESSAGE_MAP;
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
bool StatusChangeMsg(CStatusChangeMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
private:
static int _v1;
static bool _v1;

CString _string1;
CString _target;
public:
CLASSDEF;

Expand Down
25 changes: 25 additions & 0 deletions engines/titanic/game/pickup/pick_up_lemon.cpp
Expand Up @@ -21,9 +21,15 @@
*/

#include "titanic/game/pickup/pick_up_lemon.h"
#include "titanic/core/project_item.h"

namespace Titanic {

BEGIN_MESSAGE_MAP(CPickUpLemon, CPickUp)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(MouseDragStartMsg)
END_MESSAGE_MAP()

void CPickUpLemon::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CPickUp::save(file, indent);
Expand All @@ -34,4 +40,23 @@ void CPickUpLemon::load(SimpleFile *file) {
CPickUp::load(file);
}

bool CPickUpLemon::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
return true;
}

bool CPickUpLemon::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (!checkStartDragging(msg))
return true;
if (!_enabled)
return false;

CVisibleMsg visibleMsg;
visibleMsg.execute("Lemon");
CPassOnDragStartMsg passMsg(msg->_mousePos, 1);
passMsg.execute("Lemon");

msg->_dragItem = getRoot()->findByName("Lemon");
return true;
}

} // End of namespace Titanic
3 changes: 3 additions & 0 deletions engines/titanic/game/pickup/pick_up_lemon.h
Expand Up @@ -28,6 +28,9 @@
namespace Titanic {

class CPickUpLemon : public CPickUp {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
public:
CLASSDEF;

Expand Down
36 changes: 36 additions & 0 deletions engines/titanic/game/pickup/pick_up_speech_centre.cpp
Expand Up @@ -21,9 +21,16 @@
*/

#include "titanic/game/pickup/pick_up_speech_centre.h"
#include "titanic/core/project_item.h"

namespace Titanic {

BEGIN_MESSAGE_MAP(CPickUpSpeechCentre, CPickUp)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(StatusChangeMsg)
ON_MESSAGE(MouseDragStartMsg)
END_MESSAGE_MAP()

void CPickUpSpeechCentre::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CPickUp::save(file, indent);
Expand All @@ -34,4 +41,33 @@ void CPickUpSpeechCentre::load(SimpleFile *file) {
CPickUp::load(file);
}

bool CPickUpSpeechCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
return true;
}

bool CPickUpSpeechCentre::StatusChangeMsg(CStatusChangeMsg *msg) {
_enabled = msg->_newStatus == 1;
return true;
}

bool CPickUpSpeechCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (checkStartDragging(msg)) {
if (_enabled) {
CVisibleMsg visibleMsg;
visibleMsg.execute("SpeechCentre");
CPassOnDragStartMsg passMsg(msg->_mousePos, 1);
passMsg.execute("SpeechCentre");

msg->_dragItem = getRoot()->findByName("SpeechCentre");

CActMsg actMsg("PlayerGetsSpeechCentre");
actMsg.execute("SeasonalAdjust");
} else {
petDisplayMessage("You can',27h,'t pick this up on account of it being stuck to the branch.");
}
}

return true;
}

} // End of namespace Titanic
4 changes: 4 additions & 0 deletions engines/titanic/game/pickup/pick_up_speech_centre.h
Expand Up @@ -28,6 +28,10 @@
namespace Titanic {

class CPickUpSpeechCentre : public CPickUp {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool StatusChangeMsg(CStatusChangeMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
public:
CLASSDEF;

Expand Down

0 comments on commit c1b6fc3

Please sign in to comment.