TITANIC: Implemented CBedhead class

This commit is contained in:
Paul Gilbert
2016-08-24 23:40:02 -04:00
parent 25e977f81d
commit 58df8d72f0
2 changed files with 151 additions and 2 deletions
+111 -2
View File
@@ -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;
}
+40
View File
@@ -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