Skip to content

Commit

Permalink
TITANIC: Implemented more game classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 28, 2016
1 parent 67be58f commit 8f29f06
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 39 deletions.
103 changes: 94 additions & 9 deletions engines/titanic/game/season_background.cpp
Expand Up @@ -24,28 +24,113 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CSeasonBackground, CBackground)
ON_MESSAGE(EnterViewMsg)
ON_MESSAGE(ChangeSeasonMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(ActMsg)
END_MESSAGE_MAP()

CSeasonBackground::CSeasonBackground() : CBackground(),
_fieldE0(0), _fieldE4(0), _fieldE8(46), _fieldEC(0) {
_seasonNum(SEASON_SUMMER), _flag(false), _defaultFrame(46), _unused(0) {
}

void CSeasonBackground::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(_seasonNum, indent);
file->writeNumberLine(_flag, indent);
file->writeNumberLine(_defaultFrame, indent);
file->writeNumberLine(_unused, indent);

CBackground::save(file, indent);
}

void CSeasonBackground::load(SimpleFile *file) {
file->readNumber();
_fieldE0 = file->readNumber();
_fieldE4 = file->readNumber();
_fieldE8 = file->readNumber();
_fieldEC = file->readNumber();
_seasonNum = (Season)file->readNumber();
_flag = file->readNumber();
_defaultFrame = file->readNumber();
_unused = file->readNumber();

CBackground::load(file);
}

bool CSeasonBackground::EnterViewMsg(CEnterViewMsg *msg) {
loadFrame(_defaultFrame);
return true;
}

bool CSeasonBackground::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
_seasonNum = (Season)(((int)_seasonNum + 1) % 4);

switch (_seasonNum) {
case SEASON_SUMMER:
playMovie(0, 45, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 45;
break;

case SEASON_AUTUMN:
if (_flag) {
playMovie(232, 278, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 278;
} else {
playMovie(45, 91, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 91;
}
break;

case SEASON_WINTER:
if (_flag) {
playMovie(278, 326, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 326;
} else {
CStatusChangeMsg changeMsg;
changeMsg._newStatus = 0;
changeMsg.execute("PickUpSpeechCentre");
playMovie(91, 139, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 139;
}
break;

case SEASON_SPRING:
if (_flag) {
playMovie(326, 417, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 417;
} else {
playMovie(139, 228, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
_defaultFrame = 228;
}
break;

default:
break;
}

return true;
}

bool CSeasonBackground::MovieEndMsg(CMovieEndMsg *msg) {
if (msg->_endFrame == _defaultFrame) {
CTurnOn onMsg;
onMsg.execute("SeasonalAdjust");
}

if (msg->_endFrame == 91 && !_flag) {
CStatusChangeMsg changeMsg;
changeMsg.execute("PickUpSpeechCentre");
}

return true;
}

bool CSeasonBackground::ActMsg(CActMsg *msg) {
if (msg->_action == "PlayerGetsSpeechCentre") {
loadFrame(278);
_defaultFrame = 278;
_flag = true;
}

return true;
}

} // End of namespace Titanic
13 changes: 9 additions & 4 deletions engines/titanic/game/season_background.h
Expand Up @@ -28,11 +28,16 @@
namespace Titanic {

class CSeasonBackground : public CBackground {
DECLARE_MESSAGE_MAP;
bool EnterViewMsg(CEnterViewMsg *msg);
bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
bool ActMsg(CActMsg *msg);
public:
int _fieldE0;
int _fieldE4;
int _fieldE8;
int _fieldEC;
Season _seasonNum;
bool _flag;
int _defaultFrame;
int _unused;
public:
CLASSDEF;
CSeasonBackground();
Expand Down
27 changes: 23 additions & 4 deletions engines/titanic/game/season_barrel.cpp
Expand Up @@ -24,19 +24,38 @@

namespace Titanic {

BEGIN_MESSAGE_MAP(CSeasonBarrel, CBackground)
ON_MESSAGE(ChangeSeasonMsg)
ON_MESSAGE(EnterViewMsg)
END_MESSAGE_MAP()

void CSeasonBarrel::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_fieldE0, indent);
file->writeNumberLine(_fieldE4, indent);
file->writeNumberLine(_unused, indent);
file->writeNumberLine(_startFrame, indent);

CBackground::save(file, indent);
}

void CSeasonBarrel::load(SimpleFile *file) {
file->readNumber();
_fieldE0 = file->readNumber();
_fieldE4 = file->readNumber();
_unused = file->readNumber();
_startFrame = file->readNumber();
CBackground::load(file);
}

bool CSeasonBarrel::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
if (_startFrame >= 28)
_startFrame = 0;

playMovie(_startFrame, _startFrame + 7, 0);
_startFrame += 7;
return true;
}

bool CSeasonBarrel::EnterViewMsg(CEnterViewMsg *msg) {
loadFrame(_startFrame);
return true;
}

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

class CSeasonBarrel : public CBackground {
DECLARE_MESSAGE_MAP;
bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
public:
int _fieldE0;
int _fieldE4;
int _unused;
int _startFrame;
public:
CLASSDEF;
CSeasonBarrel() : CBackground(), _fieldE0(0), _fieldE4(7) {}
CSeasonBarrel() : CBackground(), _unused(0), _startFrame(7) {}

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

#include "titanic/game/service_elevator_window.h"
#include "titanic/core/room_item.h"
#include "titanic/npcs/doorbot.h"

namespace Titanic {

BEGIN_MESSAGE_MAP(CServiceElevatorWindow, CBackground)
ON_MESSAGE(ServiceElevatorFloorChangeMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(EnterViewMsg)
END_MESSAGE_MAP()

static const int FACTORS[4] = { 0, 20, 100, 0 };

CServiceElevatorWindow::CServiceElevatorWindow() : CBackground(),
_fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) {
}
Expand All @@ -48,4 +58,57 @@ void CServiceElevatorWindow::load(SimpleFile *file) {
CBackground::load(file);
}

bool CServiceElevatorWindow::ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg) {
if (getView() == findView()) {
CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot"));
int val = (_fieldE8 && doorbot) ? 65 : 15;
CMovieClip *clip = _movieClips.findByName("Going Up");

if (!clip)
return true;

int count = _endFrame - _startFrame;
setMovieFrameRate(1.0 * count / val);

int startFrame = clip->_startFrame + count * FACTORS[msg->_value1] / 100;
int endFrame = clip->_startFrame + count * FACTORS[msg->_value2] / 100;

if (_fieldE4) {
playMovie(startFrame, endFrame, MOVIE_NOTIFY_OBJECT);
} else {
playMovie(startFrame, endFrame, 0);
if (_fieldEC)
playClip("Into Space");
}
}

_fieldE0 = msg->_value2;
return true;
}

bool CServiceElevatorWindow::MovieEndMsg(CMovieEndMsg *msg) {
CServiceElevatorMsg elevMsg(5);
elevMsg.execute(findRoom()->findByName("Service Elevator Entity"));
return true;
}

bool CServiceElevatorWindow::EnterViewMsg(CEnterViewMsg *msg) {
if (_fieldEC) {
playClip("Fade Up");
playMovie(1, 2, 0);
} else {
CMovieClip *clip = _movieClips.findByName("Going Up");

if (clip) {
int frameNum = clip->_startFrame + (clip->_endFrame - clip->_startFrame)
* FACTORS[_fieldE0] / 100;
loadFrame(frameNum);
} else {
loadFrame(0);
}
}

return true;
}

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

class CServiceElevatorWindow : public CBackground {
DECLARE_MESSAGE_MAP;
bool ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
public:
int _fieldE0;
int _fieldE4;
Expand Down

0 comments on commit 8f29f06

Please sign in to comment.