diff options
author | Paul Gilbert | 2016-08-24 23:40:02 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-08-24 23:40:02 -0400 |
commit | 58df8d72f0dc44480871384e280b0885ece0c577 (patch) | |
tree | e4ba07aa73a7aaea9d7b3cb7a478690e29f22644 /engines/titanic/game | |
parent | 25e977f81dacf4ad6465ba53bc7425532786109d (diff) | |
download | scummvm-rg350-58df8d72f0dc44480871384e280b0885ece0c577.tar.gz scummvm-rg350-58df8d72f0dc44480871384e280b0885ece0c577.tar.bz2 scummvm-rg350-58df8d72f0dc44480871384e280b0885ece0c577.zip |
TITANIC: Implemented CBedhead class
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/sgt/bedhead.cpp | 113 | ||||
-rw-r--r-- | engines/titanic/game/sgt/bedhead.h | 40 |
2 files changed, 151 insertions, 2 deletions
diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp index 6f427ab625..45031bd6b3 100644 --- a/engines/titanic/game/sgt/bedhead.cpp +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -29,6 +29,44 @@ BEGIN_MESSAGE_MAP(CBedhead, CSGTStateRoom) ON_MESSAGE(TurnOff) END_MESSAGE_MAP() +void BedheadEntry::load(Common::SeekableReadStream *s) { + // TODO +} + +/*------------------------------------------------------------------------*/ + +void BedheadEntries::load(Common::SeekableReadStream *s) { + resize(s->readUint32LE()); + for (uint idx = 0; idx < size(); ++idx) + (*this)[idx].load(s); +} + +/*------------------------------------------------------------------------*/ + +void TurnOnEntries::load(Common::SeekableReadStream *s) { + _closed.load(s); + _restingTV.load(s); + _restingUV.load(s); + _closedWrong.load(s); +} + +/*------------------------------------------------------------------------*/ + +void TurnOffEntries::load(Common::SeekableReadStream *s) { + _open.load(s); + _restingUTV.load(s); + _restingV.load(s); + _restingG.load(s); + _openWrong.load(s); + _restingDWrong.load(s); +} + +/*------------------------------------------------------------------------*/ + +CBedhead::CBedhead() : CSGTStateRoom() { + // TODO: Load data for turn on/off methods +} + void CBedhead::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -40,12 +78,83 @@ void CBedhead::load(SimpleFile *file) { } bool CBedhead::TurnOn(CTurnOn *msg) { - // TODO + if (_statics->_v2 == "Closed" || _statics->_v2 == "RestingUnderTV") + return true; + + const BedheadEntries *data = nullptr; + if (_statics->_v1 == "Closed") + data = &_on._closed; + else if (_statics->_v1 == "RestingTV") + data = &_on._restingTV; + else if (_statics->_v1 == "RestingUV") + data = &_on._restingUV; + else if (_statics->_v1 == "ClosedWrong") + data = &_on._closedWrong; + else + return true; + + for (uint idx = 0; idx < data->size(); ++idx) { + const BedheadEntry &entry = (*data)[idx]; + if ((entry._name1 == _statics->_v4 || entry._name1 == "Any") + && (entry._name2 == _statics->_v3 || entry._name2 == "Any") + && (entry._name3 == _statics->_v5 || entry._name3 == "Any")) { + CVisibleMsg visibleMsg(false); + visibleMsg.execute("Bedfoot"); + setVisible(true); + + _statics->_v1 = entry._name4; + playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("b#6.wav"); + _fieldE0 = false; + } + } + + if (_statics->_v1 == "Open") { + playMovie(71, 78, 0); + playSound("196_436 bed inflate 2.wav"); + } + return true; } bool CBedhead::TurnOff(CTurnOff *msg) { - // TODO + if (_statics->_v1 == "Open") { + playMovie(78, 85, 0); + playSound("191_436_bed inflate deflate.wav"); + } + + BedheadEntries *data = nullptr; + if (_statics->_v1 == "Open") + data = &_off._open; + else if (_statics->_v1 == "RestingUTV") + data = &_off._restingUTV; + else if (_statics->_v1 == "RestingV") + data = &_off._restingV; + else if (_statics->_v1 == "RestingG") + data = &_off._restingG; + else if (_statics->_v1 == "OpenWrong") + data = &_off._openWrong; + else if (_statics->_v1 == "RestingDWrong") + data = &_off._restingDWrong; + else + return true; + + for (uint idx = 0; idx < data->size(); ++idx) { + const BedheadEntry &entry = (*data)[idx]; + if ((entry._name1 == _statics->_v4 || entry._name1 == "Any") + && (entry._name2 == _statics->_v3 || entry._name2 == "Any") + && (entry._name3 == _statics->_v5 || entry._name3 == "Any")) { + CVisibleMsg visibleMsg(false); + visibleMsg.execute("Bedfoot"); + setVisible(true); + + _statics->_v1 = entry._name4; + playMovie(entry._startFrame, entry._endFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + playSound("193_436_bed fold up 1.wav"); + _fieldE0 = false; + } + } + return true; } diff --git a/engines/titanic/game/sgt/bedhead.h b/engines/titanic/game/sgt/bedhead.h index 665dec021c..53c61e19d8 100644 --- a/engines/titanic/game/sgt/bedhead.h +++ b/engines/titanic/game/sgt/bedhead.h @@ -23,16 +23,56 @@ #ifndef TITANIC_BEDHEAD_H #define TITANIC_BEDHEAD_H +#include "common/array.h" #include "titanic/game/sgt/sgt_state_room.h" namespace Titanic { +struct BedheadEntry { + CString _name1; + CString _name2; + CString _name3; + CString _name4; + int _startFrame; + int _endFrame; + + void load(Common::SeekableReadStream *s); +}; +class BedheadEntries : public Common::Array<BedheadEntry> { +public: + void load(Common::SeekableReadStream *s); +}; + +struct TurnOnEntries { + BedheadEntries _closed; + BedheadEntries _restingTV; + BedheadEntries _restingUV; + BedheadEntries _closedWrong; + + void load(Common::SeekableReadStream *s); +}; + +struct TurnOffEntries { + BedheadEntries _open; + BedheadEntries _restingUTV; + BedheadEntries _restingV; + BedheadEntries _restingG; + BedheadEntries _openWrong; + BedheadEntries _restingDWrong; + + void load(Common::SeekableReadStream *s); +}; + class CBedhead : public CSGTStateRoom { DECLARE_MESSAGE_MAP; bool TurnOn(CTurnOn *msg); bool TurnOff(CTurnOff *msg); +private: + TurnOnEntries _on; + TurnOffEntries _off; public: CLASSDEF; + CBedhead(); /** * Save the data for the class to file |