Skip to content

Commit

Permalink
TITANIC: Implemented remaining game classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 28, 2016
1 parent 1760fb3 commit 4933b59
Show file tree
Hide file tree
Showing 42 changed files with 722 additions and 56 deletions.
29 changes: 29 additions & 0 deletions engines/titanic/carry/vision_centre.cpp
Expand Up @@ -24,6 +24,12 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CVisionCentre, CBrain)
ON_MESSAGE(PuzzleSolvedMsg)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(MouseDragStartMsg)
END_MESSAGE_MAP()

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

bool CVisionCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) {
_fieldE0 = true;
return true;
}

bool CVisionCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (_fieldE0) {
return CBrain::MouseButtonDownMsg(msg);
} else {
petDisplayMessage(1, "It would be nice if you could take that but you can't.");
return true;
}
}

bool CVisionCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (_fieldE0) {
return CBrain::MouseDragStartMsg(msg);
} else {
petDisplayMessage(1, "It would be nice if you could take that but you can't.");
return true;
}
}

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

class CVisionCentre : public CBrain {
DECLARE_MESSAGE_MAP;
bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg);
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseDragStartMsg(CMouseDragStartMsg *msg);
public:
CLASSDEF;

Expand Down
25 changes: 18 additions & 7 deletions engines/titanic/core/turn_on_play_sound.cpp
Expand Up @@ -24,26 +24,37 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CTurnOnPlaySound, CTurnOnObject)
ON_MESSAGE(MouseButtonUpMsg)
END_MESSAGE_MAP()

CTurnOnPlaySound::CTurnOnPlaySound() : CTurnOnObject(),
_string3("NULL"), _fieldF8(80), _fieldFC(0) {
_soundName("NULL"), _soundVolume(80), _soundVal3(0) {
}

void CTurnOnPlaySound::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeQuotedLine(_string3, indent);
file->writeNumberLine(_fieldF8, indent);
file->writeNumberLine(_fieldFC, indent);
file->writeQuotedLine(_soundName, indent);
file->writeNumberLine(_soundVolume, indent);
file->writeNumberLine(_soundVal3, indent);

CTurnOnObject::save(file, indent);
}

void CTurnOnPlaySound::load(SimpleFile *file) {
file->readNumber();
_string3 = file->readString();
_fieldF8 = file->readNumber();
_fieldFC = file->readNumber();
_soundName = file->readString();
_soundVolume = file->readNumber();
_soundVal3 = file->readNumber();

CTurnOnObject::load(file);
}

bool CTurnOnPlaySound::MouseButtonUpMsg(CMouseButtonUpMsg *msg) {
if (_soundName != "NULL")
playSound(_soundName, _soundVolume, _soundVal3);

return CTurnOnObject::MouseButtonUpMsg(msg);
}

} // End of namespace Titanic
8 changes: 5 additions & 3 deletions engines/titanic/core/turn_on_play_sound.h
Expand Up @@ -28,10 +28,12 @@
namespace Titanic {

class CTurnOnPlaySound : public CTurnOnObject {
DECLARE_MESSAGE_MAP;
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
private:
CString _string3;
int _fieldF8;
int _fieldFC;
CString _soundName;
int _soundVolume;
int _soundVal3;
public:
CLASSDEF;
CTurnOnPlaySound();
Expand Down
49 changes: 39 additions & 10 deletions engines/titanic/core/turn_on_turn_off.cpp
Expand Up @@ -24,30 +24,59 @@

namespace Titanic {

CTurnOnTurnOff::CTurnOnTurnOff() : CBackground(), _fieldE0(0),
_fieldE4(0), _fieldE8(0), _fieldEC(0), _fieldF0(0) {
BEGIN_MESSAGE_MAP(CTurnOnTurnOff, CBackground)
ON_MESSAGE(TurnOn)
ON_MESSAGE(TurnOff)
END_MESSAGE_MAP()

CTurnOnTurnOff::CTurnOnTurnOff() : CBackground(), _startFrameOn(0),
_endFrameOn(0), _startFrameOff(0), _endFrameOff(0), _fieldF0(false) {
}

void CTurnOnTurnOff::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_fieldE0, indent);
file->writeNumberLine(_fieldE4, indent);
file->writeNumberLine(_fieldE8, indent);
file->writeNumberLine(_fieldEC, indent);
file->writeNumberLine(_startFrameOn, indent);
file->writeNumberLine(_endFrameOn, indent);
file->writeNumberLine(_startFrameOff, indent);
file->writeNumberLine(_endFrameOff, indent);
file->writeNumberLine(_fieldF0, indent);

CBackground::save(file, indent);
}

void CTurnOnTurnOff::load(SimpleFile *file) {
file->readNumber();
_fieldE0 = file->readNumber();
_fieldE4 = file->readNumber();
_fieldE8 = file->readNumber();
_fieldEC = file->readNumber();
_startFrameOn = file->readNumber();
_endFrameOn = file->readNumber();
_startFrameOff = file->readNumber();
_endFrameOff = file->readNumber();
_fieldF0 = file->readNumber();

CBackground::load(file);
}

bool CTurnOnTurnOff::TurnOn(CTurnOn *msg) {
if (!_fieldF0) {
if (_fieldDC)
playMovie(_startFrameOn, _endFrameOn, MOVIE_GAMESTATE);
else
playMovie(_startFrameOn, _endFrameOn, MOVIE_NOTIFY_OBJECT);
_fieldF0 = true;
}

return true;
}

bool CTurnOnTurnOff::TurnOff(CTurnOff *msg) {
if (!_fieldF0) {
if (_fieldDC)
playMovie(_startFrameOff, _endFrameOff, MOVIE_GAMESTATE);
else
playMovie(_startFrameOff, _endFrameOff, MOVIE_NOTIFY_OBJECT);
_fieldF0 = true;
}

return true;
}

} // End of namespace Titanic
13 changes: 8 additions & 5 deletions engines/titanic/core/turn_on_turn_off.h
Expand Up @@ -28,12 +28,15 @@
namespace Titanic {

class CTurnOnTurnOff : public CBackground {
DECLARE_MESSAGE_MAP;
bool TurnOn(CTurnOn *msg);
bool TurnOff(CTurnOff *msg);
private:
int _fieldE0;
int _fieldE4;
int _fieldE8;
int _fieldEC;
int _fieldF0;
int _startFrameOn;
int _endFrameOn;
int _startFrameOff;
int _endFrameOff;
bool _fieldF0;
public:
CLASSDEF;
CTurnOnTurnOff();
Expand Down
18 changes: 16 additions & 2 deletions engines/titanic/game/placeholder/tv_on_bar.cpp
Expand Up @@ -24,16 +24,30 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CTVOnBar, CPlaceHolder)
ON_MESSAGE(VisibleMsg)
END_MESSAGE_MAP()

void CTVOnBar::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writePoint(_pos1, indent);
file->writePoint(_tvPos, indent);
CPlaceHolder::save(file, indent);
}

void CTVOnBar::load(SimpleFile *file) {
file->readNumber();
_pos1 = file->readPoint();
_tvPos = file->readPoint();
CPlaceHolder::load(file);
}

bool CTVOnBar::VisibleMsg(CVisibleMsg *msg) {
setVisible(msg->_visible);
if (msg->_visible)
setPosition(_tvPos);
else
setPosition(Point(0, 0));

return true;
}

} // End of namespace Titanic
4 changes: 3 additions & 1 deletion engines/titanic/game/placeholder/tv_on_bar.h
Expand Up @@ -28,8 +28,10 @@
namespace Titanic {

class CTVOnBar : public CPlaceHolder {
DECLARE_MESSAGE_MAP;
bool VisibleMsg(CVisibleMsg *msg);
private:
Point _pos1;
Point _tvPos;
public:
CLASSDEF;

Expand Down
44 changes: 44 additions & 0 deletions engines/titanic/game/sgt/sgt_nav.cpp
Expand Up @@ -24,6 +24,11 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(SGTNav, CSGTStateRoom)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(MouseMoveMsg)
END_MESSAGE_MAP()

void SGTNav::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CSGTStateRoom::save(file, indent);
Expand All @@ -34,4 +39,43 @@ void SGTNav::load(SimpleFile *file) {
CSGTStateRoom::load(file);
}

bool SGTNav::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
CTurnOn onMsg;
CTurnOff offMsg;

if (_statics->_v6 == "Open" && _statics->_v1 == "Open") {
if (_statics->_v3 == "Open")
offMsg.execute("Vase");
if (_statics->_v4 == "Closed")
onMsg.execute("SGTTV");
if (_statics->_v7 == "Open")
offMsg.execute("Drawer");
if (_statics->_v8 == "Open")
offMsg.execute("Armchair");
if (_statics->_v9 == "Open")
offMsg.execute("Deskchair");
if (_statics->_v12 == "Open")
offMsg.execute("Toilet");

changeView("SGTState.Node 2.E");
} else if (_statics->_v1 == "Open") {
petDisplayMessage(1, "This is your stateroom. It is for sleeping. If you desire "
"entertainment or relaxation, please visit your local leisure lounge.");
} else if (_statics->_v6 == "Closed") {
petDisplayMessage(1, "The bed will not currently support your weight."
" We are working on this problem but are unlikely to be able to fix it.");
}

return true;
}

bool SGTNav::MouseMoveMsg(CMouseMoveMsg *msg) {
if (_statics->_v6 == "Open" && _statics->_v1 == "Open")
_cursorId = CURSOR_MOVE_FORWARD;
else
_cursorId = CURSOR_ARROW;

return true;
}

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

class SGTNav : public CSGTStateRoom {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MouseMoveMsg(CMouseMoveMsg *msg);
public:
CLASSDEF;

Expand Down
44 changes: 44 additions & 0 deletions engines/titanic/game/sgt/toilet.cpp
Expand Up @@ -24,6 +24,12 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CToilet, CSGTStateRoom)
ON_MESSAGE(TurnOn)
ON_MESSAGE(TurnOff)
ON_MESSAGE(MovieEndMsg)
END_MESSAGE_MAP()

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

bool CToilet::TurnOn(CTurnOn *msg) {
if (CSGTStateRoom::_statics->_v12 == "Closed"
&& CSGTStateRoom::_statics->_v10 == "Open"
&& CSGTStateRoom::_statics->_v8 == "Closed") {
setVisible(true);
CSGTStateRoom::_statics->_v12 = "Open";

_fieldE0 = false;
_startFrame = 0;
_endFrame = 11;
playMovie(0, 11, MOVIE_GAMESTATE);
playSound("b#1.wav");
}

return true;
}

bool CToilet::TurnOff(CTurnOff *msg) {
if (CSGTStateRoom::_statics->_v12 == "Open") {
CSGTStateRoom::_statics->_v12 = "Closed";

_fieldE0 = true;
_startFrame = 11;
_endFrame = 18;
playMovie(11, 18, MOVIE_GAMESTATE);
playSound("b#1.wav");
}

return true;
}

bool CToilet::MovieEndMsg(CMovieEndMsg *msg) {
if (CSGTStateRoom::_statics->_v12 == "Closed")
setVisible(false);

return true;
}

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

class CToilet : public CSGTStateRoom {
DECLARE_MESSAGE_MAP;
bool TurnOn(CTurnOn *msg);
bool TurnOff(CTurnOff *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
public:
CLASSDEF;

Expand Down

0 comments on commit 4933b59

Please sign in to comment.